Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
21 lines
607 B
Plaintext
21 lines
607 B
Plaintext
import { JOSENotSupported } from '../util/errors.js';
|
|
import random from '../runtime/random.js';
|
|
export function bitLength(alg) {
|
|
switch (alg) {
|
|
case 'A128GCM':
|
|
case 'A128GCMKW':
|
|
case 'A192GCM':
|
|
case 'A192GCMKW':
|
|
case 'A256GCM':
|
|
case 'A256GCMKW':
|
|
return 96;
|
|
case 'A128CBC-HS256':
|
|
case 'A192CBC-HS384':
|
|
case 'A256CBC-HS512':
|
|
return 128;
|
|
default:
|
|
throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
|
|
}
|
|
}
|
|
export default (alg) => random(new Uint8Array(bitLength(alg) >> 3));
|