Should auth_cntr provide a return value?

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

Should auth_cntr provide a return value?

Jump to solution
913 Views
HH_Mov
Contributor III

Using an i.mx93 in OEM_Open mode, I was validating the detection of invalidly signed containers.

The code in u-boot for "\include\configs\imx93_evk.h" implies that the auth_cntr returns a value which could be used in an "if statement" in the environment.

"auth_os=auth_cntr ${cntr_addr}\0" \
"mmcboot=echo Booting from mmc ...; " \
		"run mmcargs; " \
		"if test ${sec_boot} = yes; then " \
			"if run auth_os; then " \
				"run boot_os; " \
			"else " \
				"echo ERR: failed to authenticate; " \
			"fi; " \
		....

The check "if run auth_os; then" gives the impression that the success of the container validation is available as a return value. 

However testing shows that the result is always "0", for both a valid and invalid signed container. The ahab_status command does report errors after validating the invalid signed container.

Is this expected behavior for an OEM_Open device ? Or is the imx93_evk.h file implying something that is not there ?

Labels (2)
Tags (2)
0 Kudos
Reply
1 Solution
609 Views
HH_Mov
Contributor III

It seems the result value only reports something about the execution of the auth_cntr command and not if the container itself is authentic.


For OEM_Open scenarios this might result in the "run boot_os" to be executed even when the container is not authentic.

For OEM_Closed scenarios, the call to auth_cntr will result in an immediate reboot, so the if statement will never be completed.

View solution in original post

0 Kudos
Reply
4 Replies
610 Views
HH_Mov
Contributor III

It seems the result value only reports something about the execution of the auth_cntr command and not if the container itself is authentic.


For OEM_Open scenarios this might result in the "run boot_os" to be executed even when the container is not authentic.

For OEM_Closed scenarios, the call to auth_cntr will result in an immediate reboot, so the if statement will never be completed.

0 Kudos
Reply
870 Views
Harvey021
NXP TechSupport
NXP TechSupport

The auth_os verifies the container which is built with kernel and DTB. The ahab_status just reports what was verified.

Which version of BSP are you testing and what AHAB events?

 

Best regards

Harvey

0 Kudos
Reply
865 Views
HH_Mov
Contributor III

I am running a yocto scarthgap based image on an i.MX93 based board, running a rather old 2022.04 u-boot (at the moment).

The idea was to have a number of ahab containers:
  - 1st container: ELE, DDR FW, SPL
  - 2nd container: ATF, OP-TEE, U-Boot
  - 3rd container: Kernel
  - 4th container: dtb
  - ....nth

All containers are verified via the chain of trust, starting with ROM verifying the 1st, SPL the 2nd, u-boot the 3rd, 4th and possibly additional containers.

To verify the 3rd and 4th container in u-boot, I use the auth_cntr command and it provides info via ahab_status on the result. However the idea was to add this to a bootcmd, allowing each container to be validated and stopping or moving to a recovery mode on failure.

So the question I have is, how can I use the auth_cntr in an automated/scripted implementation? Or is adding these steps/verifications in the code itself and calling a custom command to handle these checks more suitable/normal practice?

0 Kudos
Reply
796 Views
Harvey021
NXP TechSupport
NXP TechSupport

Hope that the section <10.9 Security reference design> of the guide may help for you. 

 

Regards

