# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MLA -- Crypto Library

1 January, 2012

- 1
- 2
…
- 73
- 74
- 75
- 76
- 77
…
- 119
- 120

//keyStream could also be allocated memory instead of fixed memory
uint8_t keyStream[AES_BLOCK_SIZE*4];
// The encryption key
static uint8_t AESKey128[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7,
0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
// Structure to contain the created AES round keys
AES_ROUND_KEYS_128_BIT round_keys;
sysObject = DRV_AES_Initialize (DRV_AES_INDEX, NULL);
if (sysObject != SYS_MODULE_OBJ_STATIC)
{
// error
}
handle = DRV_AES_Open (DRV_AES_INDEX, 0);
if (handle != DRV_AES_HANDLE)
{
// error
}
//Create the AES round keys. This only needs to be done once for each AES key.
AES_RoundKeysCreate (&round_keys, (uint8_t*)AESKey128, AES_KEY_SIZE_128_BIT);
// Initialize the Block Cipher context
BLOCK_CIPHER_GCM_Initialize (handle, &context, AES_Encrypt, AES_Decrypt, AES_BLOCK_SIZE,
(uint8_t *)ivValue, 12, (void *)&keyStream, sizeof(keyStream), &round_keys);
Parameters
Parameters Description
handle A handle that is passed to the block cipher's encrypt/decrypt
functions to specify which instance of the block cipher
module to use. This parameter can be specified as NULL if
the block cipher does not have multiple instances.
context The GCM context to initialize.
encryptFunction Pointer to the encryption function for the block cipher
algorithm being used in GCM mode.
decryptFunction Pointer to the decryption function for the block cipher
algorithm being used in GCM mode.
blockSize The block size of the block cipher algorithm being used in
GCM mode.
initializationVector A security nonce. See the GCM specification, section 8.2 for
information about constructing initialization vectors.
initializationVectorLen Length of the initialization vector, in bytes
keyStream Pointer to a buffer to contain a calculated keyStream.
keyStreamSize The size of the keystream buffer, in bytes.
key The key to use when encrypting/decrypting the data. The
format of this key will depend on the block cipher you are
using. The key is used by the Initialize function to calculate
the hash subkey.
Function
void BLOCK_CIPHER_GCM_Initialize ( BLOCK_CIPHER_GCM_CONTEXT * context,
BLOCK_CIPHER_FunctionEncrypt encryptFunction,
BLOCK_CIPHER_FunctionDecrypt decryptFunction, uint32_t blockSize,
uint8_t * initializationVector, void * keyStream, uint32_t keyStreamSize)
1.7.1.7.3 BLOCK_CIPHER_GCM_KeyStreamGenerate Function
Generates a key stream for use with the Galois/counter mode.
1.7 Library Interface MLA - Crypto Library Help Block Cipher Modes
75

- 1
- 2
…
- 73
- 74
- 75
- 76
- 77
…
- 119
- 120