nn::crypto Namespace

Description

The namespace of the encryption library.

Block Cipher API

Encryption using a block cipher has the following four stages, depending on the sophistication of the API.
If at all possible, use the first stage, wherein a single function performs all operations.

  1. A single function that carries out all operations

    It includes functions such as EncryptAes128Ctr, DecryptAes128Ctr, EncryptAndGenerateAes128Ccm, and DecryptAndVerifyAes128Ccm.
    Perform all processing required to encrypt by calling only this one function and specifying the encryption key, data to encrypt, and buffer to store the results.

  2. Batch processing using a combination of a block cipher and a cipher mode

    This uses an instance of a class derived from BlockCipher and one of the following functions.

    You cannot use instances of these classes. You can use any combination of block cipher and cipher mode. Enter all required parameters and run as a batch. Consequently, all targeted data must be loaded into memory.

  3. Stream processing using a combination of a block cipher and a cipher mode

    Uses instances of a class derived from BlockCipher, and a class derived from CipherMode. You can use any combination of block cipher and cipher mode. You can process a little at a time this way, allowing you to process a large volume of data using a smaller buffer to load and process the data.

  4. Directly using the block cipher

    Uses only an instance of a class derived from BlockCipher.
    Do not use this method unless you know enough about encryption, and have a firm understanding of what you are doing.

Classes

Block Cipher (Concrete Class)
nn::crypto::Aes Class for implementing AES ciphers.
nn::crypto::CcmDecryptor Class for decrypting and verifying in CCM mode.
nn::crypto::CcmEncryptor Class for encrypting and generating an MAC in CCM mode.
nn::crypto::CtrDecryptor Class for decrypting in CTR mode.
nn::crypto::CtrEncryptor Class for encrypting in CTR mode.
Block Cipher (Abstract Class)
nn::crypto::AuthenticatedDecryptor Base class for classes that decrypt ciphertexts with MAC and verify them.
nn::crypto::AuthenticatedEncryptor Base class for classes that encrypt with MAC.
nn::crypto::BlockCipher Base class for classes that implement block ciphers.
nn::crypto::CipherMode Base class for the cipher mode classes.
nn::crypto::Decryptor Base class for classes performing decryption using a cipher mode.
nn::crypto::Encryptor Base class for classes that perform encryption using a cipher mode.
Hash
nn::crypto::HashContextBase Base class for context objects used for hash calculation.
nn::crypto::Sha1Context Context object for SHA-1 calculation.
nn::crypto::Sha256Context Context object for SHA-256 calculation.
nn::crypto::ShaBlock512BitContext Context object for SHA calculation with a BlockSize of 512 bits.
RSA
nn::crypto::RsaContext The context class for RSA public key encryption.
nn::crypto::RsaKey The RSA key class.

typedef Definitions

Aes128 Class for AES encryption with a key length of 128 bits.
Aes192 Class for AES encryption with a key length of 192 bits.
Aes256 Class for AES encryption with a key length of 256 bits.
CtrDecryptor128 CtrDecryptor class for a block size of 128 bits.
CtrEncryptor128 CtrEncryptor class for a block size of 128 bits.

Constants

ENCRYPT_HEADER_SIZE const size_t Amount by which data size increases when encrypted using the EncryptAes128Ctr function.
GENERATE_HEADER_SIZE const size_t Amount by which data size increases when encrypted using the EncryptAndGenerateAes128Ccm function.

Functions

EncryptAes128Ctr Encrypts.
DecryptAes128Ctr Decrypts.
EncryptAndGenerateAes128Ccm Encrypts and generates data for tampering tests.
DecryptAndVerifyAes128Ccm Decrypts and tests for tampering.
GenerateRandomBytes Generates a pseudo-random number.
CalculateHmacSha1 Performs HMAC-SHA1 calculation.
CalculateHmacSha256 Performs HMAC-SHA256 calculation.
CalculateSha1 Utility function that encompasses a sequence of operations used for SHA-1 calculation.
CalculateSha256 Utility function that encompasses a sequence of operations used for SHA-256 calculation.

Revision History

2011/10/27
Added explanation of the block cipher API.
2010/01/07
Initial version.

CONFIDENTIAL