INNER CODE UNIT · JavaScript

pickContentEncryptionAlg

DinoChiesa/jwt-webtool · src/js/app.js:484

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}`;
  return Promise.reject(new Error(errorMsg));
}

function retrieveCryptoKey(header, options) {
  // options = {direction:'encrypt'} or {direction:'decrypt'}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…