<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>
"); //-->

博客專(zhuān)欄

EEPW首頁(yè) > 博客 > 干貨分享 | 一文了解TSMaster中Seed&key的兩種處理方法

干貨分享 | 一文了解TSMaster中Seed&key的兩種處理方法

發(fā)布人:汽車(chē)電子工程師 時(shí)間:2023-09-13 來(lái)源:工程師 發(fā)布文章

在UDS診斷過(guò)程中,會(huì )涉及到安全訪(fǎng)問(wèn)的問(wèn)題,也就是常說(shuō)的Seed&Key。TSMaster中提供了兩種 Seed&Key 的處理方法:第一種是直接加載DLL文件;第二種是直接在TSMaster的編譯器中直接添加安全算法。

一、加載外部 Seed&Key DLL

TSMaster 診斷模塊支持通過(guò) dll 載入 Seed&Key 算法,該算法 dll 跟主流工具的計算接口兼容,接口定義如下圖所示:

1.pngDLL 加載界面如下圖所示:

2.png

【1】 加載 DLL

【2】 刪除 DLL

【3】 DLL 校驗器,通過(guò)此按鈕,用戶(hù)可以判斷自己加載的 dll 接口是否正確,算法是否符合設計要求。如下圖所示:

3.png

如上圖所示界面,用戶(hù)選擇 Seed 的 Level 過(guò)后,輸入 Demo Seed 值,點(diǎn)擊 GenKey 進(jìn)行判斷。如果該 DLL 接口跟模板定義接口統一,則會(huì )輸出提示信息:Generate Key Success,然后用戶(hù)根據 Key 值跟目標值對比,進(jìn)一步確認DLL 中的算法是否符合設計要求。


【4】 打開(kāi) TSMaster 安裝目錄下 Seed&Key 接口工程所在的路徑。用戶(hù)可以拷貝該工程添加自己的 Seed&Key 算法。


默認SeedKey函數接口

目前,要想被 TSMaster 的診斷模塊直接加載,該 DLL 必須實(shí)現如下三種函數接口中的一種:


【1】 接口 1:

unsigned int GenerateKeyEx(

const unsigned char* ipSeedArray, /* Array for the seed [in] */

unsigned int iSeedArraySize, /* Length of the array for the seed [in] */

const unsigned int iSecurityLevel, /* Security level [in] */

const char* ipVariant, /* Name of the active variant [in] */

unsigned char* iopKeyArray, /* Array for the key [in, out] */

unsigned int iMaxKeyArraySize, /* Maximum length of the array for the key [in] */

unsigned int& oActualKeyArraySize); /* Length of the key [out] */


【2】 接口 2:

unsigned int GenerateKeyExOpt(

const unsigned char* ipSeedArray, /* Array for the seed [in] */

unsigned int iSeedArraySize, /* Length of the array for the seed [in] */

const unsigned int iSecurityLevel, /* Security level [in] */

const char* ipVariant, /* Name of the active variant [in] */

const char* iPara, /* */

unsigned char* iopKeyArray, /* Array for the key [in, out] */

unsigned int iMaxKeyArraySize, /* Maximum length of the array for the key [in] */

unsigned int& oActualKeyArraySize) /* Length of the key [out] */


【3】 接口 3:

bool ASAP1A_CCP_ComputeKeyFromSeed(

const unsigned char* ipSeedArray, /* Array for the seed [in] */

unsigned short iSeedArraySize, /* Length of the array for the seed [in] */

unsigned char* iopKeyArray, /* Array for the key [in, out] */

unsigned short iMaxKeyArraySize, /* Maximum length of the array for the key [in] */

unsigned short* opSizeKey) /* Length of the key [out] */


用戶(hù)的 DLL 只要實(shí)現了上述任意一種函數接口,即可直接加載到 TP 層模塊中。如果出現加載失敗,主要檢查如下情況:

1. 是否用 Release 模式發(fā)布,如果是 Debug 模式,常常會(huì )有以上失敗的情況出現。

2. 是否采用 x86 平臺發(fā)布,目前 TSMaster 為支持 X86 的版本,用來(lái)調試的 DLL 也必須為X86 模式。


