cancel
Showing results for 
Search instead for 
Did you mean: 

X-CUBE-CRYPTOLIB AES CTR

SURLEAU.Frederic
Associate III
Posted on May 14, 2018 at 10:07

Hi,

Does anyone knows how the counter is handled in AES_CTR_Encrypt_Init() / AES_CTR_Encrypt_Append().

I suppose it is somewhere in the IV, but the documentation does not talk about it.

The examples use an IV initialised at 0xF0, 0xF1, ..., 0xFF with a nice comment :

'Third parameter is NULL because CTR doesn't use any IV'.

If the counter is not in the IV where is it ? How can I modify it ?

Is it a 16 bytes big integer ?

A 32 bit integer ?

Endianness ?

Regards,

Fred.

#x-cube-cryptolib-aes-ctr
2 REPLIES 2
Richard Lowe
Senior III
Posted on May 14, 2018 at 20:13

Although it declares that it is not used and is null, one is provided in the examples:

/* Initialize the operation, by passing the key.
 * Third parameter is NULL because CTR doesn't use any IV */
error_status = AES_CTR_Encrypt_Init(&AESctx, AES128_Key, InitializationVector );�?�?�?

InitializationVector is a reference to:

/* Initialization Vector, used only in non-ECB modes */
uint8_t IV[CRL_AES_BLOCK] =
 {
 0xf0 , 0xf1 , 0xf2 , 0xf3 , 0xf4 , 0xf5 , 0xf6 , 0xf7,
 0xf8 , 0xf9 , 0xfa , 0xfb , 0xfc , 0xfd , 0xfe , 0xff
 };�?�?�?�?�?�?

I believe the source is compiled, so not sure where that reference goes. Might be worth it just change the referenced block and monitor the result.

I would also assume it is in bytes (16) and little endian to match the processor.
SURLEAU.Frederic
Associate III
Posted on May 15, 2018 at 08:28

Thanks for your answer.

You pointed the same problems i did : 'the source is closed', the examples are not helping and the documentation is not complete.

It may not be a problem for implementation of a standard, but in this case, there is no CTR standard.

So X-CUBE-CRYPTOLIB is only compatible with itself and can't be used to exchange data with another library.

Regards,

Fred.