Failure to Catalog Keys and utilize Crypto functions like AES

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

Failure to Catalog Keys and utilize Crypto functions like AES

520 Views
kraghav
Contributor I

HI There,

I have installed the HSE Firmware as per the guide and it seems to show installed status. Also confirmed by the value at UTEST. After installing I have my Crypto driver code trying to catalog the AES Keys to be used for Encryption and Decryption but it fails to Catalog or load any keys. Looking for help on missing steps. 

0 Kudos
Reply
4 Replies

481 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @kraghav 

First of all, could you confirm if bit 0 in HSE GPR register at 0x4039_C028 is set? 

Then, is HSE_STATUS_INIT_OK (bit 24) in FSR register in MU_0 set? 

What is the state of GSR register in MU_0?

And how it fails? What kind of error code did you get? If you step inside those functions, can you see which error HSE returned exactly?

And finally - which device, which HSE firmware version and which RTD version you have?

Regards,

Lukas

0 Kudos
Reply

462 Views
kraghav
Contributor I

Hi Lukas,

Thanks for the quick response.

Below are the details requested:

I am using S32K344 MCU 

HSE GPR register : (*(volatile uint32_t*)0x4039C028)
Decimal:129
Hex:0x81
Binary:10000001
Octal:0201

s32k3x4_hse_fw_1.5.0_2.55.0_pb250130.bin.pink

msh />hse_dump_fw_version

=== HSE Init Start ===
MU Instance: 0
HSE FW status (before init): 0x00000960
- INIT_OK: YES
- RNG_OK: YES
Calling Hse_Ip_Init...
Hse_Ip_Init returned: 0 (0=success)
HSE FW status (after init): 0x00000960
Failed to get HSE capabilities (resp: 0xAA55A11E)
=== HSE Init SUCCESS ===

07-19 18:33:24 I/drv.hse: HSE0 initialized (FW status: 0x00000960)

=== HSE Init Start ===
MU Instance: 0
Already initialized
07-19 18:33:24 I/drv.hse: HSE key catalogs formatted successfully
07-19 18:33:24 I/hse.app: Key catalog formatted successfully
07-19 18:33:24 I/hse.app: HSE crypto context initialized
07-19 18:33:24 I/hse.test: Querying HSE FW version...
07-19 18:33:24 W/drv.hse: Get attr (id=0x0001) returned: 0xAA55A21C
07-19 18:33:24 W/hse.test: GET_ATTR(HSE_FW_VERSION_ATTR_ID) failed (ret=-1)
07-19 18:33:24 W/hse.test: Driver last HSE response: 0xAA55A21C
07-19 18:33:24 I/hse.app: HSE crypto context deinitialized

msh />hse_dump_mu_regs07-19 18:33:38 E/ser.pm: VBUS reset: 500ms


=== HSE Init Start ===
MU Instance: 0
Already initialized
07-19 18:33:38 I/drv.hse: Key catalogs already formatted; skipping format call
07-19 18:33:38 I/hse.app: Key catalog formatted successfully
07-19 18:33:38 I/hse.app: HSE crypto context initialized
07-19 18:33:38 I/hse.test: MU Registers snapshot:
07-19 18:33:38 I/hse.test: VER = 0x0300000F
07-19 18:33:38 I/hse.test: PAR = 0x20200404
07-19 18:33:38 I/hse.test: CR = 0x00000000
07-19 18:33:38 I/hse.test: SR = 0x00000000
07-19 18:33:38 I/hse.test: FSR = 0x09600000
07-19 18:33:38 I/hse.test: GCR = 0x00000000
07-19 18:33:39 I/hse.test: GSR = 0x00000000
07-19 18:33:39 I/hse.test: TCR = 0x00000000 TSR = 0x0000000F
07-19 18:33:39 I/hse.test: RCR = 0x00000000 RSR = 0x00000000
07-19 18:33:39 I/hse.test: TR[0] = 0x00000000
07-19 18:33:39 I/hse.test: TR[1] = 0x00000000
07-19 18:33:39 I/hse.test: TR[2] = 0x00000000
07-19 18:33:39 I/hse.test: TR[3] = 0x00000000
07-19 18:33:39 I/hse.test: RR[0] = 0x00000000
07-19 18:33:39 I/hse.test: RR[1] = 0xAA55A21C
07-19 18:33:39 I/hse.test: RR[2] = 0x00000000
07-19 18:33:39 I/hse.test: RR[3] = 0x00000000
07-19 18:33:39 I/hse.app: HSE crypto context deinitialized

