diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-24 04:15:26 +0100 |
| commit | ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 (patch) | |
| tree | c55e4b85ee30138ce83263045d77d01631378b2e /src/crypto_context.h | |
| parent | 6c37cc1979b2a01205a888c4c98f3334685ee8dd (diff) | |
Tidying.
Diffstat (limited to 'src/crypto_context.h')
| -rw-r--r-- | src/crypto_context.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/crypto_context.h b/src/crypto_context.h index 263121bf..6020ea88 100644 --- a/src/crypto_context.h +++ b/src/crypto_context.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,9 +31,16 @@ files in the program, then also delete it here. */ + +/** @file src/crypto_context.h + * @class CryptoContext class + */ + + #ifndef LIBDCP_CRYPTO_CONTEXT_H #define LIBDCP_CRYPTO_CONTEXT_H + #include "key.h" #include "types.h" #include "exceptions.h" @@ -41,22 +48,24 @@ #include <asdcp/KM_prng.h> #include <boost/optional.hpp> + namespace dcp { + template <class T> class CryptoContext { public: CryptoContext (boost::optional<Key> key, Standard standard) - : _context (0) - , _hmac (0) + : _context (nullptr) + , _hmac (nullptr) { if (!key) { return; } - _context = new T; - if (ASDCP_FAILURE (_context->InitKey (key->value ()))) { + _context = new T (); + if (ASDCP_FAILURE (_context->InitKey(key->value()))) { throw MiscError ("could not set up crypto context"); } @@ -76,7 +85,7 @@ public: type = ASDCP::LS_MXF_SMPTE; } - if (ASDCP_FAILURE (_hmac->InitKey (key->value(), type))) { + if (ASDCP_FAILURE (_hmac->InitKey(key->value(), type))) { throw MiscError ("could not set up HMAC context"); } } @@ -100,9 +109,12 @@ private: ASDCP::HMACContext* _hmac; }; + typedef CryptoContext<ASDCP::AESEncContext> EncryptionContext; typedef CryptoContext<ASDCP::AESDecContext> DecryptionContext; + } + #endif |
