0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

AMD MPSoC R5 AES示例

jf_pJlTbmA9 ? 來源:jf_pJlTbmA9 ? 作者:jf_pJlTbmA9 ? 2023-07-10 16:56 ? 次閱讀

測試環(huán)境

測試單板
ZCU106

測試工具
Vitis 2021.2

R5 AES 測試流程

創(chuàng)建Platform
在Vitis的 “File - New ” 中,選擇“Platform Project”, 指定名稱如“zcu106_r5”, 再選擇對應(yīng)的XSA文件和 Processor 如 “psu_cortexr5_0”。

使能AES庫

1. 打開hw_platform工程。

2. 雙擊“platform.spr”文件。

3. 雙擊“psu_cortexr5_0”的 “board support package”。

4. 點擊 “Modif BSP Settings”。

5. 在“Supported Libraries”中選擇xilsecure。

100570888-302272-01.png
100570888-302273-02.png

導(dǎo)入AES示例

1. 打開hw_platform工程。

2. 雙擊“platform.spr”文件。

3. 雙擊“psu_cortexr5_0”的 “board support package”。

4. 等待Libraries窗口顯示

5. 點擊xilsecure行右邊的import examples

6. 選擇"xilsecure_aes_example"

100570888-302274-03.png
100570888-302275-04.png

定制

導(dǎo)入example, 創(chuàng)建的工程里有文件xilsecure_aes_example.c。 打開文件,確認AES 密鑰和數(shù)據(jù)地址。

AES密鑰

AES密鑰如下:

/*
* The hard coded aes key for decryption, in case user given key is being used
* it will be loaded in KUP before decryption
*/
static const u8 CsuKey[] = {
0xf8, 0x78, 0xb8, 0x38, 0xd8, 0x58, 0x98, 0x18,
0xe8, 0x68, 0xa8, 0x28, 0xc8, 0x48, 0x88, 0x08,
0xf0, 0x70, 0xb0, 0x30, 0xd0, 0x50, 0x90, 0x10,
0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00
};

/*
* The hard coded iv used for decryption secure header and block 0
*/
u8 CsuIv[] = {
0xD2, 0x45, 0x0E, 0x07, 0xEA, 0x5D, 0xE0, 0x42, 0x6C, 0x0F, 0xA1, 0x33,
0x00, 0x00, 0x00, 0x00
};

內(nèi)存地址

默認保存密文和明文的內(nèi)存地址都是0x04000000,需要和代碼中的地址對應(yīng),可以根據(jù)自己需要更改。

static u32 ImageOffset = 0x04000000;
static u32 DestinationAddr = 0x04000000;

創(chuàng)建密文

AMD提供工具bootgen,加密數(shù)據(jù),創(chuàng)建密文。

bootgen的配置文件user_data_example.bif如下:

the_ROM_image:
{
[keysrc_encryption]kup_key
[encryption=aes, aeskeyfile=user_data_kup_key_example.nky, load=0x04000000]data.bin
}

上面的data.bin是明文文件; user_data_kup_key_example.nky是AES的密鑰。如果不存在AES的密鑰, 工具bootgen會自動生成密鑰。 生成密鑰后,需要更新文件xilsecure_aes_example.c。

在“Xilinx Software Command Line Tool 2021.2”中執(zhí)行命令,“ bootgen -arch zynqmp -p userdata -image user_data_example.bif -o data.bin.enc -w on -log error”,可以得到密文文件data.bin.enc。

xsct% bootgen -arch zynqmp -p userdata -image user_data_example.bif -o data.bin.enc -w on -log error
WARNING: [Common 17-259] Unknown Tcl command 'bootgen -arch zynqmp -p userdata -image user_data_example.bif -o data.bin.enc -w on -log error' sending command to the OS shell for execution. It is recommended to use 'exec' to send the command to the OS shell.

****** Xilinx Bootgen v2021.2
**** Build date : Oct 19 2021-03:13:27
** Copyright 1986-2021 Xilinx, Inc. All Rights Reserved.

[INFO] : Bootimage generated successfully

運行AES

以調(diào)試模式運行工程xilsecure_aes_example_1。當(dāng)Vitis SDK停在main()入口時,在xsct界面里下載密文到0x4000000。下載完成后,再繼續(xù)運行xilsecure_aes_example_1。 運行完XSecure_AesDecrypt()后,暫停程序,顯示存儲器0x4000000的內(nèi)容,可以看到它的內(nèi)容和明文的16進制值一樣。

