Closed kingingo closed 2 years ago
Hi @kingingo and thanks for the question :)
A quick guess is that your calculations are overflowing.
From the pasted code, it looks like you are working with 2048 bit integers.
If you increment the integer size to, say 2080 bits or larger (260 bytes instead of 256 bytes), your calculations seem to work correctly.
At least, if I run the code with 2048 bit integers, I get this final result:
COMP K_a == K_b = EQUAL
K_a is ZERO
K_b is ZERO
... and with 2080 bit integers, it's this:
COMP K_a == K_b = NOT EQUAL
K_a is NOT ZERO
K_b is NOT ZERO
Let me know if you have any questions :)
EDIT:
The code in rsa.c
is just for fun and games. It could probably be made much faster with Karatsuba-multiplication etc.
I am trying to implement the deffie-hellman-group14 but unfortunately bignum_pow_mod_faster gives me 0 back... I got a & b for testing from this site: http://acme.com/dhtest/dhtest.html