cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone used the STM HAL CRYP functions to generate AES-GCM Nist test vector matches

JBuse.1
Associate
 
4 REPLIES 4
Imen.D
ST Employee

Hello @JBuse.1​ ,

Welcome to the STM32 Community 😊

Our HAL provided examples, based on either cryptolib or HW accelerators, are validated with NIST vector matching.

The processed results are always compared to expected ones from NIST test suits.

Hope this answer your question.

Otherswise, please share more details: which family, HAL examples, versions ?

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
JBuse.1
Associate

Hello Imen,

First thank you for the very quick reply.

I am trying to get the HAL_CRYP_Decrypt() or HAL_CRYP_Encrypt() method to produce results that match the below NIST test vector, and I cannot seem to get it to match. I use the following settings:

 Crypto::hcryp.Instance = CRYP;

 Crypto::hcryp.Init.DataType = CRYP_DATATYPE_8B;

 Crypto::hcryp.Init.KeySize = CRYP_KEYSIZE_128B;

 Crypto::hcryp.Init.Algorithm = CRYP_AES_GCM;

 Crypto::hcryp.Init.Header = (uint32_t *)NULL;

 Crypto::hcryp.Init.HeaderSize = 0;

 Crypto::hcryp.Init.KeyIVConfigSkip = CRYP_KEYIVCONFIG_ONCE;

 Crypto::hcryp.Init.DataWidthUnit = CRYP_DATAWIDTHUNIT_WORD;

 Crypto::hcryp.Init.pKey = (puint32_t)key_;

 Crypto::hcryp.Init.pInitVect=(puint32_t)iv_;

The test vector is line 4417 of the gcmDecrypt128.rsp file. I have validated this test vector with the STM32H7's AES ECB encrypt functionality and a software GCM implementation. I have checked your example projects, and there are AESGCM examples but they do not generate a NIST approved vector for verification.

[Keylen = 128]

[IVlen = 96]

[PTlen = 128]

[AADlen = 0]

[Taglen = 128]

Count = 0

Key = e98b72a9881a84ca6b76e0f43e68647a

IV = 8b23299fde174053f3d652ba

CT = 5a3c1cf1985dbb8bed818036fdd5ab42

AAD =

Tag = 23c7ab0f952b7091cd324835043b5eb5

PT = 28286a321293253c3e0aa2704a278032

Any help would be appreciated. Thank you,

Jon

Imen.D
ST Employee

Please check the STM32H7 series used and its compatibility with the appropriate Cryptolib version as below (or X-CUBE-CRYPTOLIB Data briefDB2660 - Rev 5 - November 2020 for all series compatibility) 

0693W000006GpkVQAS.png 

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

 Hi @JBuse.1​ ,

Please mark my answer as best by clicking on the "Select as Best" button if it fully solved your issue. This will help other users find this solution more quickly.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen