|
10Duke Enterprise C++ SDK
|
#include <LibcryptoCiphers.h>
Libcrypto-implementation of tenduke::crypto::Ciphers.
Provides symmetric encryption and decryption using AES-256-GCM. Generates a random IV and prepends it to the ciphertext. Uses PBKDF2 with SHA-256 for key derivation. Output format: [magic (4 bytes)] [version (2 bytes)] [IV (12 bytes)] [ciphertext] [authentication tag (16 bytes)]
Protected Member Functions | |
| std::unique_ptr< tenduke::utl::BinaryData > | decryptBytes (const unsigned char *ciphertext, std::size_t ciphertextLength, const unsigned char *encryptionKey, std::size_t encryptionKeyLength) const override |
| Decrypts the data.Implementations will implement this method. | |
| std::unique_ptr< tenduke::utl::BinaryData > | encryptBytes (const unsigned char *plaintext, std::size_t plaintextLength, const unsigned char *encryptionKey, std::size_t encryptionKeyLength) const override |
| Encrypts the data.Implementations will implement this method. | |
| Protected Member Functions inherited from tenduke::crypto::AbstractCiphers | |
| 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. | |
Additional Inherited Members | |||||
| Public Member Functions inherited from tenduke::crypto::AbstractCiphers | |||||
| 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.
| |||||
| 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.
| |||||
| 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.
| |||||
| Static Protected Attributes inherited from tenduke::crypto::AbstractCiphers | |||||
| static constexpr std::uint32_t | BLOB_MAGIC = 0x44554B45 | ||||
| Magic value for encrypted blob header. | |||||
| static constexpr std::size_t | BLOB_HEADER_SIZE = 6 | ||||
| Header size: magic (4 bytes) + version (2 bytes). | |||||
|
overrideprotectedvirtual |
Decrypts the data.Implementations will implement this method.
Implements tenduke::crypto::AbstractCiphers.
|
overrideprotectedvirtual |
Encrypts the data.Implementations will implement this method.
Implements tenduke::crypto::AbstractCiphers.