aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/misc/cryptobox
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-07 13:34:52 -0400
committerJack Lloyd <[email protected]>2018-04-07 13:34:52 -0400
commit3657639abf776e78b35a961d646dd410a7fce492 (patch)
treecf969470c7299941f420ac1fc3cde1ba39ab7eb7 /src/lib/misc/cryptobox
parent7df69ab04ba5f2944ac3135b444c3b103aaa3f80 (diff)
Add RAII versions of get_cipher_mode and get_aead
See also #1526
Diffstat (limited to 'src/lib/misc/cryptobox')
-rw-r--r--src/lib/misc/cryptobox/cryptobox.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp
index 5d2364871..452d95308 100644
--- a/src/lib/misc/cryptobox/cryptobox.cpp
+++ b/src/lib/misc/cryptobox/cryptobox.cpp
@@ -76,7 +76,7 @@ std::string encrypt(const uint8_t input[], size_t input_len,
const uint8_t* iv = mk + CIPHER_KEY_LEN + MAC_KEY_LEN;
// Now encrypt and authenticate
- std::unique_ptr<Cipher_Mode> ctr(get_cipher_mode("Serpent/CTR-BE", ENCRYPTION));
+ std::unique_ptr<Cipher_Mode> ctr = Cipher_Mode::create_or_throw("Serpent/CTR-BE", ENCRYPTION);
ctr->set_key(cipher_key, CIPHER_KEY_LEN);
ctr->start(iv, CIPHER_IV_LEN);
ctr->finish(out_buf, CRYPTOBOX_HEADER_LEN);
@@ -142,7 +142,7 @@ decrypt_bin(const uint8_t input[], size_t input_len,
if(!constant_time_compare(computed_mac.data(), box_mac, MAC_OUTPUT_LEN))
throw Decoding_Error("CryptoBox integrity failure");
- std::unique_ptr<Cipher_Mode> ctr(get_cipher_mode("Serpent/CTR-BE", DECRYPTION));
+ std::unique_ptr<Cipher_Mode> ctr(Cipher_Mode::create_or_throw("Serpent/CTR-BE", DECRYPTION));
ctr->set_key(cipher_key, CIPHER_KEY_LEN);
ctr->start(iv, CIPHER_IV_LEN);
ctr->finish(ciphertext, CRYPTOBOX_HEADER_LEN);