【问题标题】:PINBLOCK does not contain a valid valuePINBLOCK 不包含有效值
【发布时间】:2017-05-26 11:18:30
【问题描述】:

在尝试运行交易时,我总是在使用正确的 TPK 加密已确认的 PINBLOCK 时收到此错误作为响应。 虽然,我不太确定的是用于加密此数据的算法,因此会引发此错误,因为预期的算法是 DES 算法(来自给出的文档),它给出了 translatedPINBlock: 99-Wrong Format,但在更新我的代码以使用

public String do3DESEncryption(String key, String text) {
        String encryptedInfo = null;
        try {
            String key1 = key.substring(0, 16);
            String key2 = key.substring(16);
            encryptedInfo = doDESEncryption(key1, text);
            encryptedInfo = doDESDecryption(key2, encryptedInfo);
            encryptedInfo = doDESEncryption(key1, encryptedInfo);
        } catch (Exception ex) {
            System.out.println("do3DESEncryption error message"+ex.getMessage());
            ex.printStackTrace();
        }

        return encryptedInfo;
    }

我之前使用的算法如下所述

public String doDESEncryption(String key, String text) {
        String encryptedInfo = "";
        try {
            byte[] theCph = null;
            byte[] theKey = null;
            byte[] theMsg = null;
            theKey = hexToBytes(key);
            theMsg = hexToBytes(text);
            DESKeySpec ks = new DESKeySpec(theKey);
            SecretKeyFactory kf = SecretKeyFactory.getInstance("DES");
            SecretKey ky = kf.generateSecret(ks);
            Cipher cf = Cipher.getInstance("DES/ECB/NoPadding");
            cf.init(Cipher.ENCRYPT_MODE, ky);
            theCph = cf.doFinal(theMsg);
            encryptedInfo = bytesToHex(theCph);
            System.out.println("Just the ePINBLOCK"+encryptedInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return encryptedInfo;
    }

我想知道,如果我真的做好了加密,因为我只能访问客户端。我只是想确定自己正在做的事情,并想知道是否可以进行任何其他更正以避免出现此错误。 translatedPINBlock:99-格式错误

这是来自一号机器的错误日志

Postilion 异常:[postilion.realtime.sdk.crypto.XPinLengthError] 说明:涉及密钥的加密操作 () “SBP_KVP”失败,因为提供了无效数据。无效数据 在“PIN”字段中。数据无效,因为 PIN 长度为 无效的。 ID:[126] 数据:[无]

在 postilion.realtime.sdk.crypto.impl.rg7000.ARG7000KeyImpl.processErrorCode(ARG7000KeyImpl.java:170) 在 postilion.realtime.sdk.crypto.impl.rg7000.RG7000DesKeyImpl.processErrorCode(RG7000DesKeyImpl.java:1320) 在 postilion.realtime.sdk.crypto.impl.rg7000.RG7000DesKeyImpl.processResponseAndErrorCode(RG7000DesKeyImpl.java:1378) 在 postilion.realtime.sdk.crypto.impl.rg7000.RG7000DesKvpIbmImpl.verifyPin(RG7000DesKvpIbmImpl.java:365) 在 postilion.realtime.sdk.crypto.DesKvpIbm.verifyPin(DesKvpIbm.java:613) 在 postilion.postcard.authorizers.IBMPinVerificationData.verify(IBMPinVerificationData.java:281) 在 postilion.postcard.authorizers.validators.ValidatorPinPostCard.validatePin(ValidatorPinPostCard.java:550) 在 postilion.postcard.authorizers.validators.ValidatorPinPostCard.validatePinAndPopulateMessageReasonCode(ValidatorPinPostCard.java:281) 在 postilion.postcard.authorizers.validators.ValidatorPinPostCard.validateOnline(ValidatorPinPostCard.java:78) 在 postilion.postcard.authorizers.pipeline.adapter.IssuerValidatorAdapter.process(IssuerValidatorAdapter.java:117) 在 postilion.postcard.authorizers.pipeline.Pipeline.process(Pipeline.java:315) 在 postilion.postcard.authorizers.AuthorizerPostCard.authorizeRequestOnline(AuthorizerPostCard.java:339) 在 postilion.realtime.apps.tranmgr.EventHandlerReqReqMessage.attemptLocalAuthorization(EventHandlerReqReqMessage.java:145) 在 postilion.realtime.apps.tranmgr.EventHandlerTranReq.processTran(EventHandlerTranReq.java:88) 在 postilion.realtime.apps.tranmgr.EventHandlerMessage.process(EventHandlerMessage.java:64) 在 postilion.realtime.apps.tranmgr.EventHandlerMessage.processMsg(EventHandlerMessage.java:40) 在 postilion.realtime.apps.tranmgr.TransactionManager.processNodeMessage(TransactionManager.java:1435) 在 postilion.realtime.apps.tranmgr.TransactionManager.processEvent(TransactionManager.java:1360) 在 postilion.realtime.sdk.util.Processor.run(Processor.java:213) 在 postilion.realtime.sdk.env.AppProcessor.run(AppProcessor.java:136) [错误事件 126]

来自机器 2 的错误日志

:: process0200 messageRetrievedFromStore [51]:22314F270B978B54 信息 |虚拟机 1 | 2017/01/04 16:00:21 | 2017 年 1 月 4 日下午 4:00:21 hsmm.ncs.core.MessageProcessor 进程PINBlock INFO |虚拟机 1 | 2017/01/04 16:00:21 |信息:MessageProcessor :: process0200 ::

translatedPINBlock:99-格式错误信息 |虚拟机 1 | 2017/01/04 16:00:21 | 2017 年 1 月 4 日下午 4:00:21 hsmm.ncs.core.MessageProcessor 进程0200

【问题讨论】:

  • 您必须使用某些格式来加密 PIN 值。 paymentsystemsblog.com/2010/03/03/pin-block-formats
  • 感谢您的评论,我非常感谢...PINBLOCK 实际上是使用 ISO-0 格式从设备生成的,这也是 HSM 所期望的相同格式,所以..我怀疑在我正在使用的算法上。我也真诚地感谢您的时间
  • 钥匙有多长,不是三倍的吗?因为根据我的经验,现在大多数解决方案都首选 3DES
  • 我以前只使用DES,但现在使用3DES..密钥长度为32
  • 3DES 没有 32 字节的密钥。 3DES 密钥是 24 字节中的 168 位(每个字节的 lsb 未使用)。最有可能的额外字节将被忽略,但这表明对密钥有一些误解。有时使用双 DES 密钥,前 8 字节重复字节 16-23,一些 3DES 实现会自动执行此操作,但不是全部。您确实需要确定 keyL DE​​S 与 3DES 以及 3DES 是 2 字节还是 3 字节密钥以及如何处理密钥。使用错误的密钥解密数据会产生错误的数据,因此任何基于错误密钥的错误消息都没有意义。

标签: hsm iso8583


【解决方案1】:

目前的做法要求加密是 3DES,可能使用双倍长度的密钥。

【讨论】:

  • 非常感谢@zaph,我已经更新了这个问题,我得到了上面的错误日志(由帮助我监控交易的人给我),我真诚地感谢你的时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-23
  • 2018-04-15
  • 1970-01-01
  • 2013-05-28
  • 2014-05-17
  • 1970-01-01
  • 2017-01-06
相关资源
最近更新 更多