Abstract base class for cipher implementations.
This class provides default implementations for convenience methods that delegate to the pure virtual methods defined in the Ciphers interface.
Subclasses must implement the pure virtual methods.
|
| std::unique_ptr<::tenduke::utl::BinaryData > | decrypt (const ::tenduke::utl::DataSpan &ciphertext, const ::tenduke::utl::DataSpan &encryptionKey) const override |
| | Decrypts given data using the system default cipher (AES256 GCM).
|
| std::string | decryptString (const ::tenduke::utl::DataSpan &ciphertext, const ::tenduke::utl::DataSpan &encryptionKey) const override |
| | Decrypts given data using the system default cipher (AES256 GCM) to a string.This method expects the input to consist of magic (4 bytes) + version (2 bytes) + IV (12 bytes) + ciphertext + tag (16 bytes), i.e., the output produced by calling ::encrypt(key, plaintext).This is "syntactic sugar": The method also performs key-derivation for the provided key to simplify the use.- Parameters
-
| ciphertext | the cipher text (the data to decrypt), the maximum supported length is INT_MAX. |
| encryptionKey | encryption key |
- Returns
- plain text (decrypted data) as std::string. Good for decrypting a string but also works for binary data
|
| std::unique_ptr<::tenduke::utl::BinaryData > | encrypt (const ::tenduke::utl::DataSpan &plaintext, const ::tenduke::utl::DataSpan &encryptionKey) const override |
| | Encrypts given data using the system default cipher (AES256 GCM).The output consists of magic (4 bytes) + version (2 bytes) + IV (12 bytes) + ciphertext + tag (16 bytes).This is "syntactic sugar": The method also performs key-derivation for the provided key to simplify the use. The method also generates a random IV.- Parameters
-
| plaintext | the plain text (the data to encrypt), the maximum supported length is INT_MAX. |
| encryptionKey | encryption key |
- Returns
- cipher text (encrypted data)
|
| std::unique_ptr<::tenduke::utl::BinaryData > | encrypt (const std::string &plaintext, const ::tenduke::utl::DataSpan &encryptionKey) const override |
| | Encrypts given data using the system default cipher (AES256 GCM).The output consists of magic (4 bytes) + version (2 bytes) + IV (12 bytes) + ciphertext + tag (16 bytes).This is "syntactic sugar": The method also performs key-derivation for the provided key to simplify the use. The method also generates a random IV.- Parameters
-
| plaintext | the plain text, the maximum supported length is INT_MAX. |
| encryptionKey | encryption key |
- Returns
- cipher text (encrypted data)
|
|
| virtual std::unique_ptr<::tenduke::utl::BinaryData > | decryptBytes (const unsigned char *ciphertext, std::size_t ciphertextLength, const unsigned char *encryptionKey, std::size_t encryptionKeyLength) const =0 |
| | Decrypts the data.
|
| virtual std::unique_ptr<::tenduke::utl::BinaryData > | encryptBytes (const unsigned char *plaintext, std::size_t plaintextLength, const unsigned char *encryptionKey, std::size_t encryptionKeyLength) const =0 |
| | Encrypts the data.
|
| virtual void | writeHeader (unsigned char *buffer, std::uint16_t version) const |
| | Writes the blob header (magic and version) in network byte order.
|
| virtual std::uint16_t | readAndValidateHeader (const unsigned char *buffer, std::size_t bufferLength) const |
| | Reads and validates the blob header.
|
Decrypts given data using the system default cipher (AES256 GCM).
This method expects the input to consist of magic (4 bytes) + version (2 bytes) + IV (12 bytes) + ciphertext + tag (16 bytes), i.e., the output produced by calling ::encrypt(key, plaintext).
This is "syntactic sugar": The method also performs key-derivation for the provided key to simplify the use.
- Parameters
-
| ciphertext | the cipher text (the data to decrypt), the maximum supported length is INT_MAX. |
| encryptionKey | encryption key |
- Returns
- plain text (decrypted data)
Implements tenduke::crypto::Ciphers.