An 12056
An 12056
1. Introduction Contents
This application note describes the encrypted boot 1. Introduction ........................................................................ 1
feature found in High-Assurance Boot (HAB) v4 1.1. Purpose .....................................................................2
1.2. Intended audience and scope ....................................2
supported devices, such as the i.MX 6 and i.MX 7 1.3. Definitions, Acronyms, and Abbreviations...............2
processors. Encrypted boot is a security mechanism that 2. Overview ............................................................................ 3
hides the sensitive information embedded in the 2.1. HAB library ..............................................................4
bootloader data when it is in the persistent data storage. 2.2. Encrypted boot sequence ..........................................4
3. Encrypted boot implementation.......................................... 5
3.1. Overview ..................................................................5
3.2. Requirements ............................................................6
3.3. Protocol ....................................................................6
3.4. Data encryption key handling ...................................7
3.5. DEK blob ..................................................................9
4. Encrypted U-Boot example .............................................. 10
4.1. Assumptions ...........................................................11
4.2. Requirements ..........................................................11
4.3. Implementation .......................................................13
4.4. Protecting the DEK blob after encrypted boot .......19
5. References ........................................................................ 20
Appendix A. Development scripts ....................................... 20
A.1. Building secure U-Boot ..........................................20
A.2. Building signed U-Boot..........................................21
A.3. Building encrypted U-Boot ....................................22
A.4. Provisioning the PRIBLOB setting on the chip .....25
Appendix B. Troubleshooting ............................................. 25
B.1. Signed U-Boot CSF example .................................25
B.2. Encrypted U-Boot CSF example ............................26
B.3. Script to determine the DEK blob address .............27
1.1. Purpose
The security suite in the i.MX 6 and i.MX 7 processors provides adequate features to establish a chain of
trust for high-assurance computing. The security suite provides the capability to meet the trust
computing requirements of embedded solutions, such as firmware data assurance.
Securing a hardware platform requires examination of its hardware components and verification of
authenticity and integrity of the critical code that controls the platform. These security checks are
executed after the reset by the boot code in the on-chip ROM. The ROM boot process (after verifying
the authenticity of the bootloader script residing in the flash or external memory) follows the script to
continue loading the operating system and data into the external memory. Because the bootloader script
may reside in the external memory, it can be seen or used by unauthorized users.
The encrypted boot feature adds an extra security operation to the boot-loading sequence. It uses
cryptographic techniques to obscure the bootloader data (it can be extended to the entire image), so it
cannot be seen or used by unauthorized users. This mechanism protects and conceals the bootloader
code residing in the flash (or external) memory. This application note describes the implementation of
encrypted boot, which can be tailored to your requirements.
stream cipher, and hashing algorithms, with a random number generator and run-time integrity
checker.
• CMS—Cryptographic Message Syntax; a general format for data that may have cryptography
applied to it, such as digital signatures and digital envelopes. HAB uses the CMS as a container
to hold the PKCS#1 signatures.
• CSF—Command Sequence File; a binary data structure interpreted by the HAB to guide
authentication operations.
• CST—Code Signing Tool; an application running on the build host to generate the CSF and
associated digital signatures.
• DCD—Device Configuration Data; a binary table used by the ROM code to configure the device
at early boot stages.
• DEK—Data Encryption Key; the AES key used to encrypt/decrypt the boot image.
• HAB—High-Assurance Boot; a software library executed in the internal ROM of NXP
processors at boot time which, among other things, authenticates the software in the external
memory by verifying digital signatures according to the CSF.
• IVT—Image Vector Table.
• OS—Operating System.
• OTP—One-Time Programmable. The OTP hardware includes the masked ROM and electrically
programmable fuses (eFuses).
• PKCS#1—A standard that specifies the use of the RSA algorithm.
• PKI—Public Key Infrastructure; a hierarchy of public key certificates in which each certificate
(except for the root certificate) can be verified using the public key above it.
• RSA—A public key cryptography algorithm developed by Rivest, Shamir, and Adleman.
• SA—Signature Authority; the holder of the private key used to sign software components.
• SDP—Serial Download Protocol; also called UART/USB serial download mode. It allows code
provisioning through UART or USB during the production and development phases.
• SRK—Super Root Key; an RSA key pair which forms the start of the boot-time authentication
chain. The hash of the SRK public key is embedded in the processor using OTP hardware. The
SRK private key is held by the CA. Unless explicitly noted, the SRK acronym (in this document)
refers to the public key only.
2. Overview
It is recommended to read Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using HABv4
(document AN4581) before reading this document. Document AN4581 provides technical overview of
the secure boot feature and the signing procedure of image binaries required to understand the use cases
and processes described later on in this document.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 3
Overview
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
4 NXP Semiconductors
Encrypted boot implementation
3.1. Overview
Simply put, encrypted boot is a secure-boot version of an encrypted bootloader. Therefore, this protocol
can be divided into two protection mechanisms. The first mechanism is the digital signature, which
authenticates the source of the binary image. The second mechanism is the bootloader code encryption,
which bestows confidentiality to the bootloader data. Keep in mind that encrypted boot uses both
mechanisms in any order (sign and then encrypt or encrypt and then sign) and both operations are
applied on the same region (except the header in plaintext, which can only be signed but not encrypted).
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 5
Encrypted boot implementation
3.2. Requirements
As described in the respective i.MX applications processor reference manual, the ROM requires a preset
number of data structures from the program image. In addition to these structures, the encrypted boot
image has two more data structures. These are the CSF and the DEK blob. The encrypted boot image
consists of:
• Image Vector Table (IVT)—a table of address pointers used by the boot ROM to locate other
required data components.
• Boot data structure—a simple structure indicating where to load the boot image and specifying
the size of the image.
• Device Configuration Data (DCD)—a list of registers that the ROM programs with the provided
data to perform an early initialization of the system. The DCD is typically used to initialize the
SDRAM.
• Command Sequence File (CSF) and the associated data—a block of data that contains the
commands that the HAB executes during the boot, as well as the associated certificates and
signatures that the HAB uses to verify images.
• Data Encryption Key blob (DEK blob)—the DEK is used to decrypt the encrypted boot image.
The DEK blob is used as a security layer to wrap and store the DEK off-chip, which is unique to
the chip that generated the blob.
Only the DEK blob generation and encryption process is described in this application note. For more
information about other components and the digital signature process, see Secure Boot on i.MX 50, i.MX
53, i.MX 6 and i.MX 7 Series using HABv4 (document AN4581).
3.3. Protocol
The encrypted boot protocol is an advanced use of the secure boot protocol. Encrypted boot is a
combination of digital signature verification and decryption of the bootloader image code. These steps
are a simplification of the encrypted boot protocol:
1. Signing a boot image.
2. Encrypting and signing of a boot image, or signing and encrypting of a boot image.
3. DEK blob generation and encrypted boot image assembling.
The first and second steps involve signing a binary image; this procedure follows the instructions from
Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using HABv4 (document AN4581). Keep in
mind that the authenticated boot image in step 1 is independent from the encrypted boot image in step 2.
For both steps, the digital signature authentication follows the same procedure as the secure boot. As
specified in Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using HABv4 (document
AN4581), a unique set of keys is generated by the CST, and these keys are used to create the digital
signature. During the process, a Super Root Key (SRK) table and certificates are also generated. Because
the keys and certificates are unique to the target processor, the same set is used for the encrypted boot.
In step 2, the boot data is encrypted and a digital signature of the whole boot data image including the
boot data structure (or vice versa) is generated. Note that the boot data structures do not contain any
confidential data and are used by the ROM before the CSF is processed. Therefore, these data structures
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
6 NXP Semiconductors
Encrypted boot implementation
remain in plaintext and are included in the digital signature. This allows the boot ROM to access the
necessary pointers to initialize the data structures and modules required by HAB.
The encryption part of step 2 is straightforward. By adding two new commands to the CSF, the CST
continues to generate the digital signature and produces a DEK to encrypt the boot image. Figure 2
shows the process of the boot image encryption.
The third step generates a secure blob using on-chip private keys. This security measure ensures that this
specific chip is the only chip that can encrypt and decrypt the blob. However, CAAM is the only
component with access to the OTP master keys. NXP provides specialized tools for DEK blob
generation through the NXP U-Boot port. Finally, the CSF and the DEK blob are appended to the
encrypted image.
The following sections describe steps 2 and 3 in more detail. For a step-by-step guide of step 1, see
Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using HABv4 (document AN4581).
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 7
Encrypted boot implementation
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
8 NXP Semiconductors
Encrypted boot implementation
The previous security layer anticipates the use of a contract manufacturer by the OEM. A good security
practice is to never share passwords. Therefore, the intent for the contract manufacturer is to provide the
OEM with a public key. The OEM encrypts the DEK and sends it to the manufacturer, which can
decrypt the DEK with the corresponding private key. If a contract manufacturer is not used, then the CA
key (generated for the authenticated boot by the CST) can be used for this purpose.
Because the DEK generated by the CST is in plaintext, the OEM can operate on it. If the DEK is
encrypted by the public key generated above, the DEK can be obtained using this OpenSSL command:
openssl cms -decrypt -in dek_in.bin -inform DER -out dek_out.dec –binary -inkey
private_key.pem
Where:
• dek_in.bin is the DEK protected with the public key dek_rsa_key.pem.
• dek_out.bin is the plaintext DEK.
• private_key is the private key corresponding to the public key given to the CST.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 9
Encrypted U-Boot example
Parameters:
tag: constant-identifying HAB data structure HAB_TAG_WRP = 0x81
len: structure length in 8-bit
par: constant value HAB Version = 0x41
mode: constant value HAB_MODE_CCM = 0x66
alg: constant value HAB_ALG_AES = 0x55
size: unwrapped key value size in bytes
flg: key flags
data: encrypted key value
enc blob key: encrypted blob key
MAC: Message Authentication Code
The DEK blob utility builds this structure from a given DEK. Notice that the HAB supports a set of
encryption algorithms, but the encrypted boot protocol expects AES. The key length is a variable; it can
be 128-bit, 192-bit, or 256-bit.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
10 NXP Semiconductors
Encrypted U-Boot example
PADDING
4.1. Assumptions
When designing the U-Boot image as an encrypted boot solution, there are three assumptions which
accelerate and simplify the construction process.
• The U-Boot image can be built for multiple board configurations. For demonstration purposes,
this example uses the i.MX 6Quad processor. For other boards, use the associated configuration
file to build the U-Boot and see the reference manual of the particular chip to write the fuses.
• The user is familiar with the secure configuration for the U-Boot and can properly sign and boot
a U-Boot image.
• The encrypted image is constructed by an individual party, and there is no need to worry about
provisioning the DEK.
4.2. Requirements
The components required to build an encrypted image are shown below. Note that the majority of these
components are the product of this U-Boot image signing procedure:
• The OpenSSL library is installed:
— sudo apt-get install libssl-dev
• The CST is in the encryption mode:
— To build the CST in the encryption mode, run these commands:
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 11
Encrypted U-Boot example
NOTE
The CST is not in the encryption mode by default. This feature must be
enabled before encrypting the bootloader image. The performance of the
CST may be affected due to its dependency on the host entropy. See the
CST User Guide for more details.
• The i.MX 6Quad SabreSD device is in a secure mode.
• The U-Boot image with the secure boot and encrypted boot support (with the blob generation tool)
is enabled:
— To configure the U-Boot to be built with secure boot support, CONFIG_SECURE_BOOT
must be defined in the board header file:
– For older U-Boot versions (v2016.09 and lower): Uncomment or add
CONFIG_SECURE_BOOT to the board configuration header (in
include/configs/mx6sabre_common.h).
– Newer U-Boot versions (since v2016.11): Add CONFIG_SECURE_BOOT=y into the
board configuration file (in configs/mx6qsabresd_defconfig) or select it in the U-Boot
configuration menu:
➔ Arm architecture → Check “Support i.MX HAB features”.
— To configure the U-Boot to be built with encrypted boot support, follow these steps
(depending on the BSP release):
– imx_v2016.03_04.1.15_2.0.0_ga and older: define these configurations in the board
header file (in include/configs/mx6sabre_common.h):
• CONFIG_SYS_FSL_SEC_COMPAT 4 /* HAB version */.
• CONFIG_FSL_CAAM.
• CONFIG_CMD_DEKBLOB.
• CONFIG_SYS_FSL_LE.
– imx_v2017.03_4.9.11_1.0.0_ga: Select CONFIG_SECURE_BOOT in
Kconfig/defconfig.
– imx_v2017.03_4.9.88_2.0.0_ga and newer: Select CONFIG_CMD_DEKBLOB in
Kconfig/defconfig.
• Signed U-Boot image:
— U-Boot image with the CSF and digital signature attached.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
12 NXP Semiconductors
Encrypted U-Boot example
4.3. Implementation
Many different implementations to construct an encrypted U-boot image are possible. The right
implementation depends on the solution’s requirements. The presented implementation provides the
foundation principles; it can be modified to meet different needs. Appendix A, “Development scripts”
provides a list of scripts to automate this implementation.
• Verification index—the index of the master key used in the encryption algorithm.
• Target index—the index of the key storage that holds the new key.
• Key—path to the DEK file generated by the CST.
• Key length—the length of the key for the AES algorithm. Possible lengths are 128-bit, 192-bit,
and 256-bit.
• Blob address—the address in RAM where the DEK blob is loaded.
It is recommended to append the blob to the U-Boot image in the same way as the CSF was appended.
The reason for padding the CSF is that the blob can be stored at a known location, which is used to
compute the blob address in the RAM.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 13
Encrypted U-Boot example
NOTE
This implementation forces the total size of the encrypted image (boot data
structures, U-Boot code, CSF, and DEK blob) to be lesser than (or equal
to) the image size specified in the boot data.
The DEK blob is placed at the end of the padded CSF in the final encrypted boot image. Thus, the blob
address can be calculated as follows:
Blob Address = IVT start address + u-boot size + Padded CSF size (0x2000)
IVT start address = 0x177ff400
u-boot size = 0x55c00
• Verification index—the index of the master key used in the encryption algorithm.
• Mac bytes—the length of BLOB_MAC; supported lengths are 4, 8, and 16 bytes.
• <address>—the location in the device’s RAM where the data are loaded.
• <offset>—the offset into the image file to start the decryption.
• <size>—the size of the decrypted data.
• <file>—the path to the image file.
With the current implementation of the CST, it is not possible to construct a CSF that can sign the
encrypted boot image which then can be authenticated by the HAB before decryption, because the HAB
interprets the CSF commands serially (and the other way round—encrypt a signed boot image). Due to
this constraint, the CSF is split into two:
• Case 1, encrypt signed U-Boot—the first one is used to sign the boot image and the second one is
used to encrypt the signed image (except for the header) and create the DEK.
• Case 2, sign encrypted U-Boot—the first one is used to encrypt the boot image and create the
DEK and the second one is used to sign the encrypted image including the boot data structures.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
14 NXP Semiconductors
Encrypted U-Boot example
Verification index = 2
Verification index = 2
Verification index = 0
Target Index = 0
Key = “dek.bin”
• Verification index—the index of the master key used in the encryption algorithm.
• Target index—the index of the key storage to hold the new key.
• Key—the path to the DEK file generated by the CST.
• Key length—the length of the key for the AES algorithm. The possible lengths are 128-bit,
192-bit, and 256-bit.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 15
Encrypted U-Boot example
Verification index = 0
Mac Bytes = 16
• Verification index—the index of the master key used in the encryption algorithm.
• Mac bytes—the length of the MAC. The supported lengths are 4, 8, and 16 bytes.
• <address>—the location where the data is loaded into the device’s RAM.
• <offset>—the offset into the image file to start decrypting.
• <size>—the size to decrypt the data.
• <file>—the path to the image file.
Verification index = 2
Verification index = 0
Target Index = 0
Key = “dek.bin.dummy”
Key Length = 192
Blob Address = 0x17857000
• Verification index—the index of the master key used in the encryption algorithm.
• Target index—the index of the key storage to hold the new key.
• Key—the path to the DEK file generated by the CST.
• Key length—the length of the key for the AES algorithm. The possible lengths are 128-bit,
192-bit, and 256-bit.
• Blob address—the address in RAM where the DEK blob is loaded.
[Decrypt Data]
Verification index = 0
Mac Bytes = 16
Blocks = <address> <offset> <size> <file>,
0x17800000 0xc00 0x55000 “u-boot-dtb.imx.dummy”
• Verification index—the index of the master key used in the encryption algorithm.
• Mac bytes—the length of the MAC; the supported lengths are 4, 8, and 16 bytes.
• <address>—the location where the data is loaded into the device’s RAM.
• <offset>—the offset into the image file to start decrypting.
• <size>—the size to decrypt the data.
• <file>—the path to the image file.
When the [Decrypt Data] command is compiled by the CST, it encrypts the data blocks in place of the
given files using DEK and generates the IMAGE_MAC data which is appended to the CSF. The CST
also generates the nonce used for the encryption. Because only the CSF binary generated by this CSF is
used by the HAB, the Nonce/IMAGE_MAC data must be swapped with the one from the first CSF
because the encrypted image and the DEK from the first CSF are used. This involves another step in the
encrypted boot process before the encrypted boot image is assembled for booting onto the chip.
Both CSFs for this example are shown in Appendix B.2, “Encrypted U-Boot CSF example”.
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 17
Encrypted U-Boot example
NOTE
At this point, the u-boot-dtb.imx file is almost entirely replaced by its
encrypted version and the dek.bin file is created (plaintext/encrypted) in
the given path.
4. Generate the CSF to sign the encrypted boot image, similar to that in Appendix B.2, “Encrypted
U-Boot CSF example”. The address and offset depend on the generated keys and the size of the
u-boot-dtb.imx file.
5. Sign the encrypted U-Boot including the boot data structures from Step 3 and encrypt a dummy
U-Boot by providing the CSF to the CST.
./cst --o csf_sign_enc.bin --i u-boot_sign_enc.csf
6. Swap the Nonce/IMAGE_MAC from csf_enc.bin to csf_sign_enc.bin.
— Calculate the Nonce/IMAGE_MAC size based on the MAC bytes’ value in the CSF.
Mac Bytes = 16, thus,
Nonce/MAC size = 12 (Nonce size) + 16 (MAC bytes) + 8 (CSF header for Nonce/MAC) =
36
— Calculate the Nonce/IMAGE_MAC offset in the CSF.
MAC offset = csf_enc.bin size – Nonce/MAC size = 3972 – 36 = 3936
— Extract Nonce/IMAGE_MAC from csf_enc.bin.
dd if=csf_enc.bin of=noncemac.bin bs=1 skip=3936 count=36
— Replace IMAGE_MAC from csf_enc.bin to csf_sign_enc.bin.
dd if=noncemac.bin of=csf_sign_enc.bin bs=1 seek=3936 count=36
7. Pad the CSF to 0x2000. The reason is that it provides a known address for the blob to be stored
to. Check that the known address is the same as that specified in the CSF.
objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0xff csf_sign_enc.bin
csf_sign_enc_padded.bin
8. Assemble u-boot_encrypted_no_dek.bin, which is the append of the U-Boot image and the
obtained CSF:
cat u-boot-dtb.imx csf_sign_enc_padded.bin > u-boot_encrypted_no_dek.bin
9. (Optional) If dek.bin is obfuscated for manufacturing purposes, the DEK must be decrypted. The
U-Boot port provides the tools to generate a DEK blob using a DEK in plaintext. To use the
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
18 NXP Semiconductors
Encrypted U-Boot example
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 19
References
an error. A substitute encrypted boot image is neither decrypted nor executed. This ensures
cryptographic separation of private blob types during the boot process and thereafter, avoiding any
modification or replacement of DEK blobs.
NOTE
To enable the command used to set this bitfield in U-Boot, the U-Boot
must be built with a custom KConfig. For more information, see Appendix
A.4, “Provisioning the PRIBLOB setting on the chip”.
NOTE
In the i.MX 7ULP, i.MX 7D, i.MX 6SoloX, and i.MX 6UL devices, the
CAAM registers may be reset to suspend and resume operation. If
deploying an encrypted boot environment using these devices, the
PRIBLOB settings must be restored to ensure that the cryptographic
separation of the private blob types is still valid.
The reference steps to set the PRIBLOB bitfield are described in Appendix A.4, “Provisioning the
PRIBLOB setting on the chip”.
5. References
• i.MX 6 Reference Manual and Security Reference Manual
• i.MX 7 Reference Manual and Security Reference Manual
• HAB CST User Guide available in the Code Signing Tool package downloadable from
www.nxp.com (search for CST_TOOL).
• Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX7 Series using HABv4 (document AN4581).
• High-Assurance Boot Version 4 Application Programming Interface Reference Manual available
in the Code Signing Tool package.
— CONFIG_SYS_FSL_LE.
— imx_v2017.03_4.9.11_1.0.0_ga: Select CONFIG_CMD_DEKBLOB in
Kconfig/defconfig.
— imx_v2017.03_4.9.88_2.0.0_ga and newer: Select CONFIG_CMD_DEKBLOB in
Kconfig/defconfig.
#!/bin/bash
uboot_dir="<u-boot-imx location>"
output_dir="$uboot_dir/output"
output_uboot="$output_dir/uboot"
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
target="mx6qsabresd_config"
cd $uboot_dir
if [[ ! -e $output_dir ]]
then
mkdir $output_dir
fi
if [[ ! -e $output_uboot ]]
then
mkdir $output_uboot
fi
make mrproper
make O=$output_uboot distclean
make O=$output_uboot $target
make O=$output_uboot
uboot_dir="<u-boot-imx location>"
output_dir="$uboot_dir/output"
output_uboot="$output_dir/uboot"
output_signed="$output_dir/signed_uboot"
cst_dir="<cst package location>"
cst_signed_uboot="$cst_dir/sig_u-boot"
target_dir="$output_signed/boards/mx6q"
if [[ ! -d $target_dir ]]
then
mkdir –p $target_dir
fi
if [[ ! -d $output_signed ]]
then
mkdir $output_signed
fi
if [[ ! -d $cst_signed_uboot ]]
then
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 21
References
mkdir $cst_signed_uboot
fi
cp $output_uboot/u-boot-dtb.imx $cst_signed_uboot
cd $cst_signed_uboot
#Get the u-boot image
uboot_dir="<u-boot-imx location>"
output_dir="$uboot_dir/output"
output_uboot="$output_dir/uboot"
output_encrypted="$output_dir/encrypted_uboot"
cst_dir="<cst package location>"
cst_enc_uboot=”$cst_dir/enc_u-boot”
target_dir="$output_encrypted/boards/mx6q"
if [[ ! -d $output_encrypted ]]
then
mkdir $output_encrypted
fi
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
22 NXP Semiconductors
References
if [[ ! -d $target_dir ]]
then
mkdir –p $target_dir
fi
if [[ ! -d $cst_enc_uboot ]]
then
mkdir $cst_enc_uboot
fi
#Padded CSF
objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0xff csf_sign_enc.bin
csf_sign_enc_pad.bin
cp dek.bin $target_dir
cp u-boot-dtb.imx $target_dir
cp csf_sign_enc_pad.bin $target_dir
touch dek_blob.bin
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 23
References
When the data encryption key (dek.bin) is on the target, the dek_blob utility in the U-Boot can be used
to create a DEK blob. The resulting blob information can be copied to the dek_blob.bin file created on
the host machine.
• On the target:
=> dek_blob 0x17870000 0x17871000 128
Write the dek_blob.bin file to the SD card using the fatwrite command. It is enabled by selecting
CONFIG_CMD_FAT in “Kconfig for u-boot BSP imx_v2018.03” (and higher). For older BSPs, add
CONFIG_FAT_WRITE manually into the BOARDNAME.h file.
• On the target:
=> fatwrite mmc 1:1 0x17871000 dek_blob.bin 0x48
target_dir="$output_encrypted/boards/mx6q"
if [[ ! -d $target_dir ]]
then
mkdir –p $target_dir
fi
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
24 NXP Semiconductors
References
cp dek_blob.bin $target_dir
cd $cst_enc_uboot
#Concatenate encrypted u-boot, csf
cat u-boot-dtb.imx csf_sign_enc_pad.bin > u-boot_encrypted_no_dek.bin
#Pad binary
objcopy -I binary -O binary --pad-to 0x57c00 --gap-fill=0x00 u-boot_encrypted_no_dek.bin u-
boot_encrypted_no_dek_padded.bin
#Concatenate binary and dek
cat u-boot_encrypted_no_dek_padded.bin dek_blob.bin > u-boot_encrypted.bin
cp u-boot_encrypted.bin $target
#Download to SD card
sudo dd if=u-boot_encrypted.bin of=/dev/sd<partition> bs=512 seek=2 conv=fsync
Appendix B. Troubleshooting
[Install SRK]
File = "../crts/SRK_1_2_3_4_table.bin"
Source index = 0
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 25
References
[Install CSFK]
File = “../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Install Key]
Verification index = 0
Target index = 2
File = "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate Data]
Verification index = 2
Blocks = 0x177ff400 0x000 0x55c00 "u-boot-dtb.imx"
[Header]
Version = 4.1
Hash Algorithm = sha256
Engine Configuration = 0
Certificate Format = X509
Signature Format = CMS
Engine = CAAM
[Install SRK]
File = "../crts/SRK_1_2_3_4_table.bin"
Source index = 0
[Install CSFK]
File = “../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Install Key]
Verification index = 0
Target index = 2
File = "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate Data]
Verification index = 2
Blocks = 0x177ff400 0x000 0xc00 "u-boot-dtb.imx"
[Decrypt Data]
Verification index = 0
Mac Bytes = 16
Blocks = 0x17800000 0xc00 0x55000 "u-boot-dtb.imx"
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
26 NXP Semiconductors
References
[Header]
Version = 4.1
Hash Algorithm = sha256
Engine Configuration = 0
Certificate Format = X509
Signature Format = CMS
Engine = CAAM
[Install SRK]
File = "../crts/SRK_1_2_3_4_table.bin"
Source index = 0
[Install CSFK]
File = “../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Install Key]
Verification index = 0
Target index = 2
File = "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate Data]
Verification index = 2
Blocks = 0x177ff400 0x000 0x55c00 "u-boot-dtb.imx"
[Decrypt Data]
Verification index = 0
Mac Bytes = 16
Blocks = 0x17800000 0xc00 0x55000 "u-boot-dtb.imx.dummy"
Encrypted Boot on HABv4 and CAAM Enabled Devices, Application Note, Rev. 0, 11/2018
NXP Semiconductors 27
How to Reach Us: Information in this document is provided solely to enable system and software
implementers to use NXP products. There are no express or implied copyright licenses
Home Page: granted hereunder to design or fabricate any integrated circuits based on the
www.nxp.com information in this document. NXP reserves the right to make changes without further
Web Support: notice to any products herein.
www.nxp.com/support
NXP makes no warranty, representation, or guarantee regarding the suitability of its
products for any particular purpose, nor does NXP assume any liability arising out of
the application or use of any product or circuit, and specifically disclaims any and all
liability, including without limitation consequential or incidental damages. “Typical”
parameters that may be provided in NXP data sheets and/or specifications can and do
vary in different applications, and actual performance may vary over time. All operating
parameters, including “typicals,” must be validated for each customer application by
customer’s technical experts. NXP does not convey any license under its patent rights
nor the rights of others. NXP sells products pursuant to standard terms and conditions
of sale, which can be found at the following address:
www.nxp.com/SalesTermsandConditions.
While NXP has implemented advanced security features, all products may be subject to
unidentified vulnerabilities. Customers are responsible for the design and operation of
their applications and products to reduce the effect of these vulnerabilities on
customer’s applications and products, and NXP accepts no liability for any vulnerability
that is discovered. Customers should implement appropriate design and operating
safeguards to minimize the risks associated with their applications and products
NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD,
COOLFLUX, EMBRACE, GREENCHIP, HITAG, I2C BUS, ICODE, JCOP, LIFE VIBES,
MIFARE, MIFARE CLASSIC, MIFARE DESFire, MIFARE PLUS, MIFARE FLEX,
MANTIS, MIFARE ULTRALIGHT, MIFARE4MOBILE, MIGLO, NTAG, ROADLINK,
SMARTLX, SMARTMX, STARPLUG, TOPFET, TRENCHMOS, UCODE, Freescale, the
Freescale logo, AltiVec, C‑5, CodeTEST, CodeWarrior, ColdFire, ColdFire+, C‑Ware,
the Energy Efficient Solutions logo, Kinetis, Layerscape, MagniV, mobileGT, PEG,
PowerQUICC, Processor Expert, QorIQ, QorIQ Qonverge, Ready Play, SafeAssure, the
SafeAssure logo, StarCore, Symphony, VortiQa, Vybrid, Airfast, BeeKit, BeeStack,
CoreNet, Flexis, MXC, Platform in a Package, QUICC Engine, SMARTMOS, Tower,
TurboLink, and UMEMS are trademarks of NXP B.V. All other product or service names
are the property of their respective owners. AMBA, Arm, Arm7, Arm7TDMI, Arm9,
Arm11, Artisan, big.LITTLE, Cordio, CoreLink, CoreSight, Cortex, DesignStart,
DynamIQ, Jazelle, Keil, Mali, Mbed, Mbed Enabled, NEON, POP, RealView,
SecurCore, Socrates, Thumb, TrustZone, ULINK, ULINK2, ULINK-ME, ULINK-PLUS,
ULINKpro, µVision, Versatile are trademarks or registered trademarks of Arm Limited
(or its subsidiaries) in the US and/or elsewhere. The related technology may be
protected by any or all of patents, copyrights, designs and trade secrets. All rights
reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. The
Power Architecture and Power.org word marks and the Power and Power.org logos and
related marks are trademarks and service marks licensed by Power.org.