Encrypt

nn::crypto::CtrEncryptor::Encrypt Member Function

Syntax

static size_t Encrypt(
     void * pDst,
     size_t dstSize,
     const void * pSrc,
     size_t srcSize,
     const void * pIv,
     size_t ivSize,
     const BlockCipher & c
);

Parameters

Name Description
out pDst Pointer to the buffer storing the encryption results.
in dstSize Size of the buffer pointed to by pDst.
in pSrc Pointer to the buffer storing the plaintext.
in srcSize Plaintext size in bytes.
in pIv Pointer to the buffer storing the IV.
in ivSize IV size in bytes.
in c Instance of the block encryption implementation used in encryption.

Return Values

Returns the number of bytes written to pDst.

Description

Handles batch encryption when in CTR mode.

When all data is loaded into memory, you can call this function to encrypt all of the data at once.

For c, specify an instance of a class derived from the BlockCipher class that implements the block cipher used in encryption. You must have previously used the BlockCipher::SetKey function to set the key used in encryption.

The function fails and displays an error if the size of the return value is larger than the buffer size specified in dstSize. Data is not written to the buffer beyond the size specified in dstSize. If the size of the return value is not larger than dstSize, the function indicates a successful completion and writes the size of the return value in pDst.

If this function fails, encryption cannot continue. You must then try again, starting by calling the Initialize function.

Revision History

2011/10/27
Initial version.

CONFIDENTIAL