HSM モードを使用した Zynq-7000 SoC デバイス ブート イメージの作成 - 2022.1 日本語

Vitis 統合ソフトウェア プラットフォームの資料: エンベデッド ソフトウェア開発 (UG1400)

Document ID
UG1400
Release Date
2022-04-26
Version
2022.1 日本語

次の図に、 Zynq®-7000 SoC デバイスの HSM モードのブート イメージを示します。この図の後にブート イメージを作成する手順を示します。

図 1. ステージ 0 ~ 8 のブート プロセス

HSM モードを使用して Zynq®-7000 SoC デバイスのブート イメージを作成するプロセスは、次の BIF ファイルを使用して標準フローでブート イメージを作成するのと似ています。これらの例は、必要に応じてハッシュ ファイルを生成するために OpenSSL プログラムを使用します。

all:
{
	[aeskeyfile]my_efuse.nky 
	[pskfile]primary.pem 
	[sskfile]secondary.pem
	[bootloader,encryption=aes,authentication=rsa] zynq_fsbl_0.elf
	[authentication=rsa]system.bit
}

ステージ 0: SPK のハッシュを生成

このステージは、SPK キーのハッシュを生成します。

stage0:
{
	[ppkfile] primary.pub
	[spkfile] secondary.pub
}

Bootgen コマンドは次のとおりです。

bootgen -image stage0.bif –w -generate_hashes

ステージ 1: SPK ハッシュに署名

このステージは SPK ハッシュにサインして署名を作成します。

xil_rsa_sign.exe -gensig -sk primary.pem -data secondary.pub.sha256 -out secondary.pub.sha256.sig
または、OpenSSL プログラムを使用して署名を作成します。
#Swap the bytes in SPK hash
objcopy -I binary -O binary --reverse-bytes=256 secondary.pub.sha256

#Generate SPK signature using OpenSSL
openssl rsautl -raw -sign -inkey primary.pem -in secondary.pub.sha256 > secondary.pub.sha256.sig

#Swap the bytes in SPK signature
objcopy -I binary -O binary --reverse-bytes=256 secondary.pub.sha256.sig

ステージ 2: AES を使用して暗号化

このステージはパーティションを暗号化します。stage2.bif は次のとおりです。

stage2:
{
	[aeskeyfile] my_efuse.nky
	[bootloader, encryption=aes] zynq_fsbl_0.elf
}
Bootgen コマンドは次のとおりです。
bootgen -image stage2.bif -w -o fsbl_e.bin -encrypt efuse
出力は、暗号化されたファイル (fsbl_e.bin) です。

ステージ 3: パーティションのハッシュを生成

このステージは、さまざまなパーティションのハッシュを生成します。

ステージ 3a: FSBL ハッシュを生成

BIF ファイルは次のとおりです。

stage3a:
{
	[ppkfile] primary.pub
	[spkfile] secondary.pub
	[spksignature] secondary.pub.sha256.sig
	[bootimage, authentication=rsa] fsbl_e.bin
}
Bootgen コマンドは次のとおりです。
bootgen -image stage3a.bif -w -generate_hashes

出力は、ハッシュ ファイル (zynq_fsbl_0.elf.0.sha256) です。

ステージ 3b: ビットストリーム ハッシュを生成

このステージの BIF ファイルは次のとおりです。

stage3b:
{
	[ppkfile] primary.pub
	[spkfile] secondary.pub
	[spksignature] secondary.pub.sha256.sig
	[authentication=rsa] system.bit
}
Bootgen コマンドは次のとおりです。
bootgen -image stage3b.bif -w -generate_hashes
出力は、ハッシュ ファイル (system.bit.0.sha256) です。

ステージ 4: ハッシュに署名

このステージは作成したパーティション ハッシュ ファイルから署名を作成します。

ステージ 4a: FSBL パーティション ハッシュに署名
xil_rsa_sign.exe -gensig -sk secondary.pem -data zynq_fsbl_0.elf.0.sha256 -out zynq_fsbl_0.elf.0.sha256.sig
または、OpenSSL プログラムを使用して署名を作成します。
#Swap the bytes in FSBL hash
objcopy -I binary -O binary --reverse-bytes=256 zynq_fsbl_0.elf.0.sha256

