Open Search
    AES Class Reference

    #include <lib_aes.h>

    Detailed Description

    An Advanced Encryption Standard (also known as Rijndael) class to encrypt/decrypt data.

    Note
    Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

    Private Member Functions

     AES ()
     
     ~AES ()
     

    Alloc/Free

    static AESAlloc ()
     
    static void Free (AES *&pAES)
     

    Calculate Data Size

    static Int CalcEncryptedDataSize (Int32 lBlockLength, Int lDataLength)
     

    Init

    Bool Init (Int32 lBlockLength, Int32 lKeyLength)
     

    Encrypt/Decrypt

    Bool Encrypt (void *pData, Int lDataLength, const void *pKey)
     
    Bool Decrypt (void *pData, Int lDataLength, const void *pKey)
     

    Progress Callback

    void SetProgressCallback (PFNRIJINDAEL_CIPHER_PROGRESS fn, void *pData)
     

    Constructor & Destructor Documentation

    ◆ AES()

    AES ( )
    private

    ◆ ~AES()

    ~AES ( )
    private

    Member Function Documentation

    ◆ Alloc()

    static AES* Alloc ( )
    static

    Allocates an AES cipher. Destroy the allocated AES cipher with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

    Returns
    The allocated AES cipher, or nullptr if the allocation failed.

    ◆ Free()

    static void Free ( AES *&  pAES)
    static

    Destructs AES ciphers allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

    Parameters
    [in,out]pAESThe AES cipher to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

    ◆ Init()

    Bool Init ( Int32  lBlockLength,
    Int32  lKeyLength 
    )

    Initializes the AES cipher to the given block length and key length.

    Parameters
    [in]lBlockLengthThe block length. Must be 128, 192 or 256 (bit).
    [in]lKeyLengthThe key length. Must be 128, 192 or 256 (bit).
    Returns
    true if initialization was successful, otherwise false.

    ◆ CalcEncryptedDataSize()

    static Int CalcEncryptedDataSize ( Int32  lBlockLength,
    Int  lDataLength 
    )
    static

    Calculates the size of the data block (data size + encryption overhead).

    Parameters
    [in]lBlockLengthThe block length in bits.
    [in]lDataLengthThe size of the data in bytes.
    Returns
    The size of the data block in bytes.

    ◆ Encrypt()

    Bool Encrypt ( void *  pData,
    Int  lDataLength,
    const void *  pKey 
    )

    Encrypts a data block.

    Parameters
    [in,out]pDataThe data block to encrypt.
    [in]lDataLengthThe size of the data block. Usually retrieved with CalcEncryptedDataSize().
    [in]pKeyThe encryption key.
    Returns
    true if encryption was successful, otherwise false.

    ◆ Decrypt()

    Bool Decrypt ( void *  pData,
    Int  lDataLength,
    const void *  pKey 
    )

    Decrypts a data block.

    Parameters
    [in,out]pDataThe encrypted data block.
    [in]lDataLengthThe size of the data block.
    [in]pKeyThe decryption key.
    Returns
    true if decryption was successful, otherwise false.

    ◆ SetProgressCallback()

    void SetProgressCallback ( PFNRIJINDAEL_CIPHER_PROGRESS  fn,
    void *  pData 
    )

    Sets the encryption/decryption progress hook.

    Note
    For future use, does nothing, currently.
    Parameters
    [in]fnThe progress hook.
    [in]pDataThe data pointer passed to the hook.