From e22ca3819ed3fc5ce6b58b289c6c4b5a16dc8f25 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Add a function to hash a public key for DPoP. --- tests/Makefile.am | 3 ++- tests/jkt.scm | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/jkt.scm (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 94a8b5b..b889e0b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,7 +7,8 @@ TESTS = %reldir%/load-library.scm \ %reldir%/jwk-kty-rsa-correct.scm \ %reldir%/jwk-kty-rsa-incorrect.scm \ %reldir%/hash-ok.scm \ - %reldir%/hash-unsupported.scm + %reldir%/hash-unsupported.scm \ + %reldir%/jkt.scm EXTRA_DIST += $(TESTS) diff --git a/tests/jkt.scm b/tests/jkt.scm new file mode 100644 index 0000000..ca20f89 --- /dev/null +++ b/tests/jkt.scm @@ -0,0 +1,23 @@ +(use-modules (webid-oidc stubs) + (webid-oidc testing)) + +(with-test-environment + "jkt" + (lambda () + (let* ((key (json-string->scm "{ + \"kty\":\"EC\", + \"x\":\"l8tFrhx-34tV3hRICRDY9zCkDlpBhF42UQUfWVAWBFs\", + \"y\":\"9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA\", + \"crv\":\"P-256\" + }")) + (jkt (jkt key)) + (expected "0ZcOCORZNYy-DWpqq30jZyJGHTN0d2HglBV3uiguA4I")) + (unless (string=? jkt expected) + (format (current-error-port) + "The JKT algorithm is not correct: +expected: ~a +obtained: ~a +" + expected + jkt) + (exit 1))))) -- cgit v1.2.3