如何兼容其他函數接口

日常使用中,經(jīng)常出現用戶(hù)已經(jīng)開(kāi)發(fā)好了 dll,如果該 dll的接口不是上述三種中的任何一種,就無(wú)法直接加載到 TSMaster 的診斷模塊中。對于這種情況,推薦采用如下方案來(lái)解決此問(wèn)題:

4.jpg

下面以一個(gè)實(shí)際的實(shí)例來(lái)講解如何兼容用戶(hù)現有的 DLL 文件。


1. 用戶(hù)現有的 DLL,名稱(chēng)為 UserSeedKey.dll。該函數內部的 API 函數有:

? Seed 等級為 1 的時(shí)候,調用函數 void GetKeyFromSeed01(byte* ASeed, byte* AKey);

? Seed 等級為 3 的時(shí)候,調用函數 void GetKeyFromSeed03(byte* ASeed, byte* AKey);

? Seed 等級為 11 的時(shí)候,調用函數 void GetKeyFromSeed11(byte* ASeed, byte* AKey);


該 dll 不支持上述默認加載接口,無(wú)法直接加載到 TSMaster 中使用。因此,需要把這些 DLL 再包裝一層,才能載入到 TSMaster 的診斷模塊中。


2. 選擇 TSMaster 安裝目錄中提供的 GenerateKeyEx 的模板工程,在該工程中調用上述 DLL的函數接口?;舅悸肥牵?/span>

? 采用 Loadlibrary 動(dòng)態(tài)用戶(hù)現有的 dll。

? 根據傳入的 Level 參數,采用 GetProcAddress 函數動(dòng)態(tài)獲取實(shí)際的用于計算 Key 的函數指針。

? 如果獲取函數指針成功,則使用該函數指針傳輸 Seed 值,并計算對應的 Key 值。


詳細調用示例函數如下圖所示:

5.png

3. 該 GenerateKeyEx 工程開(kāi)發(fā)結束后,TSMaster 直接加載 GenerateKeyEx 所在的 dll。需要注意的是,用戶(hù)需要把現有的UserSeedKey.dll 拷貝到TSMaster 根目錄或者GenerateKeyEx.dll 所在的目錄。如果不拷貝過(guò)去,GenerateKeyEx.dll 執行的時(shí)候會(huì )出現找不到對應依賴(lài) dll 的情況,解鎖失敗。


總結: 

在 TSMaster 安裝目錄中,提供了封裝 Seed&Key 算法的模板工程。如 GenerateKeyEx,GenerateKeyExOpt ASAP1A_CCP_ComputeKeyFromSeed,用戶(hù)基于此模板工程開(kāi)發(fā)即可得到能夠直接加載的 dll 函數。

同時(shí),也提供了二次封裝的 dll 的工程,比如 GenerateKeyEx_Wrapper_Demo,該工程演示了如何基于已經(jīng)存在的 SeedKey 算法庫進(jìn)行包裝,生成可以直接加載到 TSMaster 診斷模塊中的 dll 的過(guò)程。

二、采用內置的算法編輯器

基本步驟如下所示:

6.png

注意事項:

【1】 算法函數的接口,TSMaster 目前提供了最常用的接口形式,如果用戶(hù)有自己特殊的接口形式,無(wú)法覆蓋住,請聯(lián)系上海同星把此接口增加到選項中。

7.png【2】 所有的接口函數都定義了返回值 s32。增加此約束,主要是增加函數的嚴謹性。返回值為 0 表示成功,為其他值則有對應的錯誤碼。用戶(hù)在編輯代碼的時(shí)候,最后一行一定不要忘了輸入返回值,否則系統執行函數過(guò)后,會(huì )認為算法執行失敗,不予往后面執行。如下所示:

8.png【3】 添加算法過(guò)后,點(diǎn)擊 OK 退出。TSMaster 內置編譯器會(huì )自動(dòng)解釋該算法,并準備好在執行診斷的過(guò)程中使用。

*博客內容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀(guān)點(diǎn),如有侵權請聯(lián)系工作人員刪除。



關(guān)鍵詞: UDS診斷 Seed&Key TSMaster

相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>