10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
LibcryptoAESCipher.h
1#ifndef TENDUKE_CRYPTO_LIBCRYPTO_LIBCRYPTOAESCIPHER_H
2#define TENDUKE_CRYPTO_LIBCRYPTO_LIBCRYPTOAESCIPHER_H
3
4#include "crypto/symmetric/aes/AESGCMCipher.h"
5#include "utl/DataSink.h"
6
7#include <openssl/evp.h>
8
9namespace tenduke { namespace crypto { namespace aes { namespace libcrypto {
10
11class LibcryptoAESKey;
12
16class LibcryptoAESCipher : public ::tenduke::crypto::aes::AESGCMCipher
17{
18public:
19 explicit LibcryptoAESCipher(const ::tenduke::crypto::aes::libcrypto::LibcryptoAESKey &key);
20
21 // Ciphers are not copyable
22 LibcryptoAESCipher(const LibcryptoAESCipher&) = delete;
23 LibcryptoAESCipher& operator=(const LibcryptoAESCipher&) = delete;
24
25 // Ciphers are movable
26 LibcryptoAESCipher(LibcryptoAESCipher&& other) noexcept = default;
27 LibcryptoAESCipher& operator=(LibcryptoAESCipher&& other) noexcept = default;
28
29 // tenduke::crypto::Cipher implementation
30 void decryptData(const ::tenduke::utl::DataSpan &ciphertext, ::tenduke::utl::DataSink &plaintext) const override;
31 void encryptData(const ::tenduke::utl::DataSpan &plaintext, ::tenduke::utl::DataSink &ciphertext) const override;
32
33 // tenduke::crypto::aes::AESGCMCipher implementation
35 const ::tenduke::utl::DataSpan &nonce,
36 const ::tenduke::utl::DataSpan &plaintext,
37 ::tenduke::utl::DataSink &ciphertext
38 ) const override;
39
40private:
41 std::unique_ptr<::tenduke::utl::DataSpan> key;
42 const EVP_CIPHER *cipher;
43};
44
45}}}}
46
47#endif //TENDUKE_CRYPTO_LIBCRYPTO_LIBCRYPTOAESCIPHER_H
An AES-GCM cipher that supports encryption with an externally provided nonce.
Definition AESGCMCipher.h:17
void decryptData(const ::tenduke::utl::DataSpan &ciphertext, ::tenduke::utl::DataSink &plaintext) const override
Utility method to decrypt data.
Definition LibcryptoAESCipher.cpp:111
void encryptData(const ::tenduke::utl::DataSpan &nonce, const ::tenduke::utl::DataSpan &plaintext, ::tenduke::utl::DataSink &ciphertext) const override
Encrypts data using the provided nonce.
void encryptData(const ::tenduke::utl::DataSpan &plaintext, ::tenduke::utl::DataSink &ciphertext) const override
Utility method to encrypt data.
Libcrypto AES secret key implementation.
Definition LibcryptoAESKey.h:13
A sink to which binary data can be appended.
Definition DataSink.h:14
Cryptography services.
Definition AbstractCiphers.h:18
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4