Encryption 根据ANSI X9.24第1部分标准解密3DES DUKPT

Encryption 根据ANSI X9.24第1部分标准解密3DES DUKPT,encryption,cryptography,credit-card,3des,dukpt,Encryption,Cryptography,Credit Card,3des,Dukpt,我有一个Magtek uDynamo,正在尝试解密轨道1。我已经阅读了下面的内容,了解了一点,但不知道如何真正解密数据。供应商说使用ANSI测试密钥解密,但我找不到任何相关信息。我有KSN、会话和序列号。我还尝试了一些我发现的Java代码,但它似乎不起作用。它返回null,或者可能是我输入了错误的BDK。我只是用我在某处读到的序列号。我在安卓上做这个。我希望代码能够在服务器上运行,而不是在设备上运行,这样就可以通过HTTPS对代码进行加密 更新 我希望按照ANSI X9.24第1部分标准解

我有一个Magtek uDynamo,正在尝试解密轨道1。我已经阅读了下面的内容,了解了一点,但不知道如何真正解密数据。供应商说使用ANSI测试密钥解密,但我找不到任何相关信息。我有KSN、会话和序列号。我还尝试了一些我发现的Java代码,但它似乎不起作用。它返回null,或者可能是我输入了错误的BDK。我只是用我在某处读到的序列号。我在安卓上做这个。我希望代码能够在服务器上运行,而不是在设备上运行,这样就可以通过HTTPS对代码进行加密

更新 我希望按照ANSI X9.24第1部分标准解密3DES DUKPT

我在用这个

我必须更新文件,确保我得到了最新的phpseclib,并且它可以运行,但是数据出来时像C��� ������4A�fr���(世界银行������F�7z�n:�W�9��,��f7�,m=�Z�CRW�

我一定是遗漏了什么。我尝试了不同的模式,我正在寻找编码。请告诉我你是否有解决方案或想法。而且他们的测试数据确实有效,所以我不确定我的和他们的有什么区别

我在根目录中运行index.php的代码:

include 'vendor/autoload.php';

use DUKPT\DerivedKey;
use DUKPT\KeySerialNumber;
use DUKPT\Utility;

$encryptedHexData = 'de8bfe769dca885cf3cc312135fe2cccfacf176235f4bdee773d1865334315ed2aefcab613f1884b5d63051703d5a0e2bd5d1988eeabe641bd5d1988eeabe641';
$ksn = '00000232100117e00027';
$bdk = '0123456789ABCDEFFEDCBA9876543210';

$key = new KeySerialNumber($ksn);
$encryptionKey = DerivedKey::calculateDataEncryptionRequestKey($key, $bdk);
$actual = Utility::hex2bin(Utility::removePadding(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true)));


echo $encryptionKey.'<br />';

echo $actual.'<br /><br />';
包括“vendor/autoload.php”;
使用DUKPT\DerivedKey;
使用DUKPT\KeySerialNumber;
使用DUKPT\Utility;
$encryptedHexData='DE8BFE769DCA885CF3C312135FE2CCCFACF176235F4BDEE773D1865334315ED2AECAB613F1884B5D63051703D5A0E2BD5D1988EEABE641BD5D1988EEABE641';
$ksn='00000232100117e00027';
$bdk='0123456789ABCDEFFEDCBA9876543210';
$key=新的密钥序列号($ksn);
$encryptionKey=DerivedKey::calculateDataEncryptionRequestKey($key,$bdk);
$actual=Utility::hex2bin(Utility::removepading(Utility::tripleDesDecrypt($encryptedHexData,$encryptionKey,true));
echo$encryptionKey.“
”; 回显$actual.“

”;
使用正确的BDK和KSN,您现在需要做的就是尝试不同的模式

现在您正在使用的是
DerivedKey::calculateDataEncryptionRequestKey($key,$bdk);

您需要尝试其他模式,以确定您的设备正在使用哪种模式。以下是我用来为我的设备找到正确结果的代码

include 'vendor/autoload.php';

use DUKPT\DerivedKey;
use DUKPT\KeySerialNumber;
use DUKPT\Utility;

$encryptedHexData = 'C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12';
$ksn = 'FFFF9876543210E00008';
$bdk = '0123456789ABCDEFFEDCBA9876543210';

$key = new KeySerialNumber($ksn);

$encryptionKey = DerivedKey::calculatePinEncryptionKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Pin Encryption Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateMacRequestKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Mac Request Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateMacResponseKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Mac Response Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateDataEncryptionRequestKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Data Encryption Request Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateDataEncryptionResponseKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Data Encryption Response Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

我曾经帮助过我。我刚刚尝试过这个,但是你如何从中获取信用卡号,谢谢你现在指的是如何传递track1?track1在本文中描述了我有bdk和ksn,track1,我如何从中获取CC号,谢谢如果你有使用DUKPT密钥加密的track1,那么看看我链接的博客。这不是一个简单的过程,但博客非常准确,并提供了一个工作示例。当你有清晰的跟踪数据时,使用wiki描述从中抄送数字相对来说非常简单。
Pin Encryption Key: 27F66D5244FF621EAA6F6120EDEB427F
Decrypted Output: %B5452300551227189^HOGAN/PAUL ^08043210000000725000000?

Mac Request Key: 27F66D5244FF9DE1AA6F6120EDEBBD80
Decrypted Output: W����U�P�TfB/`����þ&��f��3y;�U�Zy��UK�[��s�;�>�[�b

Mac Response Key: 27F66D52BBFF62E1AA6F612012EB4280
Decrypted Output: b�K2a�S0��9�Mb-����*L�J���� ��s�\���H�����=���e�]�,���Hwq�

Data Encryption Request Key: C39B2778B058AC376FB18DC906F75CBA
Decrypted Output: RA]�ԅⱰQ���'v}b��h��St�����?� lu/�ٵ�P��!���6�� �

Data Encryption Response Key: 846E267CB822197406DA2B161191C6E4
Decrypted Output: ��,�B^FZ�� ςs�c���*E�4��0��ǂ}����6`-P�b�ʞ̳aصĬ�&���+��