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/ops/crypto/cipher.rs | |
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/ops/crypto/cipher.rs')
-rw-r--r-- | ext/node/ops/crypto/cipher.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/node/ops/crypto/cipher.rs b/ext/node/ops/crypto/cipher.rs index 0c1218d31..ca13fdcd8 100644 --- a/ext/node/ops/crypto/cipher.rs +++ b/ext/node/ops/crypto/cipher.rs @@ -64,6 +64,10 @@ impl CipherContext { self.cipher.borrow_mut().encrypt(input, output); } + pub fn take_tag(self) -> Tag { + Rc::try_unwrap(self.cipher).ok()?.into_inner().take_tag() + } + pub fn r#final( self, auto_pad: bool, @@ -290,6 +294,15 @@ impl Cipher { } } } + + fn take_tag(self) -> Tag { + use Cipher::*; + match self { + Aes128Gcm(cipher) => Some(cipher.finish().to_vec()), + Aes256Gcm(cipher) => Some(cipher.finish().to_vec()), + _ => None, + } + } } impl Decipher { |