#Generate FSBL signature using OpenSSL
openssl rsautl -raw -sign -inkey secondary.pem -in zynq_fsbl_0.elf.0.sha256 > zynq_fsbl_0.elf.0.sha256.sig

#Swap the bytes in FSBL signature
objcopy -I binary -O binary --reverse-bytes=256 zynq_fsbl_0.elf.0.sha256.sig

出力は、署名ファイル (zynq_fsbl_0.elf.0.sha256.sig) です。

ステージ 4b: ビットストリーム ハッシュに署名
xil_rsa_sign.exe -gensig -sk secondary.pem -data system.bit.0.sha256 -out system.bit.0.sha256.sig
または、OpenSSL プログラムを使用して署名を作成します。
#Swap the bytes in bitstream hash
objcopy -I binary -O binary --reverse-bytes=256 system.bit.0.sha256

#Generate bitstream signature using OpenSSL
openssl rsautl -raw -sign -inkey secondary.pem -in system.bit.0.sha256 > system.bit.0.sha256.sig

#Swap the bytes in bitstream signature
objcopy -I binary -O binary --reverse-bytes=256 system.bit.0.sha256.sig
出力は、署名ファイル (system.bit.0.sha256.sig) です。

ステージ 5: パーティションの署名を挿入

上記のステージで作成したパーティションの署名を挿入し、認証証明に変更します。

ステージ 5a: FSBL 署名を挿入

stage5a.bif は次のとおりです。

stage5a:
{
	[ppkfile] primary.pub
	[spkfile] secondary.pub
	[spksignature] secondary.pub.sha256.sig
	[bootimage, authentication=rsa, presign=zynq_fsbl_0.elf.0.sha256.sig] fsbl_e.bin
}
Bootgen コマンドは次のとおりです。
bootgen -image stage5a.bif -w -o fsbl_e_ac.bin -efuseppkbits efuseppkbits.txt -nonbooting
認証された出力ファイルは、fsbl_e_ac.bin および efuseppkbits.txt です。
ステージ 5b: ビットストリーム署名を挿入
stage5b.bif は次のとおりです。
stage5b:
{
	[ppkfile] primary.pub
	[spkfile] secondary.pub
	[spksignature] secondary.pub.sha256.sig
	[authentication=rsa, presign=system.bit.0.sha256.sig] system.bit
}
Bootgen コマンドは次のとおりです。
bootgen -image stage5b.bif -o system_e_ac.bin –nonbooting
認証された出力ファイルは system_e_ac.bin です。

ステージ 6: ヘッダー テーブルのハッシュを生成

このステージは、ヘッダー テーブルのハッシュを生成します。

stage6.bif は次のとおりです。
stage6:
{
	[bootimage] fsbl_e_ac.bin
	[bootimage] system_e_ac.bin
}
Bootgen コマンドは次のとおりです。
bootgen -image stage6.bif -generate_hashes
出力ハッシュ ファイルは ImageHeaderTable.sha256 です。

ステージ 7: ヘッダー テーブル署名を生成

このステージは、ヘッダー テーブル署名を生成します。

xil_rsa_sign.exe -gensig -sk secondary.pem -data ImageHeaderTable.sha256 -out ImageHeaderTable.sha256.sig
または、OpenSSL プログラムを使用して署名を作成します。
#Swap the bytes in header table hash
objcopy -I binary -O binary --reverse-bytes=256 ImageHeaderTable.sha256

#Generate header table signature using OpenSSL
openssl rsautl -raw -sign -inkey secondary.pem -in ImageHeaderTable.sha256 > ImageHeaderTable.sha256.sig

#Swap the bytes in header table signature
objcopy -I binary -O binary --reverse-bytes=256 ImageHeaderTable.sha256.sig
出力は、署名ファイル (ImageHeaderTable.sha256.sig) です。

ステージ 8: パーティションを結合し、ヘッダー テーブル署名を挿入する

stage8.bif は次のとおりです。

stage8:
{
	[headersignature] ImageHeaderTable.sha256.sig
	[bootimage] fsbl_e_ac.bin
	[bootimage] system_e_ac.bin
}
Bootgen コマンドは次のとおりです。
bootgen -image stage8.bif -w -o final.bin
出力は、ブート イメージ ファイル (final.bin) です。