Harvey

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2138272%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EShould%20auth_cntr%20provide%20a%20return%20value%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138272%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EUsing%20an%20i.mx93%20in%20OEM_Open%20mode%2C%20I%20was%20validating%20the%20detection%20of%20invalidly%20signed%20containers.%3C%2FP%3E%3CP%3EThe%20code%20in%20u-boot%20for%20%22%5Cinclude%5Cconfigs%5Cimx93_evk.h%22%20implies%20that%20the%20auth_cntr%20returns%20a%20value%20which%20could%20be%20used%20in%20an%20%22if%20statement%22%20in%20the%20environment.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%22auth_os%3Dauth_cntr%20%24%7Bcntr_addr%7D%5C0%22%20%5C%0A%22mmcboot%3Decho%20Booting%20from%20mmc%20...%3B%20%22%20%5C%0A%09%09%22run%20mmcargs%3B%20%22%20%5C%0A%09%09%22if%20test%20%24%7Bsec_boot%7D%20%3D%20yes%3B%20then%20%22%20%5C%0A%09%09%09%22if%20run%20auth_os%3B%20then%20%22%20%5C%0A%09%09%09%09%22run%20boot_os%3B%20%22%20%5C%0A%09%09%09%22else%20%22%20%5C%0A%09%09%09%09%22echo%20ERR%3A%20failed%20to%20authenticate%3B%20%22%20%5C%0A%09%09%09%22fi%3B%20%22%20%5C%0A%09%09....%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThe%20check%20%22if%20run%20auth_os%3B%20then%22%20gives%20the%20impression%20that%20the%20success%20of%20the%20container%20validation%20is%20available%20as%20a%20return%20value.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EHowever%20testing%20shows%20that%20the%20result%20is%20always%20%220%22%2C%20for%20both%20a%20valid%20and%20invalid%20signed%20container.%20The%20ahab_status%20command%20does%20report%20errors%20after%20validating%20the%20invalid%20signed%20container.%3C%2FP%3E%3CP%3EIs%20this%20expected%20behavior%20for%20an%20OEM_Open%20device%20%3F%20Or%20is%20the%20imx93_evk.h%20file%20implying%20something%20that%20is%20not%20there%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2138272%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EYocto%20Project%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2161187%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Should%20auth_cntr%20provide%20a%20return%20value%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2161187%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIt%20seems%20the%20result%20value%20only%20reports%20something%20about%20the%20execution%20of%20the%20auth_cntr%20command%20and%20%3CSTRONG%3Enot%3C%2FSTRONG%3E%20if%20the%20container%20itself%20is%20authentic.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EFor%20OEM_Open%20scenarios%20this%20might%20result%20in%20the%20%22run%20boot_os%22%20to%20be%20executed%20even%20when%20the%20container%20is%20not%20authentic.%3C%2FP%3E%3CP%3EFor%20OEM_Closed%20scenarios%2C%20the%20call%20to%20auth_cntr%20will%20result%20in%20an%20immediate%20reboot%2C%20so%20the%20if%20statement%20will%20never%20be%20completed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2142768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Should%20auth_cntr%20provide%20a%20return%20value%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2142768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHope%20that%20the%20section%20%26lt%3B10.9%20Security%20reference%20design%26gt%3B%20of%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FUG10163.pdf%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ethe%20guide%3C%2FA%3E%26nbsp%3Bmay%20help%20for%20you.%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%3CLINGO-SUB%20id%3D%22lingo-sub-2140631%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Should%20auth_cntr%20provide%20a%20return%20value%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140631%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20running%20a%20yocto%20scarthgap%20based%20image%20on%20an%20i.MX93%20based%20board%2C%20running%20a%20rather%20old%202022.04%20u-boot%20(at%20the%20moment).%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20idea%20was%20to%20have%20a%20number%20of%20ahab%20containers%3A%3CBR%20%2F%3E%26nbsp%3B%20-%201st%20container%3A%20ELE%2C%20DDR%20FW%2C%20SPL%3CBR%20%2F%3E%26nbsp%3B%20-%202nd%20container%3A%20ATF%2C%20OP-TEE%2C%20U-Boot%3CBR%20%2F%3E%26nbsp%3B%20-%203rd%20container%3A%20Kernel%3CBR%20%2F%3E%26nbsp%3B%20-%204th%20container%3A%20dtb%3CBR%20%2F%3E%26nbsp%3B%20-%20....nth%3CBR%20%2F%3E%3CBR%20%2F%3EAll%20containers%20are%20verified%20via%20the%20chain%20of%20trust%2C%20starting%20with%20ROM%20verifying%20the%201st%2C%20SPL%20the%202nd%2C%20u-boot%20the%203rd%2C%204th%20and%20possibly%20additional%20containers.%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20verify%20the%203rd%20and%204th%20container%20in%20u-boot%2C%20I%20use%20the%20auth_cntr%20command%20and%20it%20provides%20info%20via%20ahab_status%20on%20the%20result.%20However%20the%20idea%20was%20to%20add%20this%20to%20a%20bootcmd%2C%20allowing%20each%20container%20to%20be%20validated%20and%20stopping%20or%20moving%20to%20a%20recovery%20mode%20on%20failure.%3C%2FP%3E%3CP%3ESo%20the%20question%20I%20have%20is%2C%20how%20can%20I%20use%20the%20auth_cntr%20in%20an%20automated%2Fscripted%20implementation%3F%20Or%20is%20adding%20these%20steps%2Fverifications%20in%20the%20code%20itself%20and%20calling%20a%20custom%20command%20to%20handle%20these%20checks%20more%20suitable%2Fnormal%20practice%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2140493%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Should%20auth_cntr%20provide%20a%20return%20value%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140493%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%20data-teams%3D%22true%22%3EThe%20auth_os%20verifies%20the%20container%20which%20is%20built%20with%20kernel%20and%20DTB.%20The%20ahab_status%20just%20reports%20what%20was%20verified.%3C%2FSPAN%3E%3CSPAN%20data-teams%3D%22true%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-teams%3D%22true%22%3EWhich%20version%20of%20BSP%20are%20you%20testing%20and%20what%20AHAB%20events%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSPAN%20data-teams%3D%22true%22%3EBest%20regards%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-teams%3D%22true%22%3EHarvey%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E