summaryrefslogtreecommitdiff
path: root/ext/node/ops/crypto/cipher.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/ops/crypto/cipher.rs')
-rw-r--r--ext/node/ops/crypto/cipher.rs13
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 {