INNER CODE UNIT · JavaScript
isAppropriateEncryptingAlg
DinoChiesa/jwt-webtool · src/js/app.js:476
const isAppropriateEncryptingAlg = (alg, key) =>
getAcceptableEncryptionAlgs(key).indexOf(alg) >= 0;
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);