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

Correctness: need to check why it differs from pycryptopan #2

Open
aaronkaplan opened this issue May 23, 2018 · 1 comment
Open

Correctness: need to check why it differs from pycryptopan #2

aaronkaplan opened this issue May 23, 2018 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aaronkaplan
Copy link
Member

pycryptopan as well as yacryptopan agree on the result of the function if the key is the same and the ip address as input is the same. cryptopanlib.so does not produce the same results with the same key. Need to inspect. Probably an endianness problem (?)

@aaronkaplan aaronkaplan added bug Something isn't working help wanted Extra attention is needed labels May 23, 2018
@noinkling
Copy link

noinkling commented Dec 14, 2021

That's by design to some degree, the David Stott/Lucent version tries to increase randomness of the output:

https://web.archive.org/web/20180908092852/https://www.cc.gatech.edu/computing/Networking/projects/cryptopan/lucent.shtml

I choose to wrap the overflow bits from the pad back into the pad (e.g., if the pad is being shifted left, I set the LSB to the old MSB).

You can see part of the pad being rotated each iteration here:

u_int32_t newpad = (first4bytes_pad<<pos)|(first4bytes_pad>>(32-pos));

There's another change, which doesn't seem to be documented/explained anywhere, which is that the pad gets XORed with the address bits on each iteration:

*(u_int32_t*)rin_input = htonl( newpad^(orig_addr&mask));

By changing these two parts, and also changing the endianness of one value, I was able modify the program to match the reference output (and the other implementations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants