openemv / dukpt Goto Github PK
View Code? Open in Web Editor NEWANSI X9.24 DUKPT libraries and tools
License: GNU Lesser General Public License v2.1
ANSI X9.24 DUKPT libraries and tools
License: GNU Lesser General Public License v2.1
I possibly found a bug in pinblock format 4 generation.
First command is to show the transaction key that will be used to encrypt the pin. In this case, the transaction key is the same as the ik because ksn is zero (for simplicity).
Second command is to encipher the pin using pinblock format 4, using the derived transaction key (11111111111111111111111111111111
).
# ./dukpt-tool --mode=AES --key-type=AES128 --ik=11111111111111111111111111111111 --ksn=000000000000000000000000 --derive-txn-key
11111111111111111111111111111111
# ./dukpt-tool --mode=AES --key-type=AES128 --ik=11111111111111111111111111111111 --ksn=000000000000000000000000 --pan=1234123412341234 --pinblock-format=4 --encrypt-pin=1234
A5345078DE652954CAFE125E9495D8F5
Then when trying to decipher the generated pinblock using python psec library, I encounter an error related to control field :
>>> from psec.pinblock import decipher_pinblock_iso_4
>>> decipher_pinblock_iso_4(key=bytes.fromhex("11111111111111111111111111111111"), pin_block=bytes.fromhex("A5345078DE652954CAFE125E9495D8F5"), pan="1234123412341234")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/python3.10/site-packages/psec/pinblock.py", line 625, in decipher_pinblock_iso_4
return decode_pin_field_iso_4(pin_field)
File "/python3.10/site-packages/psec/pinblock.py", line 555, in decode_pin_field_iso_4
raise ValueError(
ValueError: PIN block is not ISO format 4: control field `B`
EDIT: The transaction key is actually not the key used for pin encryption. (It is a pin encryption key, which is derived from the transaction key)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.