def command_JE(cmdObj): """ Translate a PIN from encryption under a ZPK to encryption under the LMK. """ """ Command Pattern: request: Message header + 'JE' + ZPK + PIN Block + PIN Block Format Code + Account Number + End message delimiter + Message Trailer response: Message header + 'JF' + Error code + PIN + End Message delimiter + Message Trailer """ respObj = CommandObj() ZPK = decryptKeyUnderLMK('ZPK', unhexlify(cmdObj.ZPK.value), cmdObj.ZPK.scheme) zpk = KeyScheme(ZPK) pinblock = zpk.decrypt(unhexlify(cmdObj.PINBlock.value)) (clearPIN, rslt) = extrackPINFromPINBlock(pinblock, cmdObj.AccountNumber.value, cmdObj.PINBlockFormatCode.value) if rslt != '00': respObj.ResponseCode = DataVariable(rslt) return respObj print "clearPIN=", clearPIN if (len(clearPIN) < 4) or (len(clearPIN) > 12): respObj.ResponseCode = DataVariable('24') return respObj cipherPIN = encryptPINUnderLMK(clearPIN, cmdObj.AccountNumber.value) respObj = CommandObj() respObj.ResponseCode = DataVariable('00') respObj.PIN = DataVariable(cipherPIN) return respObj
def command_BA(cmdObj): """ Encrypt a clear text PIN. """ """ Command Pattern: request: Message header + 'NG' + PIN + Account Number + End message delimiter + Message Trailer response: Message header + 'NH' + Error code + PIN + End Message delimiter + Message Trailer """ PIN = encryptPINUnderLMK(cmdObj.PIN.value, cmdObj.AccountNumber.value) respObj = CommandObj() respObj.ResponseCode = DataVariable('00') respObj.PIN = DataVariable(PIN) return respObj
def command_NG(cmdObj): """ Decrypted an encrypted PIN and return a reference number. """ """ Command Pattern: request: Message header + 'NG' + Account Number + PIN + End message delimiter + Message Trailer response: Message header + 'NH' + Error code + PIN + End Message delimiter + Message Trailer """ PIN = decryptPINUnderLMK(cmdObj.PIN.value, cmdObj.AccountNumber.value) respObj = CommandObj() respObj.ResponseCode = DataVariable('00') respObj.PIN = DataVariable(PIN) return respObj
def command_EE(cmdObj): """ Derive a PIN Using IBM Method """ """ Command Pattern: request: Message header + 'EE' + PVK + Offset + Check length + Account Number + Decimalization Table + PIN Validation data + End message delimiter + Message Trailer response: Message header + 'EF' + Error code + PIN + End Message delimiter + Message Trailer """ PVK = decryptKeyUnderLMK('PVK', unhexlify(cmdObj.PVK.value), cmdObj.PVK.scheme) PIN = genPINUsingIBMMetheod(PVK, cmdObj.AccountNumber.value, cmdObj.PINValidationData.value, cmdObj.DecimalizationTable.value) finalPIN = genFinalPIN(PIN, cmdObj.Offset.value) cypherPIN = encryptPINUnderLMK(finalPIN, cmdObj.AccountNumber.value) respObj = CommandObj() respObj.ResponseCode = DataVariable('00') respObj.PIN = DataVariable(cypherPIN) return respObj
def command_JC(cmdObj): """ Translate a PIN from encryption under a TPK to encryption under the LMK. """ """ Command Pattern: request: Message header + 'JC' + TPK + PIN Block + PIN Block Format Code + Account Number + End message delimiter + Message Trailer response: Message header + 'JD' + Error code + PIN + End Message delimiter + Message Trailer """ TPK = decryptKeyUnderLMK('TPK', unhexlify(cmdObj.TPK.value), cmdObj.TPK.scheme) tpk = KeyScheme(TPK) pinblock = tpk.decrypt(unhexlify(cmdObj.PINBlock.value)) clearPIN = extrackPINFromPINBlock(pinblock, cmdObj.AccountNumber.value, cmdObj.PINBlockFormatCode.value) cipherPIN = encryptPINUnderLMK(clearPIN, cmdObj.AccountNumber.value) respObj = CommandObj() respObj.ResponseCode = DataVariable('00') respObj.PIN = DataVariable(cipherPIN) return respObj