aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_session.cpp
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/tls/tls_session.cpp
parent7df69ab04ba5f2944ac3135b444c3b103aaa3f80 (diff)
Add RAII versions of get_cipher_mode and get_aead
See also #1526
Diffstat (limited to 'src/lib/tls/tls_session.cpp')
-rw-r--r--src/lib/tls/tls_session.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/tls/tls_session.cpp b/src/lib/tls/tls_session.cpp
index f595101f2..85443949d 100644
--- a/src/lib/tls/tls_session.cpp
+++ b/src/lib/tls/tls_session.cpp
@@ -179,7 +179,7 @@ std::chrono::seconds Session::session_age() const
std::vector<uint8_t>
Session::encrypt(const SymmetricKey& key, RandomNumberGenerator& rng) const
{
- std::unique_ptr<AEAD_Mode> aead(get_aead("AES-256/GCM", ENCRYPTION));
+ std::unique_ptr<AEAD_Mode> aead = AEAD_Mode::create_or_throw("AES-256/GCM", ENCRYPTION);
const size_t nonce_len = aead->default_nonce_length();
const secure_vector<uint8_t> nonce = rng.random_vec(nonce_len);
@@ -202,7 +202,7 @@ Session Session::decrypt(const uint8_t in[], size_t in_len, const SymmetricKey&
{
try
{
- std::unique_ptr<AEAD_Mode> aead(get_aead("AES-256/GCM", DECRYPTION));
+ std::unique_ptr<AEAD_Mode> aead = AEAD_Mode::create_or_throw("AES-256/GCM", ENCRYPTION);
const size_t nonce_len = aead->default_nonce_length();
if(in_len < nonce_len + aead->tag_size())