MU Instance: 0
Already initialized
07-19 08:02:19 I/drv.hse: Key catalogs already formatted; skipping format call
07-19 08:02:19 I/hse.app: Key catalog formatted successfully
07-19 08:02:19 I/hse.app: HSE crypto context initialized
07-19 08:02:19 I/hse.test: GET_ATTR id=1 (len=8)
07-19 08:02:19 I/hse.test: FW Ver -> socType=1 fwType=0 major=0 minor=0 patch=0
07-19 08:02:19 I/hse.test: GET_ATTR id=2 (len=8)
07-19 08:02:19 I/hse.test: Capabilities bitmap: 0x%lX
07-19 08:02:19 I/hse.test: GET_ATTR id=3 (len=20)
07-19 08:02:19 I/hse.test: SMR status[0]=0xFDFFBDB7 status[1]=0x00000001 coreBoot[0]=0x00000000 coreBoot[1]=0x000000
07-19 08:02:19 I/hse.test: GET_ATTR id=20 (len=32)
07-19 08:02:19 I/hse.app: HSE crypto context deinitialized

Hope the given details help. I have attached the logs with some additional details. Do let me know in case I missed something or is required from my  end.

 

0 Kudos
Reply

404 Views
kraghav
Contributor I

I followed the instructions to install HSE Firmware and presumed it should start working. But I believe there was a conflict with the Bootloader for my target platform that is configured at the same start address space that overwrote the Firmware. As per some of the documentation I read that the Firmware is injected by the HSE after a couple of boot cycles. 

0 Kudos
Reply

249 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @kraghav 

When HSE firmware is installed, certain flash areas are exclusively reserved for HSE as shown in section "32.3.1 Memory map" in S32K3 reference manual. These areas are removed from memory map and user can't touch them or see them anymore. It's up to users to adjust linker files, so no code or data are placed in these areas. 

According to your log, HSE firmware is installed and running. Common reason for such errors is that data objects used for communication with HSE are placed in cacheable memory which is not allowed. HSE can't see such data. Make sure that all those data objects are forced to non-cacheable memory or try to disable data cache in your project completely. 

If this doesn't help, I would need more details about those commands which returned the errors. 

Regards,

