S32K144 CSEc Calculate M1~M5

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

S32K144 CSEc Calculate M1~M5

Jump to solution
1,808 Views
wangmingming
Contributor III

It is mentioned in the document that loading the secret key is to first calculate M1~M5, and then call the interface to load the secret key. M4_out and M5_out will be returned. By comparing M4, M5 and M4_out M5_out, If both are consistent, it indicates that the key has been successfully loaded, otherwise the loading fails. I found in actual testing that the loading interface returns 0, but M4, M5, M4_out, and M5_out are quite inconsistent. Is this considered a successful or failed loading?1.png

0 Kudos
Reply
1 Solution
1,733 Views
wangmingming
Contributor III

Yes, I made a mistake before and printed their addresses, so the values are different. Modify to print numerical values, their values are the same. thank you5.png

View solution in original post

0 Kudos
Reply
4 Replies
1,786 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @wangmingming 

CSEc always uses UID when calculating M4 and M5 values which are returned after loading a key. It's given by SHE specification - it says that UID should be used for M4 and M5 calculation. It does not talk about wildcard in case of this functionality. This behavior cannot be changed.
So, if you used attribute WILDCARD = 0 when calculating M1-M5 values, the M4 and M5 will be really different.
If 0 was returned, the key was loaded. If you want to double checked that also by comparing M4 and M5, it would be necessary to use UID.

Regards,
Lukas

0 Kudos
Reply
1,775 Views
wangmingming
Contributor III

As shown in the figure below, when I set WILDCARD to 1 and plug it into the calculation interface, the M4 and M4_out, M5 and M5_out obtained are still different. How do I configure them to make them the same?2.png

0 Kudos
Reply
1,743 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

There's one more option. Please take a look at code examples in application note AN5401.

In calculate_M1_to_M5() function, wildcard and UID=0 is used for M1-M3 calculation. However, M4 and M5 is calculated with UID:

lukaszadrapa_0-1736164234091.png

The result is that M4-M5 values are the same after key load even if wildcard is used:

lukaszadrapa_1-1736164276387.png

Regards,

Lukas

0 Kudos
Reply
1,734 Views
wangmingming
Contributor III

Yes, I made a mistake before and printed their addresses, so the values are different. Modify to print numerical values, their values are the same. thank you5.png

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2021297%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K144%20CSEc%20%20Calculate%20M1~M5%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2021297%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIt%20is%20mentioned%20in%20the%20document%20that%20loading%20the%20secret%20key%20is%20to%20first%20calculate%20M1~M5%2C%20and%20then%20call%20the%20interface%20to%20load%20the%20secret%20key.%20M4_out%20and%20M5_out%20will%20be%20returned.%20By%20comparing%20M4%2C%20M5%20and%20M4_out%20M5_out%EF%BC%8C%20If%20both%20are%20consistent%2C%20it%20indicates%20that%20the%20key%20has%20been%20successfully%20loaded%2C%20otherwise%20the%20loading%20fails.%20I%20found%20in%20actual%20testing%20that%20the%20loading%20interface%20returns%200%2C%20but%20M4%2C%20M5%2C%20M4_out%2C%20and%20M5_out%20are%20quite%20inconsistent.%20Is%20this%20considered%20a%20successful%20or%20failed%20loading%3F%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%221.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F317875i5EA4C08AC6B1F964%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%221.png%22%20alt%3D%221.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2022867%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%20CSEc%20%20Calculate%20M1~M5%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2022867%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYes%2C%20I%20made%20a%20mistake%20before%20and%20printed%20their%20addresses%2C%20so%20the%20values%20are%20different.%20Modify%20to%20print%20numerical%20values%2C%20their%20values%20are%20the%20same.%20thank%20you%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%225.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%225.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F318300iED043AB78C947DA4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%225.png%22%20alt%3D%225.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2022557%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%20CSEc%20%20Calculate%20M1~M5%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2022557%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThere's%20one%20more%20option.%20Please%20take%20a%20look%20at%20code%20examples%20in%20application%20note%20AN5401.%3C%2FP%3E%0A%3CP%3EIn%20calculate_M1_to_M5()%20function%2C%20wildcard%20and%20UID%3D0%20is%20used%20for%20M1-M3%20calculation.%20However%2C%20M4%20and%20M5%20is%20calculated%20with%20UID%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lukaszadrapa_0-1736164234091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1736164234091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F318222i6C0E1C688BB7E58A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_0-1736164234091.png%22%20alt%3D%22lukaszadrapa_0-1736164234091.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20result%20is%20that%20M4-M5%20values%20are%20the%20same%20after%20key%20load%20even%20if%20wildcard%20is%20used%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lukaszadrapa_1-1736164276387.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_1-1736164276387.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F318223iE11A3E7E186B874D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_1-1736164276387.png%22%20alt%3D%22lukaszadrapa_1-1736164276387.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%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-2022043%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%20CSEc%20%20Calculate%20M1~M5%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2022043%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAs%20shown%20in%20the%20figure%20below%2C%20when%20I%20set%20WILDCARD%20to%201%20and%20plug%20it%20into%20the%20calculation%20interface%2C%20the%20M4%20and%20M4_out%2C%20M5%20and%20M5_out%20obtained%20are%20still%20different.%20How%20do%20I%20configure%20them%20to%20make%20them%20the%20same%3F%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F318090iF038066F617E9828%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222.png%22%20alt%3D%222.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2021699%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%20CSEc%20%20Calculate%20M1~M5%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2021699%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F245061%22%20target%3D%22_blank%22%3E%40wangmingming%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECSEc%20always%20uses%20UID%20when%20calculating%20M4%20and%20M5%20values%20which%20are%20returned%20after%20loading%20a%20key.%20It's%20given%20by%20SHE%20specification%20-%20it%20says%20that%20UID%20should%20be%20used%20for%20M4%20and%20M5%20calculation.%20It%20does%20not%20talk%20about%20wildcard%20in%20case%20of%20this%20functionality.%20This%20behavior%20cannot%20be%20changed.%20%3CBR%20%2F%3ESo%2C%20if%20you%20used%20attribute%20WILDCARD%20%3D%200%20when%20calculating%20M1-M5%20values%2C%20the%20M4%20and%20M5%20will%20be%20really%20different.%20%3CBR%20%2F%3EIf%200%20was%20returned%2C%20the%20key%20was%20loaded.%20If%20you%20want%20to%20double%20checked%20that%20also%20by%20comparing%20M4%20and%20M5%2C%20it%20would%20be%20necessary%20to%20use%20UID.%3C%2FP%3E%0A%3CP%3ERegards%2C%3CBR%20%2F%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E