AES解碼成功。

xsct%

Info: Cortex-R5 #0 (target 6) Stopped at 0x0 (Suspended)

Downloading Program -- C:/prj/zcu102/v212/vitis_space_r5_csu2/xilsecure_aes_example_1/Debug/xilsecure_aes_example_1.elf
section, .vectors: 0x00000000 - 0x00000467
.................
section, .stack: 0x001044f0 - 0x00107cef
0% 0MB 0.0MB/s ??:?? ETA
100% 0MB 0.5MB/s 00:00
Setting PC to Program Start Address 0x000001d0
Successfully downloaded C:/prj/zcu102/v212/vitis_space_r5_csu2/xilsecure_aes_example_1/Debug/xilsecure_aes_example_1.elf
Info: Cortex-R5 #0 (target 6) Running
Info: Cortex-R5 #0 (target 6) Stopped at 0x1001b8 (Breakpoint)
main() at ../src/xilsecure_aes_example.c: 123
123: Status = SecureAesExample();

xsct% dow -data data.bin.enc 0x04000000
0% 0MB 0.0MB/s ??:?? ETA
100% 0MB 0.4MB/s 00:00

Successfully downloaded C:/prj/zcu102/v212/vitis_space_r5_csu2/xilsecure_aes_example_1/data.bin.enc
xsct% Info: Cortex-R5 #0 (target 6) Running
xsct% Info: Cortex-R5 #0 (target 6) Stopped at 0x100204 (Step)
SecureAesExample() at ../src/xilsecure_aes_example.c: 153
153: u8 *Dst = (u8 *)(UINTPTR)DestinationAddr;
xsct% Info: Cortex-R5 #0 (target 6) Running
xsct% Info: Cortex-R5 #0 (target 6) Stopped at 0x100214 (Step)
....................
xsct% Info: Cortex-R5 #0 (target 6) Stopped at 0x100370 (Breakpoint)
189: Status = XSecure_AesDecrypt(&Secure_Aes, Dst,
xsct% Info: Cortex-R5 #0 (target 6) Running
xsct% Info: Cortex-R5 #0 (target 6) Stopped at 0x10038c (Step)
194: if(Status != XST_SUCCESS)

xsct% mrd 0x04000000
4000000: 6D783F3C

xsct% mrd 0x04000000 20
4000000: 6D783F3C
4000004: 6576206C
4000008: 6F697372
400000C: 31223D6E
4000010: 2022302E
4000014: 6F636E65
4000018: 676E6964
400001C: 5455223D
4000020: 22382D46
4000024: 61747320
4000028: 6C61646E
400002C: 3D656E6F
4000030: 226F6E22
4000034: 0A0D3E3F
4000038: 69663F3C
400003C: 6556656C
4000040: 6F697372
4000044: 2E34206E
4000048: 3F302E30
400004C: 70633C3E
xsct%


審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • amd
    amd
    +關(guān)注

    關(guān)注

    25

    文章

    5369

    瀏覽量

    133373
  • AES
    AES
    +關(guān)注

    關(guān)注

    0

    文章

    99

    瀏覽量

    33143
  • MPSoC
    +關(guān)注

    關(guān)注

    0

    文章

    194

    瀏覽量

    24190
  • Vitis
    +關(guān)注

    關(guān)注

    0

    文章

    145

    瀏覽量

    7312
收藏 人收藏

    評論

    相關(guān)推薦

    為什么要接上拉電阻R5???

    接上拉電阻R5是因為芯片IO口開漏輸出要求嗎?還有沒有其他原因?
    發(fā)表于 10-31 21:07

    R5作用是什么

    R5作用是什么
    發(fā)表于 11-21 17:42

    AD9742 R4和R5的作用是什么?

    請教各位前輩,R4和R5的作用,以及添加DVDD的作用
    發(fā)表于 12-18 07:18

    WCDMA中的R5版本

    新獲取移動網(wǎng)絡(luò)運營牌照的運營商,其決定部署UMTS網(wǎng)絡(luò)是面臨的第一個問題就是選擇標(biāo)準(zhǔn)的哪一個版本。3GPP WCDMA標(biāo)準(zhǔn)歷經(jīng)多年的努力,目前已有R99,R4,R5三個版本完成定稿,其中
    發(fā)表于 06-20 08:45 ?2334次閱讀

    BUFFALO HD-H1.OTGL/R5網(wǎng)絡(luò)存儲器評測

    BUFFALO HD-H1.OTGL/R5網(wǎng)絡(luò)存儲器評測
    發(fā)表于 11-03 18:28 ?19次下載

    AMD推出R9 3900和R5 3500X兩款處理器

    根據(jù)消息報道,AMD昨天正式發(fā)布了R9 3900和R5 3500X這兩款處理器,其中R5 3500X為中國獨占。
    的頭像 發(fā)表于 10-09 15:51 ?6141次閱讀

    AMD R5 4500U處理器跑分曝光,多核比i5-1035G1領(lǐng)先8%

    在1月份的CES 上,AMD 推出了新款的7nm移動低壓處理器,其中R5 有兩個版本,分別是6核6線程的R5 4500U和6核12線程的R5 4600U?,F(xiàn)在,搭載
    的頭像 發(fā)表于 02-03 16:42 ?14.3w次閱讀
    <b class='flag-5'>AMD</b> <b class='flag-5'>R5</b> 4500U處理器跑分曝光,多核比i<b class='flag-5'>5</b>-1035G1領(lǐng)先8%

    佳能EOS R5和索尼A7R4的對比,高畫質(zhì)之間的對決

    佳能EOS R5,最新一代的全畫幅無反相機,由于它的視頻能力太強大,因此被大家先入為主。實際上,佳能EOS R5主要還是一款高像素、高畫質(zhì)相機,4500萬像素讓它和尼康Z7、松下S1R處于同一像素
    的頭像 發(fā)表于 09-07 14:57 ?1.6w次閱讀

    AMD R5 5600X 最新跑分:單核性能超 i9-10900K

    AMD R5 5600X 是首批上市 Ryzen 5000 系列處理器中規(guī)格最低的一款,6 核 12 線程,299 美元?,F(xiàn)在,PassMark 網(wǎng)站更新了其 CPU 跑分排名,Ryzen 5
    的頭像 發(fā)表于 10-23 16:46 ?8808次閱讀
    <b class='flag-5'>AMD</b> <b class='flag-5'>R5</b> 5600X 最新跑分:單核性能超 i9-10900K

    AMD R5 5600X 外媒測試出爐:性能大幅提升,功耗溫度更低

    R5 5600X 與 10 核的 i9-10850K、6 核的 R5 3600X 和 i5-10400F 進行了對比。 游戲測試: 溫度和功耗 在功耗測試中,配備 Noctuda NH-D14 散熱器的 Ryzen
    的頭像 發(fā)表于 11-05 17:46 ?1.2w次閱讀

    AMD R5 5500U現(xiàn)身:參數(shù)與4600U一致

    根據(jù)爆料者 @APISAK 的消息,AMD 新一代移動處理器 R5 5500U 已經(jīng)出現(xiàn)在了 Geekbench 中,參數(shù)與 R5 4600U 相同。 如上圖所示,R5 5500 為
    的頭像 發(fā)表于 11-20 10:43 ?4w次閱讀

    銳龍R5和i5哪個好,11代酷睿棋高一著

    銳龍R5和i5哪個好? 不管是選購筆記本還是組裝臺式機時,不少消費者都會在挑選處理器的時候糾結(jié)這個問題。銳龍R5和酷睿i5分別是AMD和英特
    的頭像 發(fā)表于 08-10 14:33 ?19.1w次閱讀
    銳龍<b class='flag-5'>R5</b>和i<b class='flag-5'>5</b>哪個好,11代酷睿棋高一著

    Vivado里關(guān)閉R5/A53/GPU

    在SDK/Vitis里創(chuàng)建FSBL和Standalone程序,啟動后,在XSCT命令后窗口下,檢查R5/A53狀態(tài),可以看到設(shè)置為0的R5/A53的狀態(tài)是No Power。
    的頭像 發(fā)表于 05-09 10:45 ?1737次閱讀

    AMD-Xilinx MPSoC的Watchdog在Linux中使用的簡明教程

    AMD-Xilinx MPSoC的器件里,提供了內(nèi)置的Watchdog
    的頭像 發(fā)表于 07-07 14:15 ?911次閱讀

    Zynq UltraScale+ MPSoC的隔離設(shè)計示例

    電子發(fā)燒友網(wǎng)站提供《Zynq UltraScale+ MPSoC的隔離設(shè)計示例.pdf》資料免費下載
    發(fā)表于 09-13 11:28 ?3次下載
    Zynq UltraScale+ <b class='flag-5'>MPSoC</b>的隔離設(shè)計<b class='flag-5'>示例</b>