Keybox
Due to limited efuse space, Tina supports the Keybox Secure Storage feature by default. This document describes how to customize and burn keyboxes, as well as read them.
1. Firmware Configuration
Prerequisite: Secure firmware is required. For secure firmware details, refer to 14-Secure Boot.
1.1 Customize Keybox List
U-Boot loads keys into Secure OS based on the keybox_list environment variable. Configure this variable in the env.cfg file using comma-separated key names.
Example: Add a custom key name xie:
--- a/device/config/chips/h618/configs/default/env.cfg
+++ b/device/config/chips/h618/configs/default/env.cfg
@@ -13,7 +13,7 @@ mac=
wifi_mac=
bt_mac=
specialstr=
-keybox_list=hdcpkey,widevine
+keybox_list=hdcpkey,widevine,xie
#set kernel cmdline if boot.img or recovery.img has no cmdline we will use this
setargs_nand=setenv bootargs earlyprintk=${earlyprintk} initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nand_root} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} selinux=${selinux} specialstr=${specialstr} gpt=1
setargs_mmc=setenv bootargs earlyprintk=${earlyprintk} initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${mmc_root} rootwait init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} selinux=${selinux} specialstr=${specialstr} gpt=11.2 Keybox Configuration Reading
Keybox reading uses Allwinner-provided APIs. Tina includes demo implementations for these APIs. Keybox access requires TA/CA interaction.
CA: A Linux user-space application dependent on
optee-clientlibraries.TA: A secure application compiled using TA dev-kit.
1.2.1 TA/CA Compilation Configuration
Run kernel configuration:
Enable the following options:
optee-efuse-read: Example for keybox reading.optee-helloworld: Example to verify TA/CA environment.Verify changes:
Add platform-specific dev-kit:
1.2.2 Modifications for optee-efuse-read Demo
optee-efuse-read DemoAdd debug prints for keybox buffer:
dumpis a built-in hex print function.128corresponds to the key length.
1.2.3 Allwinner-Specific APIs
utee_sunxi_keyboxPurpose: Read keybox data by name. Parameters:
keyname: Key name (must match entries inkeybox_list).out_buf: Output buffer (size ≥size).size: Data length to read. Return:0(success),-1(failure).
utee_sunxi_read_efusePurpose: Read efuse data. Parameters:
keyname: Key name.result_len: Output data length.rd_buf: Output buffer. Return:0(success), others (failure).
utee_sunxi_write_efusePurpose: Burn data to efuse. Parameters:
keyname: Key name.write_len: Data length (bytes).wr_buf: Data buffer. Return:0(success), others (failure).
1.3 Compile Secure Firmware
Enable
burn_keyinsys_config.fex:
image-20241122101659346 Build firmware:
Output:
longan/out/h618_android12_p2_uart0_secure_secure_v0.img(v0is the default version number).
1.4 Burn Verification
Check
keybox_listin U-Boot:Verify TA/CA functionality:
2. Burn Keybox
Use the DragonSN tool to burn keyboxes via USB.
Open DragonSN:

Configure key settings:
Select Key Configuration:


image-20250514093013109 Add key entry (
xiein this example):
Select key file and burn options:
Enable Erase Before Burn and Power Off After Burn (for production).
Select key file:

Start burning:

Completion:

3. Read Keybox
U-Boot Verification:
System-Level Read:
Output:
Compare the output with your burned key for verification.
Last updated