hsm_import_key returns with 0xF0 (Bad Signature)

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

hsm_import_key returns with 0xF0 (Bad Signature)

Jump to solution
875 Views
HH_Mov
Contributor III

During the "import key" of a custom generated keyblob, the response is: 0xF0

SAB reports (Invalid TLV signature)

SAB Error: SAB CMD [0x4f] Resp [0xf029] - Unknown error code

 

The used signature calculation is based on the OEM_IMPORT_CMAC_SK key, using the sample code from point 6 in "OEM Key import test flow".

 

Question 1: How can I verify if it is actually the signature going wrong and not e.g. using an invalid/incorrect OEM_IMPORT_CMAC_SK ?

There is an example tlv buffer in the documentation on page 219, but the used OEM_IMPORT_WRAP_SK, OEM_IMPORT_CMAC_SK (and the used imported key) are not provided, so I cannot verify this.

Question 2: If the OEM_IMPORT_CMAC_SK is wrong/mismatching on Peer and FW, how to debug?

0 Kudos
Reply
1 Solution
458 Views
HH_Mov
Contributor III

Issue was fixed. The problem was related to an incorrect fuse_version specified in the yaml file.
Why it was not 0 but 2 is not completely clear but it solved this issue

View solution in original post

0 Kudos
Reply
6 Replies
459 Views
HH_Mov
Contributor III

Issue was fixed. The problem was related to an incorrect fuse_version specified in the yaml file.
Why it was not 0 but 2 is not completely clear but it solved this issue

0 Kudos
Reply
827 Views
Harvey021
NXP TechSupport
NXP TechSupport

There is demo related to the key import for your reference.

hope the ele-apps can help. also, the one smw-apps 

 

Regards

Harvey

0 Kudos
Reply
795 Views
HH_Mov
Contributor III

Hello @Harvey021 ,

Thanks for the example, the imx-ele-apps/key-import, helped me verify my implementation, verifying the following are correct:

- NXP product manufact key agreement
- shared secret
- OEM_IMPORT_MK_SK
- OEM_IMPORT_WRAP_SK
- OEM_IMPORT_CMAC_SK

However performing the key-exchange (with the example SW) on an OEM_Closed device crashes the system:

sh run_test_on_board.sh
nxp_prod_ka_puk.bin exists.
oem_public_key.pem exists.
signed_msg.bin exists.
Hello, World! Sep 11 2025:14:50:25 77be1e7
Signed Message: 736 bytes
00e002890200000000000000b[  281.271513] fsl-se-fw se-fw2: Rx-Msg(0xe1470206): Fatal abort received  by hsm1.

 

Running the same test (with the example SW) on an OEM_Open device results in a invalid signature message:

    hsm_open_session success
    hsm_open_key_store_service success
    hsm_open_key_management_service success

    SAB Error: SAB CMD [0x47] Resp [0x1829] - Invalid Signature in SIGNED message.

    hsm_key_exchange failed err:0xfe
    Key exchange failed: 254

 

For info, the SRK hash reported by the signed message generation (running the command.sh on host side) for KEY_EXCHANGE_REQ matches the SRKH obtained from the HSM.

1. Is there an expected difference between an OEM_Open and OEM_Closed device ?

2. Why would the signature be reported invalid in the example ?

 

 

0 Kudos
Reply
749 Views
Harvey021
NXP TechSupport
NXP TechSupport

Hello @HH_Mov 

 

For the 1st question, we'll further check with Internal R&D and get back to you.

For the 2nd question, we cannot reproduce the issue with the provided demo app. If possible, we can have a meeting with you to review your operations.

 

Regards

Harvey

0 Kudos
Reply
716 Views
HH_Mov
Contributor III

Hello Harvey,

Thanks for your reply. To validate our steps a colleague also tried the steps from the example and came to the same issues.

I would like to have a meeting to see if we can tackle this issue, maybe it is better to continue this via e-mail ?

Thnx

0 Kudos
Reply
668 Views
Harvey021
NXP TechSupport
NXP TechSupport

Hello @HH_Mov 

With checking internal team, a meeting would be more effective in solving this problem. Please let us know from there.

 

Regards

