Commit Graph
3 Commits
Author SHA1 Message Date
Chris Tate 982ebac139 Accept typed-ref arguments in createCipheriv and the cipher methods
createCipheriv, createDecipheriv, update(), setAAD() and setAuthTag()
now read the value a typed-ref box holds when it is a string, view,
ArrayBuffer or KeyObject. ERR_INVALID_ARG_TYPE names the class of a
class instance that arrives through an untyped value, as Node does,
instead of Object. An unknown output encoding that is not a string is
rendered as Node's %s formats it (util.inspect at depth 0, or the
object's own toString); a function, or an instance of a class that
defines toString, throws a coded SC2020 error. Cipher programs link the
inspect unit for that rendering.

5250 passes each argument through `any`, including class instances,
records and arrays that Node rejects, and 5254 covers output encodings
that are not strings from JavaScript.
2026-10-15 18:47:02 -05:00
Chris Tate 5336966743 Merge main into createCipheriv support
Keeps the cipher support together with the hash, random and
timingSafeEqual surface added on main.
2026-10-15 02:22:02 -05:00
Chris Tate 10539c9c42 Fail closed on cipher backend errors and on missing chacha20-poly1305 tags
- Every mbedTLS call in the cipher runtime is checked. A failed update(),
  final() or setAAD() returns no output and retires the context, so later
  calls throw and no tag is returned or accepted. An update past the
  AES-GCM limit of 2^36 - 32 bytes per message throws Node's "Trying to
  add data in unsupported state" error; it used to return zeroed output
  and leave the tag covering only the earlier data.
- chacha20-poly1305 decryption without setAuthTag() fails in final()
  again. Node 24.22 skips the tag check when authTagLength is not passed
  either and returns unverified plaintext; limitations.mdx records the
  difference.
- A runtime unit test moves contexts next to the GCM message and AAD
  limits and checks that the failure is permanent; errors.test.ts covers
  decryption without a tag.
2026-10-15 00:06:26 -05:00