INNER CODE UNIT · JavaScript
pickSigningAlg
DinoChiesa/jwt-webtool · src/js/app.js:479
const pickSigningAlg = (key) => rdg.arrayItem(getAcceptableSigningAlgs(key));
const pickKeyEncryptionAlg = (key) =>
rdg.arrayItem(getAcceptableEncryptionAlgs(key));
const pickContentEncryptionAlg = () =>
datamodel["sel-enc"] || rdg.arrayItem(contentEncryptionAlgs);
const isSymmetric = (alg) => alg.startsWith("HS");
function checkKeyLength(alg, exact, keybuffer) {
const length = keybuffer.byteLength,
requiredLength = requiredKeyBitsForAlg(alg) / 8,
okResult = exact ? length == requiredLength : length >= requiredLength;
if (okResult) return Promise.resolve(keybuffer);
const errorMsg = exact
? `inappropriate key length, provided=${length}, required=${requiredLength}`
: `insufficient key length. You need at least ${requiredLength} bytes to use ${alg}`;