10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::crypto::Ciphers Class Referenceabstract

#include <Ciphers.h>

Detailed Description

A "service locator" for cipher-related operations.

This class consolidates cipher-related operations into a single interface. It provides methods for encrypting and decrypting data using the system default cipher (AES256 GCM).

Inheritance diagram for tenduke::crypto::Ciphers:
tenduke::crypto::AbstractCiphers tenduke::crypto::libcrypto::LibcryptoCiphers tenduke::crypto::win::cng::WinCNGCiphers

Public Member Functions

virtual std::unique_ptr<::tenduke::utl::BinaryDatadecrypt (const ::tenduke::utl::DataSpan &ciphertext, const ::tenduke::utl::DataSpan &encryptionKey) const =0
 Decrypts given data using the system default cipher (AES256 GCM).
virtual std::string decryptString (const ::tenduke::utl::DataSpan &ciphertext, const ::tenduke::utl::DataSpan &encryptionKey) const =0
 Decrypts given data using the system default cipher (AES256 GCM) to a string.
virtual std::unique_ptr<::tenduke::utl::BinaryDataencrypt (const ::tenduke::utl::DataSpan &plaintext, const ::tenduke::utl::DataSpan &encryptionKey) const =0
 Encrypts given data using the system default cipher (AES256 GCM).
virtual std::unique_ptr<::tenduke::utl::BinaryDataencrypt (const std::string &plaintext, const ::tenduke::utl::DataSpan &encryptionKey) const =0
 Encrypts given data using the system default cipher (AES256 GCM).

Member Function Documentation

◆ decrypt()

virtual std::unique_ptr<::tenduke::utl::BinaryData > tenduke::crypto::Ciphers::decrypt ( const ::tenduke::utl::DataSpan & ciphertext,
const ::tenduke::utl::DataSpan & encryptionKey ) const
pure virtual

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
ciphertextthe cipher text (the data to decrypt), the maximum supported length is INT_MAX.
encryptionKeyencryption key
Returns
plain text (decrypted data)

Implemented in tenduke::crypto::AbstractCiphers.

◆ decryptString()

virtual std::string tenduke::crypto::Ciphers::decryptString ( const ::tenduke::utl::DataSpan & ciphertext,
const ::tenduke::utl::DataSpan & encryptionKey ) const
pure virtual

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
ciphertextthe cipher text (the data to decrypt), the maximum supported length is INT_MAX.
encryptionKeyencryption key
Returns
plain text (decrypted data) as std::string. Good for decrypting a string but also works for binary data

Implemented in tenduke::crypto::AbstractCiphers.

◆ encrypt() [1/2]

virtual std::unique_ptr<::tenduke::utl::BinaryData > tenduke::crypto::Ciphers::encrypt ( const ::tenduke::utl::DataSpan & plaintext,
const ::tenduke::utl::DataSpan & encryptionKey ) const
pure virtual

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
plaintextthe plain text (the data to encrypt), the maximum supported length is INT_MAX.
encryptionKeyencryption key
Returns
cipher text (encrypted data)

Implemented in tenduke::crypto::AbstractCiphers.

◆ encrypt() [2/2]

virtual std::unique_ptr<::tenduke::utl::BinaryData > tenduke::crypto::Ciphers::encrypt ( const std::string & plaintext,
const ::tenduke::utl::DataSpan & encryptionKey ) const
pure virtual

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
plaintextthe plain text, the maximum supported length is INT_MAX.
encryptionKeyencryption key
Returns
cipher text (encrypted data)

Implemented in tenduke::crypto::AbstractCiphers.


The documentation for this class was generated from the following file: