bwesterb / py-seccure

SECCURE compatible Elliptic Curve cryptography in Python
GNU Lesser General Public License v3.0
94 stars 24 forks source link

verify method with curve 224 failed #18

Closed sandrinesuire closed 5 years ago

sandrinesuire commented 5 years ago

Since version 0.3.3 was changed, and after modifying # 16, I have the following problem:

if I take your test and its values, all is OK

version 0.3.2

msg = b'ttrMWDqBxjC8UAl8X4TRDSSpd1IyYMh4\n'
pw = b'my private key'
sig = seccure.sign(msg, pw) # sig = b'5{LV[=|t~46wS2y<Ub9Ol;uO/fPGU*JYKid+|(JBMspwk7S'
pubkey = str(seccure.passphrase_to_pubkey(pw))
print(seccure.verify(msg, sig, pubkey)) # == True

version 0.3.3

msg = b'ttrMWDqBxjC8UAl8X4TRDSSpd1IyYMh4\n'
pw = b'my private key'
sig = seccure.sign(msg, pw) # sig = b'!!!5{LV[=|t~46wS2y<Ub9Ol;uO/fPGU*JYKid+|(JBMspwk7S'
pubkey = str(seccure.passphrase_to_pubkey(pw))
print(seccure.verify(msg, sig, pubkey)) # == True

But, now if I sign with the 224 curve and therefore uses the curve parameter of the verify method I have a False

version 0.3.2

msg = b'ttrMWDqBxjC8UAl8X4TRDSSpd1IyYMh4\n'
pw = b'my private key'
sig = seccure.sign(msg, pw, curve="secp224r1/nistp224") # sig = b'?/<_u~1:5ZKif8@wD<rS~NaKpu-MIc.Q3e{(J_%i3xT:Bn(uLiGU@|lvs0Qv7Nq)Fi/W:'
pubkey = str(seccure.passphrase_to_pubkey(pw))
print(seccure.verify(msg, sig, pubkey, curve="secp224r1/nistp224")) # == False

version 0.3.3

msg = b'ttrMWDqBxjC8UAl8X4TRDSSpd1IyYMh4\n'
pw = b'my private key'
sig = seccure.sign(msg, pw, curve="secp224r1/nistp224") # sig = b'!?/<_u~1:5ZKif8@wD<rS~NaKpu-MIc.Q3e{(J_%i3xT:Bn(uLiGU@|lvs0Qv7Nq)Fi/W:'
pubkey = str(seccure.passphrase_to_pubkey(pw))
print(seccure.verify(msg, sig, pubkey, curve="secp224r1/nistp224")) # == False

I tested the same method without the curve parameter of the verify method, and I get a False to my print method

bwesterb commented 5 years ago

Thank you for reporting the issue. I'll try to investigate it tomorrow.

bwesterb commented 5 years ago

You're missing the curve parameter to the seccure.passphrase_to_pubkey method. You should have used:

msg = b'ttrMWDqBxjC8UAl8X4TRDSSpd1IyYMh4\n'
pw = b'my private key'
sig = seccure.sign(msg, pw, curve="secp224r1/nistp224") # sig = b'!?/<_u~1:5ZKif8@wD<rS~NaKpu-MIc.Q3e{(J_%i3xT:Bn(uLiGU@|lvs0Qv7Nq)Fi/W:'
pubkey = str(seccure.passphrase_to_pubkey(pw, curve='secp224r1/nistp224'))
print(seccure.verify(msg, sig, pubkey, curve="secp224r1/nistp224")) # == True
sandrinesuire commented 5 years ago

Thanks you very much for your quick answer. :-)