diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-11-08 20:49:48 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-11-15 18:58:09 -0500 |
| commit | 5074f14e00f00fb0343fadcf7b2ec1c33c8efaaf (patch) | |
| tree | dc1f34ef94b8cfba539344a8df80251f949971c1 /dynamic/captcha.scm | |
| parent | ecfc5b6d209e305a76c5540e8d7f786571a1d8e8 (diff) | |
[dynamic] Drop (hashing) for (gcrypt hash)
Since it's a more standard Guile dependency, meaning I don't need to bing out
Akku for something as simple as calling a hash function.
Diffstat (limited to 'dynamic/captcha.scm')
| -rw-r--r-- | dynamic/captcha.scm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/dynamic/captcha.scm b/dynamic/captcha.scm index 99aa0cd..b095ebf 100644 --- a/dynamic/captcha.scm +++ b/dynamic/captcha.scm @@ -16,7 +16,7 @@ (define-module (captcha) #:use-module (base64) - #:use-module (hashing sha-2) + #:use-module (gcrypt hash) #:use-module (gcrypt mac) #:use-module (gcrypt random) #:use-module (ice-9 binary-ports) @@ -155,10 +155,15 @@ (define (check-proof-of-work prefix challenge challenge-signature expiry-timestamp timestamp-signature) + (define hash-value + (chain (list prefix challenge) + (string-concatenate _) + (string->bytevector _ "utf8") + (bytevector-hash _ (lookup-hash-algorithm 'sha256)) + (bytevector->base16-string _))) + (define zero-prefix (string-join (map (lambda (_) "0") (iota %hardness)) "")) (and (= 32 (string-length prefix)) - (string-prefix? - (string-join (map (lambda (_) "0") (iota %hardness)) "") - (sha-256->string (sha-256 (string->bytevector (string-concatenate (list prefix challenge)) "utf8")))) + (string-prefix? zero-prefix hash-value) (valid-base64-signature? %pow-mac-key challenge challenge-signature) (valid-base64-signature? %pow-mac-key expiry-timestamp timestamp-signature) (time<=? (current-time) |