mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
getCipherInfo(nameOrNid[, options]) runs in a new runtime unit, scr_cipher_info.c, over a table that scripts/gen-cipher-info.mjs generates from Node 24.22's getCipherInfo. The table covers every cipher OpenSSL names, including the ones without a native implementation. Lookups match names case-insensitively and accept OpenSSL's nids. The unit applies cipher.js's argument checks and GetCipherInfo's keyLength and ivLength rules, and returns the info object in Node's key order. CipherInfo maps to a checked-dynamic value, so TypeScript and JavaScript code receive Node's object. Reading the nid Node leaves out for the SIV and SM4 GCM, CCM and XTS ciphers, where the declared type gives number, throws a TypeError. createCipheriv and createDecipheriv support aes-128/192/256-ccm (and the id-aesN-ccm names) over OpenSSL's ccm128 steps. They follow Node's tag and IV lengths, the plaintextLength requirement, the message-length caps and the one-update rule, and report a failed authentication from final(). They also support the RFC 3394 and RFC 5649 key wrap ciphers (aes-N-wrap, aesN-wrap, id-aesN-wrap, the -pad forms and the -inv ciphers) over wrap128.c's routines, with Node's lengths, integrity failures and one-update rule. The new names follow the existing ones in the cipher table, so the lookup cost of the existing ciphers is unchanged.