10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::crypto::win::cng::WinCNGCiphers Class Reference

#include <WinCNGCiphers.h>

Detailed Description

Windows CNG implementation of tenduke::crypto::Ciphers.

Provides symmetric encryption and decryption using AES-256-GCM via Windows CNG (Cryptography Next Generation). Generates 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)]

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

Protected Member Functions

std::unique_ptr< tenduke::utl::BinaryDatadecryptBytes (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::BinaryDataencryptBytes (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::BinaryDatadecrypt (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
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

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

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

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).

Member Function Documentation

◆ decryptBytes()

std::unique_ptr<::BinaryData > tenduke::crypto::win::cng::WinCNGCiphers::decryptBytes ( const unsigned char * ciphertext,
std::size_t ciphertextLength,
const unsigned char * encryptionKey,
std::size_t encryptionKeyLength ) const
overrideprotectedvirtual

Decrypts the data.Implementations will implement this method.

Implements tenduke::crypto::AbstractCiphers.

◆ encryptBytes()

std::unique_ptr<::BinaryData > tenduke::crypto::win::cng::WinCNGCiphers::encryptBytes ( const unsigned char * plaintext,
std::size_t plaintextLength,
const unsigned char * encryptionKey,
std::size_t encryptionKeyLength ) const
overrideprotectedvirtual

Encrypts the data.Implementations will implement this method.

Implements tenduke::crypto::AbstractCiphers.


The documentation for this class was generated from the following files:
  • core/services/windows/src/crypto/WinCNGCiphers.h
  • core/services/windows/src/crypto/WinCNGCiphers.cpp