diff options
author | Luca Casonato <hello@lcas.dev> | 2024-08-09 12:58:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-09 12:58:20 +0200 |
commit | fc023038424f3de81d7dd66c68634024a5b29eed (patch) | |
tree | 24cf26fd44306c35bb898d017fc342bce0d319dc /ext/node/polyfills/internal/crypto/cipher.ts | |
parent | c9f626e2512d52fdc354e490b179eed7200b394b (diff) |
fix(ext/node): ed25519 signing and cipheriv autopadding fixes (#24957)
- Return auth tag for GCM ciphers from auto padding shortcircuit
- Use _ring_ for ed25519 signing
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'ext/node/polyfills/internal/crypto/cipher.ts')
-rw-r--r-- | ext/node/polyfills/internal/crypto/cipher.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/crypto/cipher.ts b/ext/node/polyfills/internal/crypto/cipher.ts index 0a0a1ca06..2141edc76 100644 --- a/ext/node/polyfills/internal/crypto/cipher.ts +++ b/ext/node/polyfills/internal/crypto/cipher.ts @@ -12,6 +12,7 @@ import { op_node_cipheriv_encrypt, op_node_cipheriv_final, op_node_cipheriv_set_aad, + op_node_cipheriv_take, op_node_create_cipheriv, op_node_create_decipheriv, op_node_decipheriv_decrypt, @@ -194,7 +195,11 @@ export class Cipheriv extends Transform implements Cipher { final(encoding: string = getDefaultEncoding()): Buffer | string { const buf = new Buffer(16); - + if (this.#cache.cache.byteLength == 0) { + const maybeTag = op_node_cipheriv_take(this.#context); + if (maybeTag) this.#authTag = Buffer.from(maybeTag); + return encoding === "buffer" ? Buffer.from([]) : ""; + } if (!this.#autoPadding && this.#cache.cache.byteLength != 16) { throw new Error("Invalid final block size"); } |