Skip to content

Commit e5aaf35

Browse files
committed
add test cases for thumbprint (EC, RSA). reference thumbprint calculated using another implementation
1 parent bbba672 commit e5aaf35

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_02_jwk.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,3 +569,22 @@ def test_appropriate():
569569

570570
assert _j1.appropriate_for('sign')
571571
assert _j1.appropriate_for('encrypt') is False
572+
573+
def test_thumbprint_ec():
574+
jwk = key_from_jwk_dict({
575+
"kty": "EC",
576+
"crv": "P-256",
577+
"x": "MJ05vpfkWoIce1MwUpZYAyotenxp4yYVHJuc6lN_J0o",
578+
"y": "Kfzs5wbqnEWUlFElN8ErWEL5YL2WQ1yowxzHejlzlZ0"
579+
})
580+
thumbprint = "RCWR9g8NPt9iZeq-lh-qXbiFxXcU0_o1YLitDj3kpg0"
581+
assert (jwk.thumbprint('SHA-256').decode()) == thumbprint
582+
583+
def test_thumbprint_rsa():
584+
jwk = key_from_jwk_dict({
585+
"kty": "RSA",
586+
"e": "AQAB",
587+
"n": "3xIyjRLL1LYi2FULhN6koVwtsaixgXa5TBOMcq2EMsk_Fq-tSXmxA8ATYcUnuSGX3PGJ5pHwIF42eesIzQV5ypYklF0sLAkmkXow_TMDX0qoc4rdfc2prq-mzPWwGcYoRsjDKiSUFOUSKB41zQ6sMY2k4BWZVo1bEL0CVpVct1DDhqSME6uUKex9T2AbwWNvwFacrwJaWyKixBhiPSwVBn7dUWDnJiM39_4Lnw6JnriXcli-aJlPuXm5F_qspXL4Pfn9nR5Z9j9Qf7NFif7nVRyg8cx7OYTbbsoIbMYYG-boVPLL7ebEBZVIUysqH_WkNJlkl5m7gAs5DB_KfMx18Q",
588+
})
589+
thumbprint = "Q1wZMrouq_iCnG7mr2y03Zxf7iE9mie-y_Mfh9-Cgk0"
590+
assert (jwk.thumbprint('SHA-256').decode()) == thumbprint

0 commit comments

Comments
 (0)