From fc023038424f3de81d7dd66c68634024a5b29eed Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 9 Aug 2024 12:58:20 +0200 Subject: 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 --- ext/node/ops/crypto/cipher.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ext/node/ops/crypto/cipher.rs') 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 { -- cgit v1.2.3