0

I am having troubling with generating IPEK from BDK and KSN from python, after that i want to generate dataKey from kSN and IPEK. Is there any way to do this two functions using python? Wanted Scenario below

def decryptinfo(ksn, data):
  BDK = unhexlify("0123456789ABCDEFFEDCBA9876543210")
  ksn = unhexlify(ksn)
  IPEK = GenerateIPEK(ksn, BDK)
  DATAKEY = GetDataKey(ksn, IPEK)
  res = TDES_Dec(data, DATA_KEY)
  return hexlify(res)

def GetDataKey(ksn, ipek):
  key = GetDukptKey(ksn, ipek)
  key = bytearray(key)
  key[5] ^= 0xFF
  key[13] ^= 0xFF
 return str(key) 

I want to know is there any way to get GenerateIPEK(ksn, BDK) and GetDukptKey(ksn, ipek) from python..

s.am.i
  • 648
  • 5
  • 16
  • other than just writing them? – Michal Gluchowski Aug 28 '20 at 07:38
  • When you do, bear in mind some DUKPT implementations (including those used by HSMs) use different value than what you currently have - in many cases DUKPT data key is encrypted by itself as a last step (you would need to add this in GetDataKey). – Michal Gluchowski Aug 28 '20 at 07:43

0 Answers0