IdentityPython / pyjwkest

Implementation of JWT, JWS, JWE and JWK
Apache License 2.0
94 stars 55 forks source link

Signature verification with ECKey #16

Closed zamzterz closed 9 years ago

zamzterz commented 9 years ago

It seems to be possible to verify the signature of a JWS with another key than the one used to sign it. I've reproduced it using the following test which fails:

def test_unequal_ec_key():
    payload = "Please take a moment to register today"
    sign_key = ECKey().load_key(P256)
    _jwt = JWS(payload, alg="ES256").sign_compact([sign_key])

    verify_key = ECKey().load_key(P256)
    assert sign_key.d != verify_key.d # should not be able to verify signature with different key?
    with pytest.raises(BadSignature):
        JWS().verify_compact(_jwt, [verify_key]) # should not be allowed since sign_key != verify_key
rohe commented 9 years ago

Fixed!

9 feb 2015 kl. 09:39 skrev Rebecka Gulliksson notifications@github.com:

It seems to be possible to verify the signature of a JWS with another key than the one used to sign it. I've reproduced it using the following test which fails:

def test_unequal_ec_key(): payload = "Please take a moment to register today" sign_key = ECKey().load_key(P256) _jwt = JWS(payload, alg="ES256").sign_compact([sign_key])

verify_key = ECKey().load_key(P256)
assert sign_key.d != verify_key.d # should not be able to verify signature with different key?
with pytest.raises(BadSignature):
    JWS().verify_compact(_jwt, [verify_key]) # should not be allowed since sign_key != verify_key

— Reply to this email directly or view it on GitHub.

  • Roland

"It is the consequence of humanity. We are all formed of frailty and error; let us pardon reciprocally each others’ folly - that is the first law of nature.” - Voltaire