Key Management Example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Key Management Example

Jump to solution
944 Views
kerti1
Contributor III

Hi,

I am using the HSE for s32K and able to perform AES-128 encryption and SHA hashing successfully. Currently, I am storing the keys in RAM, which is only for testing purposes. I would now like to implement proper key management. Specifically, I want to know whether the HSE can automatically generate keys, or if we are required to hard-code them as global variables—similar to how we use RAM keys  and call the M1, M2, and M3 for storing in ECU.I have searched for examples using the HSE_IP layer (Non-AUTOSAR), but could not find any clear examples or documentation related to key management. Could you please provide a clear and understandable example for key management using the HSE_IP layer? That would be very helpful.


 

 

Thank you

0 Kudos
Reply
1 Solution
930 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @kerti1,

From the S32K3 product page, you can download the HSE Demo Examples, which contains various projects. 

Inside the SW package, you can find the Key Management demos, which include Session Keys (1) and NVM Key update (2). 

I can share the main objective from each example:

(1) The main purpose of this example is to show the steps required to properly configure the HSE to show the functionality of the session key services. It formats the keys and then generates the ECC key pair. Then import the ECC keys, compute the DH Shared Secret and derive key using SP800_108 KDF. Finally, it extracts from the derived key material 2 keys, a 192-bits AES and a 256-bit AES, and then encrypts and decrypt using AES GCM using both keys.
 
(2) The main purpose of this example is to an import symmetric key and AES GMAC generate keys.
 
Best regards,
Julián

View solution in original post

0 Kudos
Reply
2 Replies
369 Views
ASN7
Contributor III

Can the NVM Key update (2) demo, be used to store custom keys (not generated) so that it can be accessed after writing only once to a particular key slot ? 

Because right now, I import the keys to NVM and calculate CMAC and it works fine. And then I comment out the import function in the same project and select the key handle and ask HSE to calculate CMAC and it throws me an error saying key slot is empty. 

0 Kudos
Reply
931 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @kerti1,

From the S32K3 product page, you can download the HSE Demo Examples, which contains various projects. 

Inside the SW package, you can find the Key Management demos, which include Session Keys (1) and NVM Key update (2). 

I can share the main objective from each example:

(1) The main purpose of this example is to show the steps required to properly configure the HSE to show the functionality of the session key services. It formats the keys and then generates the ECC key pair. Then import the ECC keys, compute the DH Shared Secret and derive key using SP800_108 KDF. Finally, it extracts from the derived key material 2 keys, a 192-bits AES and a 256-bit AES, and then encrypts and decrypt using AES GCM using both keys.
 
(2) The main purpose of this example is to an import symmetric key and AES GMAC generate keys.
 
Best regards,
Julián
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2095517%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EKey%20Management%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2095517%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%20class%3D%22%22%3EI%20am%20using%20the%20HSE%20for%20s32K%20and%20able%20to%20perform%20AES-128%20encryption%20and%20SHA%20hashing%20successfully.%20Currently%2C%20I%20am%20storing%20the%20keys%20in%20RAM%2C%20which%20is%20only%20for%20testing%20purposes.%20I%20would%20now%20like%20to%20implement%20proper%20key%20management.%20Specifically%2C%20I%20want%20to%20know%20whether%20the%20HSE%20can%20automatically%20generate%20keys%2C%20or%20if%20we%20are%20required%20to%20hard-code%20them%20as%20global%20variables%E2%80%94similar%20to%20how%20we%20use%20RAM%20keys%26nbsp%3B%20and%20call%20the%20M1%2C%20M2%2C%20and%20M3%20for%20storing%20in%20ECU.I%20have%20searched%20for%20examples%20using%20the%20HSE_IP%20layer%20(Non-AUTOSAR)%2C%20but%20could%20not%20find%20any%20clear%20examples%20or%20documentation%20related%20to%20key%20management.%20Could%20you%20please%20provide%20a%20clear%20and%20understandable%20example%20for%20key%20management%20using%20the%20HSE_IP%20layer%3F%20That%20would%20be%20very%20helpful.%3C%2FP%3E%3CHR%20%2F%3E%3CP%20class%3D%22%22%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2195163%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Key%20Management%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2195163%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3ECan%20the%26nbsp%3BNVM%20Key%20update%20(2)%20demo%2C%20be%20used%20to%20store%20custom%20keys%20(not%20generated)%20so%20that%20it%20can%20be%20accessed%20after%20writing%20only%20once%20to%20a%20particular%20key%20slot%20%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EBecause%20right%20now%2C%20I%20import%20the%20keys%20to%20NVM%20and%20calculate%20CMAC%20and%20it%20works%20fine.%20And%20then%20I%20comment%20out%20the%20import%20function%20in%20the%20same%20project%20and%20select%20the%20key%20handle%20and%20ask%20HSE%20to%20calculate%20CMAC%20and%20it%20throws%20me%20an%20error%20saying%20key%20slot%20is%20empty.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2095673%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Key%20Management%20Example%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2095673%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F249628%22%20target%3D%22_blank%22%3E%40kerti1%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EFrom%20the%20S32K3%20product%20page%2C%20you%20can%20download%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fwebapp%2FDownload%3FcolCode%3DS32K3_HSE_DemoExamples%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHSE%20Demo%20Examples%3C%2FA%3E%2C%20which%20contains%20various%20projects.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInside%20the%20SW%20package%2C%20you%20can%20find%20the%20%3CSTRONG%3EKey%3C%2FSTRONG%3E%20%3CSTRONG%3EManagement%3C%2FSTRONG%3E%20demos%2C%20which%20include%26nbsp%3BSession%20Keys%20(1)%20and%20NVM%20Key%20update%20(2).%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20can%20share%20the%20main%20objective%20from%20each%20example%3A%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E(1)%20The%20main%20purpose%20of%20this%20example%20is%20to%20show%20the%20steps%20required%20to%20properly%20configure%20the%20HSE%20to%20show%20the%20functionality%20of%20the%20session%20key%20services.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EIt%20formats%20the%20keys%20and%20then%20generates%20the%20ECC%20key%20pair.%20Then%20import%20the%20ECC%20keys%2C%20compute%20the%20DH%20Shared%20Secret%20and%20derive%20key%20using%20SP800_108%20KDF.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EFinally%2C%20it%20extracts%20from%20the%20derived%20key%20material%202%20keys%2C%20a%20192-bits%20AES%20and%20a%20256-bit%20AES%2C%20and%20then%20encrypts%20and%20decrypt%20using%20AES%20GCM%20using%20both%20keys.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E(2)%26nbsp%3BThe%20main%20purpose%20of%20this%20example%20is%20to%20an%20import%20symmetric%20key%20and%20AES%20GMAC%20generate%20keys.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E