const_valueClass

Template class for securely storing a constant value with structural randomization. More...

Public Functions

TypeName
constexprconst_value (const T &v)
constexproperator T () const

Private Properties

TypeName
Tvalue_

Detailed Description

The const_value class is designed to securely store a constant value of any type T . The primary purpose of this class is to provide an additional layer of security by making it harder to predict or manipulate the stored value through common attack vectors, such as memory inspection or tampering. This is achieved by randomizing the layout of the structure in memory, which obfuscates the location and accessibility of the stored value.

Template Parameters

  • T: The type of the value to be stored. This can be any primitive type or a custom type.

Public Functions

constexpr const_value (const T &v)

Constructs a const_value object with a given value.

Definition

constexpr libantispy::const_value< T >::const_value

Detailed Description

This constructor initializes the const_value object with the provided value v . The value is securely stored within the object, and the structure layout is randomized to make it less predictable in memory. This constructor can be used to initialize the object with a specific constant value that needs to be protected.

Parameters

  • v: The value to be securely stored within the const_value object. The type of v is determined by the template parameter T .

constexpr operator T () const

Conversion operator to the underlying type T .

Definition

constexpr libantispy::const_value< T >::operator T

Detailed Description

This operator allows the const_value object to be implicitly converted to the underlying type T . This means that wherever a T type value is expected, a const_value object can be used directly without needing to explicitly access its stored value. This provides a convenient way to retrieve the stored value while maintaining its security.

Returns

The securely stored value as type T .

Private Properties

T value_

Stores the constant value securely.

Definition

T libantispy::const_value< T >::value_

Detailed Description

This member variable holds the constant value of type T that is being protected. The value is intended to be immutable after the construction of the const_value object, ensuring that it remains constant throughout the object's lifetime. The security of this value is augmented by the structural randomization applied to the class.