Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly wrong digit in pinBlockFormat0 #10

Open
fangyibkk opened this issue Jun 6, 2021 · 3 comments · May be fixed by #19
Open

Possibly wrong digit in pinBlockFormat0 #10

fangyibkk opened this issue Jun 6, 2021 · 3 comments · May be fixed by #19

Comments

@fangyibkk
Copy link

fangyibkk commented Jun 6, 2021

Hello there. I'm trying out this sample.

pinBlockFormat0('000456789012345','8482' )
// expecting 0484C79876FEDCBA

but it turns out to be not that value

I think

const preparedPAN = PAN.slice(3, 15).padStart(16, "0");

might possibly be

const preparedPAN = PAN.slice(4, 16).padStart(16, "0");

or just shorthand slice(-12)

Please help me check if I misunderstood something.
Thanks and cheers.

References:
http://icma.com/wp-content/uploads/2015/07/PinBlockFormats_SE1-15CM.pdf
https://en.wikipedia.org/wiki/ISO_9564#PIN_length

@superarts
Copy link

superarts commented Sep 26, 2023

Yea I think so too, and there's another problem: PAN isn't necessarily always 16 digits. According to EFTlab:

2. Prepare PAN – take 12 rightmost digits of the primary account number (excluding the check digit)

And in their example, they were using 19 digits PAN. Similar problems exist in pinBlockFormat3 too.

I think it might be possible that the 16th digit was considered to be the "check digit", however, I cannot find any information regarding the check digit in PAN. Also, ETFLab's example seems to treat 876543210987 as the "12 rightmost digits of the primary account number", which doesn't contain the check digit.

PIN blocks: PIN block encrypt operation finished
****************************************
PAN:            43219876543210987
PIN:            1234
PAD:            N/A
Format:         Format 3 (ISO-3)
—————————————-
Clear PIN block:3412ACC9B98CDF43

Questions above should be clarified from ISO PDFs but unfortunately I don't have access to them yet.

@hosseinmd
Copy link
Owner

I agree, but I don't have time. Code base is simple, please make PR.

@superarts
Copy link

Thanks for comfirming! @fangyibkk I have a different implementation of PIN block ISO-0, 1, 2, 3, feel free to try it out: https://www.superarts.org/KTPinBlock/

agustiza added a commit to agustiza/data-crypto that referenced this issue Nov 23, 2023
@agustiza agustiza linked a pull request Nov 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants