我處理同樣的問題兩年前GPShell和金雅拓卡(不是很確定,如果我得到0x6A80,但可能是) - 如果我沒有記錯,GPShell使用錯誤的多樣化數據新的鍵和(這是糟糕的)錯誤KEK爲put_sc_key
命令-keyDerivation
選項。
也許這是固定的上游 - 你可能要考慮嘗試最新的SVN版本(更新:I was told that the problem is fixed now)。
那段時間我用來對付SVN版本以下醜陋修改419:
--- globalplatform/src/globalplatform.c (revision 419)
+++ globalplatform/src/globalplatform.c (working copy)
@@ -61,6 +61,10 @@
#ifndef MAX_PATH
#define MAX_PATH 257
#endif
+
+static BYTE savedKEK[16];
+
+
static BYTE C_MACDerivationConstant[2] = {0x01, 0x01}; //!< Constant for C-MAC session key calculation.
static BYTE ENCDerivationConstant[2] = {0x01, 0x82};//!< Constant for encryption session key calculation.
@@ -3309,6 +3313,15 @@
OPGP_LOG_START(_T("VISA2_derive_keys"));
OPGP_LOG_HEX(_T("VISA2_derive_keys: Base Key Diversification Data: "), baseKeyDiversificationData, 10);
+ static BYTE savedBaseKeyDiversificationData[10];
+ if(memcmp(baseKeyDiversificationData, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10)==0) {
+ // In trouble -> patch
+ memcpy(baseKeyDiversificationData, savedBaseKeyDiversificationData, 10);
+ } else {
+ memcpy(savedBaseKeyDiversificationData, baseKeyDiversificationData, 10);
+ }
+
+ OPGP_LOG_HEX(_T("VISA2_derive_keys: Base Key Diversification Data2: "), baseKeyDiversificationData, 10);
/* Key Diversification data VISA 2
KDCAUTH/ENC xxh xxh || IC serial number || F0h 01h ||xxh xxh || IC serial number
@@ -3971,6 +3984,9 @@
OPGP_LOG_MSG(_T("mutual_authentication: S-MAC Session Key: "), secInfo->C_MACSessionKey, 16);
+ if (secInfo->secureChannelProtocol == GP211_SCP01) {
+ memcpy(savedKEK, secInfo->dataEncryptionSessionKey, 16);
+ }
#ifdef OPGP_DEBUG
if (secInfo->secureChannelProtocol == GP211_SCP01) {
OPGP_LOG_HEX(_T("mutual_authentication: Data Encryption Key: "), secInfo->dataEncryptionSessionKey, 16);
@@ -4513,6 +4529,12 @@
OPGP_ERROR_STATUS status;
GP211_SECURITY_INFO gp211secInfo;
mapOP201ToGP211SecurityInfo(*secInfo, &gp211secInfo);
+
+ if(memcmp(KEK, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10)==0) {
+ // In trouble -> patch
+ memcpy(KEK, savedKEK, 16);
+ }
+
memcpy(gp211secInfo.dataEncryptionSessionKey, KEK, 16);
status = put_secure_channel_keys(cardContext, cardInfo, &gp211secInfo, keySetVersion, newKeySetVersion,
NULL, new_encKey, new_macKey, new_KEK);
,與此腳本爲我工作:
mode_201
....skipped...
open_sc -security 3 -keyind 0 -keyver 0 -key <motherKey> -keyDerivation visa2
put_sc_key -scp 1 -keyver 1 -newkeyver 1 -key <newMotherKey> -keyDerivation visa2 -current_kek 00000000000000000000000000000000
如果我沒有記錯以及補丁執行以下操作:
您可以考慮使用其他工具(GlobalPlatformPro?),但我不知道它是否支持PUT KEY鑰匙多樣化(沒試過)。
祝你好運!
EDIT>關於阻止我的名片用於進一步開發部分
此方法(大概)改變ISD密鑰,這在大多數情況下(即在沒有其他SD到位)保護訪問卡管理
我敢打賭,你的卡最初有知名的Java卡的默認密鑰是地方 - 並通過改變這些默認鍵一些其他強值可以防止黑客知道這些默認鍵值從認證到您的卡(強調強意味着你應該避免使用像0102030405..
鍵)
改變按鍵其實沒有阻止實體知道新密鑰從管理卡內容 - 與您c的密鑰隨意管理卡片。這個想法是,你是唯一一個能夠訪問鍵
改變(I)SD鍵來改變由GPSystem.getSecureChannel()
使用的密鑰,如果您的小程序使用它
的唯一方法(我意識到)阻止卡進行進一步管理,同時保留加載的小程序功能是通過嘗試約10次驗證失敗來阻止(I)SD訪問 - 因爲大多數卡在此情況下阻止訪問(I)SD (你的旅費可能會改變)。我不會推薦這種方式。
_他想阻止卡進一步發展_,所以,他爲什麼不簡單地更改身份驗證密鑰? – Abraham
@Abraham我明白,OP試圖用GPShell更改認證密鑰,但它不起作用。我敢打賭,正在使用的KEK/DEK是錯誤的(因爲GPShell bug)和KCV不匹配。 – vlp