WE310F5  39.00.000
M2MB CRYPTO AES

This section describes the M2MB APIs to perform various cryptographic operations. More...

INT32 m2mb_aes_256_cbc_decrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Decrypts input data for cipher AES, algorithm CBC and Key size 256. More...
 
INT32 m2mb_aes_256_cbc_encrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Encrypts input data for cipher AES, algorithm CBC and Key size 256. More...
 
INT32 m2mb_aes_128_cbc_decrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Decrypts input data for cipher AES, algorithm CBC and Key size 128. More...
 
INT32 m2mb_aes_128_cbc_encrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Encrypts input data for cipher AES, algorithm CBC and Key size 128. More...
 
INT32 m2mb_aes_128_ctr_decrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Decrypts input data for cipher AES, algorithm CTR and Key size 128. More...
 
INT32 m2mb_aes_128_ctr_encrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 encrypts input data for cipher AES, algorithm CTR and Key size 128 More...
 
INT32 m2mb_aes_256_ctr_decrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Decrypts input data for cipher AES, algorithm CTR and Key size 256. More...
 
INT32 m2mb_aes_256_ctr_encrypt (const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len)
 Encrypts input data for cipher AES, algorithm CTR and Key size 256. More...
 

Detailed Description

This section describes the M2MB APIs to perform various cryptographic operations.

Function Documentation

◆ m2mb_aes_128_cbc_decrypt()

INT32 m2mb_aes_128_cbc_decrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Decrypts input data for cipher AES, algorithm CBC and Key size 128.

Decrypts the input data and puts decrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing decrypted data
[in]data_lenlength of input data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_128_cbc_decrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_128_cbc_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
ret=m2mb_aes_128_cbc_decrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_128_cbc_encrypt()

INT32 m2mb_aes_128_cbc_encrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Encrypts input data for cipher AES, algorithm CBC and Key size 128.

Encrypts the input data and puts Encrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing encrypted data.
[in]data_lenlength of input data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_128_cbc_encrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_128_cbc_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_128_ctr_decrypt()

INT32 m2mb_aes_128_ctr_decrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Decrypts input data for cipher AES, algorithm CTR and Key size 128.

Decrypts the input data and puts decrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing decrypted data.
[in]data_lenlength of inout data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_128_ctr_decrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_128_ctr_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
ret=m2mb_aes_128_ctr_decrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_128_ctr_encrypt()

INT32 m2mb_aes_128_ctr_encrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

encrypts input data for cipher AES, algorithm CTR and Key size 128

encrypts the input data and puts encrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for encryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing encrypted/decrypted data.
[in]data_lenlength of inout data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_128_ctr_encrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_128_ctr_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_256_cbc_decrypt()

INT32 m2mb_aes_256_cbc_decrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Decrypts input data for cipher AES, algorithm CBC and Key size 256.

Decrypts the input data and puts decrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing decrypted data.
[in]data_lenlength of input data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_256_cbc_decrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
INT32 ret;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_256_cbc_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
ret=m2mb_aes_256_cbc_decrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_256_cbc_encrypt()

INT32 m2mb_aes_256_cbc_encrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Encrypts input data for cipher AES, algorithm CBC and Key size 256.

Encrypts the input data and puts encrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing encrypted data.
[in]data_lenlength of input data buffer
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_256_cbc_encrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
int32 ret;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_256_cbc_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_256_ctr_decrypt()

INT32 m2mb_aes_256_ctr_decrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Decrypts input data for cipher AES, algorithm CTR and Key size 256.

Decrypts the input data and puts decrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing decrypted data.
[in]data_lenlength of inout data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_256_ctr_decrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_256_ctr_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
ret=m2mb_aes_256_ctr_decrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}

◆ m2mb_aes_256_ctr_encrypt()

INT32 m2mb_aes_256_ctr_encrypt ( const UINT8 key,
const UINT8 iv,
UINT8 data,
UINT32  data_len 
)

Encrypts input data for cipher AES, algorithm CTR and Key size 256.

Encrypts the input data and puts Encrypted data in the input data buffer itself.

Parameters
[in]keyKey to be used for decryption.
[in]ivBuffer containing the operation initialization vector (IV) or the initial counter value, as appropriate.
[in,out]datainput/output data buffer containing encrypted data.
[in]data_lenlength of inout data buffer.
Returns
0 on success. Error code on failure.
Note
<Notes>

m2mb_aes_256_ctr_encrypt(const UINT8 *key, const UINT8 *iv, UINT8 *data, UINT32 data_len);

int main()
{
ret=0;
UINT8 srcData[16] = {0};
UINT8 test_iv[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
memcpy(srcData, test_iv, 16);
ret=m2mb_aes_256_ctr_encrypt(test_iv,test_iv,srcData,16);
if(ret!=0) return ret;
}