Harvey

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2163777%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ehsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2163777%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDuring%20the%20%22import%20key%22%20of%20a%20custom%20generated%20keyblob%2C%20the%20response%20is%3A%200xF0%3C%2FP%3E%3CP%3ESAB%20reports%20(Invalid%20TLV%20signature)%3C%2FP%3E%3CPRE%3ESAB%20Error%3A%20SAB%20CMD%20%5B0x4f%5D%20Resp%20%5B0xf029%5D%20-%20Unknown%20error%20code%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EThe%20used%20signature%20calculation%20is%20based%20on%20the%20OEM_IMPORT_CMAC_SK%20key%2C%20using%20the%20sample%20code%20from%20point%206%20in%20%22OEM%20Key%20import%20test%20flow%22.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CU%3EQuestion%201%3C%2FU%3E%3A%20How%20can%20I%20verify%20if%20it%20is%20actually%20the%20signature%20going%20wrong%20and%20not%20e.g.%20using%20an%20invalid%2Fincorrect%26nbsp%3BOEM_IMPORT_CMAC_SK%20%3F%3C%2FP%3E%3CP%3EThere%20is%20an%20example%20tlv%20buffer%20in%20the%20documentation%20on%20page%20219%2C%20but%20the%20used%20OEM_IMPORT_WRAP_SK%2C%20OEM_IMPORT_CMAC_SK%20(and%20the%20used%20imported%20key)%20are%20not%20provided%2C%20so%20I%20cannot%20verify%20this.%3C%2FP%3E%3CP%3E%3CU%3EQuestion%202%3A%3C%2FU%3E%20If%20the%26nbsp%3BOEM_IMPORT_CMAC_SK%20is%20wrong%2Fmismatching%20on%20Peer%20and%20FW%2C%20how%20to%20debug%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2184553%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2184553%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIssue%20was%20fixed.%20The%20problem%20was%20related%20to%20an%20incorrect%20fuse_version%20specified%20in%20the%20yaml%20file.%3CBR%20%2F%3EWhy%20it%20was%20not%200%20but%202%20is%20not%20completely%20clear%20but%20it%20solved%20this%20issue%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2171900%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2171900%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F252198%22%20target%3D%22_blank%22%3E%40HH_Mov%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWith%20checking%20internal%20team%2C%20a%20meeting%20would%20be%20more%20effective%20in%20solving%20this%20problem.%20Please%20let%20us%20know%20from%20there.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%3C%2FP%3E%0A%3CP%3EHarvey%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2170956%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2170956%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Harvey%2C%3C%2FP%3E%3CP%3EThanks%20for%20your%20reply.%20To%20validate%20our%20steps%20a%20colleague%20also%20tried%20the%20steps%20from%20the%20example%20and%20came%20to%20the%20same%20issues.%3C%2FP%3E%3CP%3EI%20would%20like%20to%20have%20a%20meeting%20to%20see%20if%20we%20can%20tackle%20this%20issue%2C%20maybe%20it%20is%20better%20to%20continue%20this%20via%20e-mail%20%3F%3C%2FP%3E%3CP%3EThnx%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2169583%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2169583%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F252198%22%20target%3D%22_blank%22%3E%40HH_Mov%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EFor%20the%201st%20question%2C%20we'll%20further%20check%20with%20Internal%20R%26amp%3BD%20and%20get%20back%20to%20you.%3C%2FP%3E%0A%3CP%3EFor%20the%202nd%20question%2C%20we%20cannot%20reproduce%20the%20issue%20with%20the%20provided%20demo%20app.%20If%20possible%2C%20we%20can%20have%20a%20meeting%20with%20you%20to%20review%20your%20operations.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%3C%2FP%3E%0A%3CP%3EHarvey%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2167954%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2167954%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F192970%22%20target%3D%22_blank%22%3E%40Harvey021%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EThanks%20for%20the%20example%2C%20the%20imx-ele-apps%2Fkey-import%2C%20helped%20me%20verify%20my%20implementation%2C%20verifying%20the%20following%20are%20correct%3A%3C%2FP%3E%3CP%3E-%20NXP%20product%20manufact%20key%20agreement%3CBR%20%2F%3E-%20shared%20secret%3CBR%20%2F%3E-%20OEM_IMPORT_MK_SK%3CBR%20%2F%3E-%20OEM_IMPORT_WRAP_SK%3CBR%20%2F%3E-%20OEM_IMPORT_CMAC_SK%3C%2FP%3E%3CP%20class%3D%22lia-align-left%22%20style%3D%22text-align%20%3A%20left%3B%22%20style%3D%22text-align%20%3A%20left%3B%22%3EHowever%20performing%20the%20key-exchange%20(with%20the%20example%20SW)%20on%20an%20OEM_Closed%20device%20crashes%20the%20system%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Esh%20run_test_on_board.sh%0Anxp_prod_ka_puk.bin%20exists.%0Aoem_public_key.pem%20exists.%0Asigned_msg.bin%20exists.%0AHello%2C%20World!%20Sep%2011%202025%3A14%3A50%3A25%2077be1e7%0ASigned%20Message%3A%20736%20bytes%0A00e002890200000000000000b%5B%20%20281.271513%5D%20fsl-se-fw%20se-fw2%3A%20Rx-Msg(0xe1470206)%3A%20Fatal%20abort%20received%20%20by%20hsm1.%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3ERunning%20the%20same%20test%20(with%20the%20example%20SW)%20on%20an%20OEM_Open%20device%20results%20in%20a%20invalid%20signature%20message%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20hsm_open_session%20success%0A%20%20%20%20hsm_open_key_store_service%20success%0A%20%20%20%20hsm_open_key_management_service%20success%0A%0A%20%20%20%20SAB%20Error%3A%20SAB%20CMD%20%5B0x47%5D%20Resp%20%5B0x1829%5D%20-%20Invalid%20Signature%20in%20SIGNED%20message.%0A%0A%20%20%20%20hsm_key_exchange%20failed%20err%3A0xfe%0A%20%20%20%20Key%20exchange%20failed%3A%20254%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EFor%20info%2C%20the%20SRK%20hash%20reported%20by%20the%20signed%20message%20generation%20(running%20the%20command.sh%20on%20host%20side)%20for%20KEY_EXCHANGE_REQ%20matches%20the%20SRKH%20obtained%20from%20the%20HSM.%3C%2FP%3E%3CP%3E1.%20Is%20there%20an%20expected%20difference%20between%20an%20OEM_Open%20and%20OEM_Closed%20device%20%3F%3C%2FP%3E%3CP%3E2.%20Why%20would%20the%20signature%20be%20reported%20invalid%20in%20the%20example%20%3F%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2164975%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20hsm_import_key%20returns%20with%200xF0%20(Bad%20Signature)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2164975%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThere%20is%20demo%20related%20to%20the%20key%20import%20for%20your%20reference.%3C%2FP%3E%0A%3CP%3Ehope%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fimx_sec_apps%2Ftree%2Fmaster%2Fimx-ele-apps%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eele-apps%3C%2FA%3E%20can%20help.%20also%2C%20the%20one%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fimx_sec_apps%2Ftree%2Fmaster%2Fimx-smw-apps%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Esmw-apps%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%3C%2FP%3E%0A%3CP%3EHarvey%3C%2FP%3E%3C%2FLINGO-BODY%3E