/var/www/greso.tech/server/nsm/node_modules/jose/dist/node/esm/runtime
NameSizeModeActions
aeskw.js20990644editdlrm
asn1.js15220644editdlrm
asn1_sequence_decoder.js12850644editdlrm
asn1_sequence_encoder.js33440644editdlrm
base64url.js7360644editdlrm
cbc_tag.js3830644editdlrm
check_cek_length.js13150644editdlrm
check_modulus_length.js15450644editdlrm
ciphers.js1700644editdlrm
decrypt.js32970644editdlrm
digest.js1410644editdlrm
dsa_digest.js6120644editdlrm
ecdhes.js24470644editdlrm
encrypt.js27670644editdlrm
fetch_jwks.js12770644editdlrm
flags.js4190644editdlrm
generate.js39070644editdlrm
get_named_curve.js32620644editdlrm
get_sign_verify_key.js7590644editdlrm
hmac_digest.js4060644editdlrm
is_key_like.js3500644editdlrm
is_key_object.js2030644editdlrm
jwk_to_key.js48880644editdlrm
key_to_jwk.js65080644editdlrm
node_key.js33870644editdlrm
pbes2kw.js18440644editdlrm
random.js520644editdlrm
rsaes.js21910644editdlrm
sign.js7240644editdlrm
timing_safe_equal.js1120644editdlrm
verify.js10570644editdlrm
webcrypto.js2490644editdlrm
zlib.js3070644editdlrm
Edit: /var/www/greso.tech/server/nsm/node_modules/jose/dist/node/esm/runtime/encrypt.js (2767B)
import { createCipheriv, KeyObject } from 'crypto'; import checkIvLength from '../lib/check_iv_length.js'; import checkCekLength from './check_cek_length.js'; import { concat } from '../lib/buffer_utils.js'; import cbcTag from './cbc_tag.js'; import { isCryptoKey } from './webcrypto.js'; import { checkEncCryptoKey } from '../lib/crypto_key.js'; import isKeyObject from './is_key_object.js'; import invalidKeyInput from '../lib/invalid_key_input.js'; import { JOSENotSupported } from '../util/errors.js'; import supported from './ciphers.js'; import { types } from './is_key_like.js'; function cbcEncrypt(enc, plaintext, cek, iv, aad) { const keySize = parseInt(enc.slice(1, 4), 10); if (isKeyObject(cek)) { cek = cek.export(); } const encKey = cek.subarray(keySize >> 3); const macKey = cek.subarray(0, keySize >> 3); const algorithm = `aes-${keySize}-cbc`; if (!supported(algorithm)) { throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`); } const cipher = createCipheriv(algorithm, encKey, iv); const ciphertext = concat(cipher.update(plaintext), cipher.final()); const macSize = parseInt(enc.slice(-3), 10); const tag = cbcTag(aad, iv, ciphertext, macSize, macKey, keySize); return { ciphertext, tag }; } function gcmEncrypt(enc, plaintext, cek, iv, aad) { const keySize = parseInt(enc.slice(1, 4), 10); const algorithm = `aes-${keySize}-gcm`; if (!supported(algorithm)) { throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`); } const cipher = createCipheriv(algorithm, cek, iv, { authTagLength: 16 }); if (aad.byteLength) { cipher.setAAD(aad, { plaintextLength: plaintext.length }); } const ciphertext = cipher.update(plaintext); cipher.final(); const tag = cipher.getAuthTag(); return { ciphertext, tag }; } const encrypt = (enc, plaintext, cek, iv, aad) => { let key; if (isCryptoKey(cek)) { checkEncCryptoKey(cek, enc, 'encrypt'); key = KeyObject.from(cek); } else if (cek instanceof Uint8Array || isKeyObject(cek)) { key = cek; } else { throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array')); } checkCekLength(enc, key); checkIvLength(enc, iv); switch (enc) { case 'A128CBC-HS256': case 'A192CBC-HS384': case 'A256CBC-HS512': return cbcEncrypt(enc, plaintext, key, iv, aad); case 'A128GCM': case 'A192GCM': case 'A256GCM': return gcmEncrypt(enc, plaintext, key, iv, aad); default: throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm'); } }; export default encrypt;