- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正如标题所示,我正在尝试解密来自支持 DUKPT 的扫描仪的 DUKPT 加密轨道数据。
我拥有 DUKPT 的 ANSI 标准 (X9.24),并成功实现了从 KSN 和 BDK 生成 IPEK 的功能。此外,我还成功实现了通过对 PIN 加密 key 进行异或运算来生成左右 MAC 请求和响应 key 的功能。最后,我能够生成 EPB。
从这里开始,我不明白如何从我生成的 L/R key 生成 MAC 请求和响应。
最后,一旦我到达这一步,接下来会发生什么?我什么时候真正拥有可以解密启用 DUKPT 的设备发送的轨道数据的 key ?
我知道 Thales Simulator 和 jPOS。我的代码当前正在引用 Thales Simulator 来完成其所有工作。但是,文件解密过程并没有返回预期的数据。
如果有人可以提供一些解密轨道数据的见解,我们将不胜感激。
最佳答案
我花了太多时间研究可怕的 X9.24 规范,最终通过供应商的示例实现了加密和解密,营销人员立即决定更换供应商。由于它是一个标准,您可能会认为任何人的实现都是相同的。我希望。无论如何,事情的实现方式存在差异。您必须研究细则,以确保您的工作方式与另一方相同。
但这不是你的问题。
首先,如果您需要解密信用卡中的数据轨道,您可能有兴趣生成一个 key ,该 key 将基于原始 super secret 基本派生 key 来解密数据。这与 MAC 一代无关,只是在传递那个可怕的规范时提到的。如果在 HSM 的完整 key 序列号的计数器部分中设置了位,您需要为该 key 序列号和设备 ID 生成 IPEK,并重复应用规范中的“不可逆 key 生成过程”。
我的代码的这一部分如下所示:(很抱歉在帖子中列出了很长的 list 。)
/*
* Bit "zero" set (this is a 21 bit register)(ANSI counts from the left)
* This will be used to test each bit of the encryption counter
* to decide when to find another key.
*/
testBit=0x00100000;
/*
* We have to "encrypt" the IPEK repeatedly to find the current key
* (See Section A.3). Each time we encrypt (generate a new key),
* we need to use the all prior bits to the left of the current bit.
* The Spec says we will have a maximum of ten bits set at any time
* so we should not have to generate more than ten keys to find the
* current encryption key.
*/
cumBits=0;
/*
* For each of the 21 possible key bits,
* if it is set, we need to OR that bit into the cumulative bit
* variable and set that as the KSN count and "encrypt" again.
* The encryption we are using the goofy ANSI Key Generation
* subroutine from page 50.
*/
for(int ii=0; ii<21; ii++)
{
if( (keyNumber&testBit) != 0)
{
char ksr[10];
char eightByte[8]={0};
cumBits |= testBit;
ksn.count=cumBits; /* all bits processed to date */
memcpy(ksr, &ksn,10); /* copy bit structure to char array*/
memcpy(crypt,&ksr[2],8); /* copy bytes 2 through 9 */
/*
* Generate the new Key overwriting the old.
* This will apply the "Non-reversible Key Generation Process"
* to the lower 64 bits of the KSN.
*/
keyGen(&key, &crypt, &key);
}
testBit>>=1;
}
哪里keyNumber 是 ksn 中的当前计数器ksn 是一个 80 位结构,包含来自 HSM 的 80 位 key 序列号crypt 是一个 64 位数据 block ,因为我使用的是 openSSL,所以它的类型为 DES_cblock。key 是一个 128 位双 DES_cblock 结构。keyGen 例程几乎逐字来自规范第 50 页的“不可逆 key 生成过程”本地子例程。
最后,key变量将几乎包含可用于解密的 key 。编写规范的人在 key 中添加了一些“变体”行为,以让我们保持警惕。如果 key 用于解密数据流(例如信用卡磁道),则需要将字节 5 和 13 与 0xFF 进行异或,并使用 Triple DES 自身加密 key (ECB 模式)。我的代码如下所示:
DOUBLE_KEY keyCopy;
char *p;
p=(char*)&key;
p[ 5]^=0xff;
p[13]^=0xff;
keyCopy=key;
des3(&keyCopy, (DES_cblock *)&key.left, &key.left);
des3(&keyCopy, (DES_cblock *)&key.right, &key.right);
如果您使用它来解密 PIN block ,则需要将字节 7 和 15 与 0xFF 进行异或。 (我不是 100% 确定这也不应该应用于流模式,但我的供应商将其排除在外。)
如果是 PIN block ,则会使用 ECB 模式下的 3-DES 进行加密。如果是数据流,则会以CBC模式进行加密,初始化向量为零。
(我有没有提到我不太关心规范?)有趣的是,如果服务器端(上面)记住并拒绝,加密端可以在非硬件、防篡改安全模块中使用之前使用过的键。这项技术非常巧妙。 ANSI 规范还有一些不足之处,但技术还不错。
祝你好运。/鲍勃·布莱恩
关于ansi - 解密 DUKPT 加密轨道数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11750036/
我正在寻找一个控制代码来使用 ANSI 或其他一些标准在终端中创建橙色文本,这可能吗?我只看到黄色和红色可用,我认为您不能将红色和黄色混合用于同一个角色:) 最佳答案 严格来说,不:ANSI 从未标准
我知道 \33[nC移动光标 n列向前;问题是,我不知道特定行包含多少个字符。 最佳答案 什么都没有显式 ,但是屏幕“小”,您可以使用任何光标移动命令移动到任意远的目的地,终端将通过屏幕大小限制移动。
这个问题在这里已经有了答案: Oracle Joins - Comparison between conventional syntax VS ANSI Syntax (11 个回答) 8 年前关闭。
我知道在 bash 终端中,一种可靠的变色方法是使用 ANSI 转义序列。例如: echo -e "\033[0;31mbrown text\033[0;00m" 应该输出 brown text (i
上次我检查时,说您正在使用 ANSI C 编码等同于说“这是符合 C99 的代码,其中没有任何其他内容”。现在有了 C11 和 C++11,这种区别还存在吗?它还有某种意义吗? 最佳答案 历史上,“A
我的业务逻辑包含在大约 7000 行 T-SQL 存储过程中,其中大多数都具有下一个 JOIN 语法: SELECT A.A, B.B, C.C FROM aaa AS A, bbb AS B, cc
我的业务逻辑包含在大约 7000 行 T-SQL 存储过程中,其中大多数都具有下一个 JOIN 语法: SELECT A.A, B.B, C.C FROM aaa AS A, bbb AS B, cc
我正在使用 CentOS 7 和 PHP 7.0 TERM=xterm-256color 我确实有一个彩色提示和 ls 颜色,如果我通过 --ansi然后它确实显示为彩色,但我不想总是添加 --ans
在我工作过的每家公司,我发现人们仍然按照 ANSI-89 标准编写 SQL 查询: select a.id, b.id, b.address_1 from person a, address b wh
我正在使用 Delphi RIO 10.3.3。 当我将 Ansi 字符串作为 const 数组的元素之一传递时,string() 转换对其不起作用。为了让它工作,我必须先将 VAnsiString
我正在使用 Delphi RIO 10.3.3。 当我将 Ansi 字符串作为 const 数组的元素之一传递时,string() 转换对其不起作用。为了让它工作,我必须先将 VAnsiString
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
当我在终端上调整大小时,它保持全屏显示。我想,有某种方法可以找出终端的屏幕尺寸。我怎样才能在 VT100 中做到这一点? 使用 ,当我列出文件夹时,它以蓝色显示文件夹。 (或者让我们说不同的颜色)但是
我的程序正在向某个日志文件发送characters-colored文本: echo -e "\\033[38;5;2m-->\\033[0m Starting program." | tee $Log
我刚开始使用 gsoap。我只使用 c++ 取得了 4 个小成功,但是我当前的项目限制了我设置源代码生成选项来创建纯 ANSI C(不是 c++)。我似乎无法成功调用该服务,错误返回为 0xC0000
来自 http://blocktronics.org/ 的 ANSI 文件似乎使用的是另一种 ANSI 编码,而不是我的 VT100 终端仿真器支持的编码。 如果我使用 tetraview 查看这些文
如何在 Java 中将十六进制字符串转换为 ansi(窗口 1252)以及将 ansi(窗口 1252)转换为十六进制字符串。 python(完美运行) q = "hex string value"
我用 java 编写了一个 android 应用程序来获取用户答案并将它们保存在一个文件中。问题是这个文件是以 utf-8 格式保存的。最终用户将在 IBM SPSS 中打开这些文件,这是一种适用于
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 锁定。这个问题及其答案
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicates: Floating point inaccuracy examples Is JavaScript's Ma
我是一名优秀的程序员,十分优秀!