const_bufferClass

Template class for securely storing and managing encrypted buffers. More...

Public Functions

TypeName
constexprconst_buffer (const char *str) noexcept
const const_array< char, N > *raw_data () const noexcept
size_tget_hash () const
voidinitialize () const

Private Properties

TypeName
const_array< char, N >data_

Detailed Description

The const_buffer class template provides a mechanism for encrypting and securely storing a fixed-size buffer of characters. This class is particularly useful in scenarios where sensitive strings or data need to be protected from tampering or inspection. The stored buffer is encrypted using a provided key and can be decrypted when needed, either as a raw pointer to the encrypted data or as a std::string when converted.

The encryption process is designed to be highly secure, leveraging a combination of compile-time and runtime obfuscation techniques. Additionally, the class supports generating a hash of the buffer, which can be used for integrity checks or to uniquely identify the buffer content.

Template Parameters

  • Key: The encryption key used to encrypt the buffer. This is a compile-time constant.

  • Hash: A compile-time constant representing the hash of the buffer, used for identification or integrity checks.

  • N: The size of the buffer (number of characters in the buffer).

Public Functions

constexpr const_buffer (const char *str) noexcept

Constructs a const_buffer object from a source buffer.

Definition

constexpr libantispy::const_buffer< Key, Hash, N >::const_buffer

Detailed Description

This constructor encrypts the given source buffer using the specified key and identifier, and stores the encrypted buffer within the const_buffer object. The encryption process is carried out at compile-time, ensuring that the original content is never exposed in plain text.

Parameters

  • str: The source buffer to be encrypted. It is expected to be a null-terminated C-string with a length of N characters or fewer.

const const_array< char, N > * raw_data () const noexcept

Returns a pointer to the raw data of the encrypted buffer.

Definition

const const_array< char, N > * libantispy::const_buffer< Key, Hash, N >::raw_data

Detailed Description

This method returns a pointer to the encrypted buffer stored within the const_buffer object. This pointer provides access to the encrypted data in its raw form, which can be useful for low-level operations or for passing the data to functions that require direct memory access.

The returned pointer points to a const_array<char, N> , ensuring that the data remains immutable.

Returns

A pointer to the raw data of the encrypted buffer.

size_t get_hash () const

Returns the hash of the buffer.

Definition

size_t libantispy::const_buffer< Key, Hash, N >::get_hash

Detailed Description

This method returns the compile-time hash value associated with the buffer. The hash value is a unique identifier for the content of the buffer and can be used for integrity checks, quick comparisons, or as a lookup key in hash-based data structures.

The hash is computed at compile-time and is stored as a constant within the const_buffer object.

Returns

The hash of the buffer.

void initialize () const

Initializes the const_buffer object.

Definition

void libantispy::const_buffer< Key, Hash, N >::initialize

Detailed Description

This method initializes the const_buffer object by invoking a function at the memory address where the encrypted data is stored. This is typically used to perform any necessary setup or preparation of the buffer data before it is accessed or processed.

Private Properties

const_array< char, N > data_

Stores the encrypted buffer data.

Definition

const_array<char, N> libantispy::const_buffer< Key, Hash, N >::data_

Detailed Description

The data_ member variable holds the encrypted version of the buffer. The encryption process is applied at compile-time, and the resulting encrypted data is stored in a const_array<char, N> . This ensures that the data remains immutable and secure.