Lukas

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2255599%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFailure%20to%20Catalog%20Keys%20and%20utilize%20Crypto%20functions%20like%20AES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2255599%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHI%20There%2C%3C%2FP%3E%3CP%3EI%20have%20installed%20the%20HSE%20Firmware%20as%20per%20the%20guide%20and%20it%20seems%20to%20show%20installed%20status.%20Also%20confirmed%20by%20the%20value%20at%20UTEST.%20After%20installing%20I%20have%20my%20Crypto%20driver%20code%20trying%20to%20catalog%20the%20AES%20Keys%20to%20be%20used%20for%20Encryption%20and%20Decryption%20but%20it%20fails%20to%20Catalog%20or%20load%20any%20keys.%20Looking%20for%20help%20on%20missing%20steps.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256671%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Failure%20to%20Catalog%20Keys%20and%20utilize%20Crypto%20functions%20like%20AES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256671%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%2F257115%22%20target%3D%22_blank%22%3E%40kraghav%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20HSE%20firmware%20is%20installed%2C%20certain%20flash%20areas%20are%20exclusively%20reserved%20for%20HSE%20as%20shown%20in%20section%20%2232.3.1%20Memory%20map%22%20in%20S32K3%20reference%20manual.%20These%20areas%20are%20removed%20from%20memory%20map%20and%20user%20can't%20touch%20them%20or%20see%20them%20anymore.%20It's%20up%20to%20users%20to%20adjust%20linker%20files%2C%20so%20no%20code%20or%20data%20are%20placed%20in%20these%20areas.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAccording%20to%20your%20log%2C%20HSE%20firmware%20is%20installed%20and%20running.%20Common%20reason%20for%20such%20errors%20is%20that%20data%20objects%20used%20for%20communication%20with%20HSE%20are%20placed%20in%20cacheable%20memory%20which%20is%20not%20allowed.%20HSE%20can't%20see%20such%20data.%20Make%20sure%20that%20all%20those%20data%20objects%20are%20forced%20to%20non-cacheable%20memory%20or%20try%20to%20disable%20data%20cache%20in%20your%20project%20completely.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20this%20doesn't%20help%2C%20I%20would%20need%20more%20details%20about%20those%20commands%20which%20returned%20the%20errors.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Failure%20to%20Catalog%20Keys%20and%20utilize%20Crypto%20functions%20like%20AES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20followed%20the%20instructions%20to%20install%20HSE%20Firmware%20and%20presumed%20it%20should%20start%20working.%20But%20I%20believe%20there%20was%20a%20conflict%20with%20the%20Bootloader%20for%20my%20target%20platform%20that%20is%20configured%20at%20the%20same%20start%20address%20space%20that%20overwrote%20the%20Firmware.%20As%20per%20some%20of%20the%20documentation%20I%20read%20that%20the%20Firmware%20is%20injected%20by%20the%20HSE%20after%20a%20couple%20of%20boot%20cycles.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Failure%20to%20Catalog%20Keys%20and%20utilize%20Crypto%20functions%20like%20AES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Lukas%2C%3C%2FP%3E%3CP%3EThanks%20for%20the%20quick%20response.%3C%2FP%3E%3CP%3EBelow%20are%20the%20details%20requested%3A%3C%2FP%3E%3CP%3EI%20am%20using%20S32K344%20MCU%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHSE%20GPR%20register%26nbsp%3B%3C%2FSPAN%3E%3A%20(*(volatile%20uint32_t*)0x4039C028)%3CBR%20%2F%3EDecimal%3A129%3CBR%20%2F%3EHex%3A0x81%3CBR%20%2F%3EBinary%3A10000001%3CBR%20%2F%3EOctal%3A0201%3C%2FP%3E%3CP%3Es32k3x4_hse_fw_1.5.0_2.55.0_pb250130.bin.pink%3C%2FP%3E%3CP%3Emsh%20%2F%26gt%3Bhse_dump_fw_version%3C%2FP%3E%3CP%3E%3D%3D%3D%20HSE%20Init%20Start%20%3D%3D%3D%3CBR%20%2F%3EMU%20Instance%3A%200%3CBR%20%2F%3EHSE%20FW%20status%20(before%20init)%3A%200x00000960%3CBR%20%2F%3E-%20INIT_OK%3A%20YES%3CBR%20%2F%3E-%20RNG_OK%3A%20YES%3CBR%20%2F%3ECalling%20Hse_Ip_Init...%3CBR%20%2F%3EHse_Ip_Init%20returned%3A%200%20(0%3Dsuccess)%3CBR%20%2F%3EHSE%20FW%20status%20(after%20init)%3A%200x00000960%3CBR%20%2F%3EFailed%20to%20get%20HSE%20capabilities%20(resp%3A%200xAA55A11E)%3CBR%20%2F%3E%3D%3D%3D%20HSE%20Init%20SUCCESS%20%3D%3D%3D%3C%2FP%3E%3CP%3E07-19%2018%3A33%3A24%20I%2Fdrv.hse%3A%20HSE0%20initialized%20(FW%20status%3A%200x00000960)%3C%2FP%3E%3CP%3E%3D%3D%3D%20HSE%20Init%20Start%20%3D%3D%3D%3CBR%20%2F%3EMU%20Instance%3A%200%3CBR%20%2F%3EAlready%20initialized%3CBR%20%2F%3E07-19%2018%3A33%3A24%20I%2Fdrv.hse%3A%20HSE%20key%20catalogs%20formatted%20successfully%3CBR%20%2F%3E07-19%2018%3A33%3A24%20I%2Fhse.app%3A%20Key%20catalog%20formatted%20successfully%3CBR%20%2F%3E07-19%2018%3A33%3A24%20I%2Fhse.app%3A%20HSE%20crypto%20context%20initialized%3CBR%20%2F%3E07-19%2018%3A33%3A24%20I%2Fhse.test%3A%20Querying%20HSE%20FW%20version...%3CBR%20%2F%3E07-19%2018%3A33%3A24%20W%2Fdrv.hse%3A%20Get%20attr%20(id%3D0x0001)%20returned%3A%200xAA55A21C%3CBR%20%2F%3E07-19%2018%3A33%3A24%20W%2Fhse.test%3A%20GET_ATTR(HSE_FW_VERSION_ATTR_ID)%20failed%20(ret%3D-1)%3CBR%20%2F%3E07-19%2018%3A33%3A24%20W%2Fhse.test%3A%20Driver%20last%20HSE%20response%3A%200xAA55A21C%3CBR%20%2F%3E07-19%2018%3A33%3A24%20I%2Fhse.app%3A%20HSE%20crypto%20context%20deinitialized%3C%2FP%3E%3CP%3Emsh%20%2F%26gt%3Bhse_dump_mu_regs07-19%2018%3A33%3A38%20E%2Fser.pm%3A%20VBUS%20reset%3A%20500ms%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3D%3D%3D%20HSE%20Init%20Start%20%3D%3D%3D%3CBR%20%2F%3EMU%20Instance%3A%200%3CBR%20%2F%3EAlready%20initialized%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fdrv.hse%3A%20Key%20catalogs%20already%20formatted%3B%20skipping%20format%20call%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.app%3A%20Key%20catalog%20formatted%20successfully%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.app%3A%20HSE%20crypto%20context%20initialized%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20MU%20Registers%20snapshot%3A%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20VER%20%3D%200x0300000F%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20PAR%20%3D%200x20200404%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20CR%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20SR%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20FSR%20%3D%200x09600000%3CBR%20%2F%3E07-19%2018%3A33%3A38%20I%2Fhse.test%3A%20GCR%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20GSR%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20TCR%20%3D%200x00000000%20TSR%20%3D%200x0000000F%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20RCR%20%3D%200x00000000%20RSR%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20TR%5B0%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20TR%5B1%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20TR%5B2%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20TR%5B3%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20RR%5B0%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20RR%5B1%5D%20%3D%200xAA55A21C%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20RR%5B2%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.test%3A%20RR%5B3%5D%20%3D%200x00000000%3CBR%20%2F%3E07-19%2018%3A33%3A39%20I%2Fhse.app%3A%20HSE%20crypto%20context%20deinitialized%3C%2FP%3E%3CP%3EMU%20Instance%3A%200%3CBR%20%2F%3EAlready%20initialized%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fdrv.hse%3A%20Key%20catalogs%20already%20formatted%3B%20skipping%20format%20call%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.app%3A%20Key%20catalog%20formatted%20successfully%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.app%3A%20HSE%20crypto%20context%20initialized%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20GET_ATTR%20id%3D1%20(len%3D8)%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20FW%20Ver%20-%26gt%3B%20socType%3D1%20fwType%3D0%20major%3D0%20minor%3D0%20patch%3D0%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20GET_ATTR%20id%3D2%20(len%3D8)%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20Capabilities%20bitmap%3A%200x%25lX%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20GET_ATTR%20id%3D3%20(len%3D20)%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20SMR%20status%5B0%5D%3D0xFDFFBDB7%20status%5B1%5D%3D0x00000001%20coreBoot%5B0%5D%3D0x00000000%20coreBoot%5B1%5D%3D0x000000%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.test%3A%20GET_ATTR%20id%3D20%20(len%3D32)%3CBR%20%2F%3E07-19%2008%3A02%3A19%20I%2Fhse.app%3A%20HSE%20crypto%20context%20deinitialized%3C%2FP%3E%3CP%3EHope%20the%20given%20details%20help.%20I%20have%20attached%20the%20logs%20with%20some%20additional%20details.%20Do%20let%20me%20know%20in%20case%20I%20missed%20something%20or%20is%20required%20from%20my%26nbsp%3B%20end.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256064%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Failure%20to%20Catalog%20Keys%20and%20utilize%20Crypto%20functions%20like%20AES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256064%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%2F257115%22%20target%3D%22_blank%22%3E%40kraghav%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20of%20all%2C%20could%20you%20confirm%20if%20bit%200%20in%20HSE%20GPR%20register%20at%200x4039_C028%20is%20set%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20is%20HSE_STATUS_INIT_OK%20(bit%2024)%20in%20FSR%20register%20in%20MU_0%20set%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20is%20the%20state%20of%20GSR%20register%20in%20MU_0%3F%3C%2FP%3E%0A%3CP%3EAnd%20how%20it%20fails%3F%20What%20kind%20of%20error%20code%20did%20you%20get%3F%20If%20you%20step%20inside%20those%20functions%2C%20can%20you%20see%20which%20error%20HSE%20returned%20exactly%3F%3C%2FP%3E%0A%3CP%3EAnd%20finally%20-%20which%20device%2C%20which%20HSE%20firmware%20version%20and%20which%20RTD%20version%20you%20have%3F%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E