|
10Duke Enterprise C++ SDK
|
#include <AESGCMCipher.h>
An AES-GCM cipher that supports encryption with an externally provided nonce.
Extends AESCipher with the ability to supply the nonce (IV) explicitly. This is needed in key-derivation schemes where the same random value serves as both the PBKDF2 salt and the AES-GCM nonce.
Public Member Functions | |
| virtual void | encryptData (const ::tenduke::utl::DataSpan &nonce, const ::tenduke::utl::DataSpan &plaintext, ::tenduke::utl::DataSink &ciphertext) const=0 |
| Encrypts data using the provided nonce. | |
| virtual void | encryptData (const ::tenduke::utl::DataSpan &plaintext, ::tenduke::utl::DataSink &ciphertext) const =0 |
| Utility method to encrypt data. | |
| Public Member Functions inherited from tenduke::crypto::aes::AESCipher | |
| AESCipher (const AESCipher &)=delete | |
| AESCipher & | operator= (const AESCipher &)=delete |
| AESCipher (AESCipher &&other) noexcept=default | |
| AESCipher & | operator= (AESCipher &&other) noexcept=default |
| Public Member Functions inherited from tenduke::crypto::Cipher | |
| Cipher (const Cipher &)=delete | |
| Cipher & | operator= (const Cipher &)=delete |
| Cipher (Cipher &&other) noexcept=default | |
| Cipher & | operator= (Cipher &&other) noexcept=default |
| virtual void | decryptData (const ::tenduke::utl::DataSpan &ciphertext, ::tenduke::utl::DataSink &plaintext) const =0 |
| Utility method to decrypt data. | |
|
pure virtual |
Encrypts data using the provided nonce.
Writes [nonce][ciphertext][authentication tag] to ciphertext.
WARNING: A (key, nonce) pair must never be used more than once. Reusing a nonce with the same key reveals the XOR of the plaintexts and allows forging authentication tags. Prefer encryptData(plaintext, ciphertext), which generates a random nonce, unless the nonce is itself a fresh random value (for example a salt that is also used for key derivation).
| nonce | the nonce (IV) to use; must be exactly GCM_NONCE_SIZE bytes |
| plaintext | data to encrypt |
| ciphertext | sink that receives the output |
| tenduke::crypto::CryptoException | if the nonce is not GCM_NONCE_SIZE bytes |
|
virtual |
Utility method to encrypt data.
This method encrypts the provided data and outputs a binary data object which contains:
| plaintext | the data to encrypt |
| ciphertext | the encrypted data |
Implements tenduke::crypto::Cipher.