diff --git a/test/test-web.lisp b/test/test-web.lisp index a33c521..d3bc1d6 100644 --- a/test/test-web.lisp +++ b/test/test-web.lisp @@ -49,6 +49,7 @@ (deftest test-jwt () (let ((secret (util:create-secret)) + ;(secret "5Hw3zlpoVbFGRNZcp7Dymw") jwt1) (setf jwt1 (jwt:create secret :admin)) (util:lgi secret jwt1))) diff --git a/util.lisp b/util.lisp index 9942c3c..ab8c99e 100644 --- a/util.lisp +++ b/util.lisp @@ -42,18 +42,21 @@ ;;;; secrets, digests, and other crypto stuff (defun create-secret (&key (bytes 16) (scheme :original)) - (b64:encode-bytes (ironclad:random-data bytes) :scheme scheme)) + (str:trim-right (b64:encode-bytes (ironclad:random-data bytes) :scheme scheme) + :char-bag "=")) (defun digest (tx &key (scheme :original) (alg :sha256)) (b64:encode-bytes (ironclad:digest-sequence alg (to-bytes tx)) :scheme scheme)) (defun sign (tx key) (let* ((binp (to-bytes tx)) - (bkey (make-array 16 :element-type '(unsigned-byte 8) - :initial-contents (b64:decode-string key))) + (bkey (to-bytes key)) + ;(bkey (make-array 16 :element-type '(unsigned-byte 8) + ; :initial-contents (b64:decode-string key))) (mac (ironclad:make-mac :hmac bkey :sha256))) (ironclad:update-mac mac binp) - (b64:encode-bytes (ironclad:hmac-digest mac) :scheme :uri))) + (str:trim-right (b64:encode-bytes (ironclad:produce-mac mac) :scheme :uri) + :char-bag "="))) ;;;; lists and loops @@ -110,7 +113,7 @@ (flexi-streams:string-to-octets s :external-format :utf8)) (defun to-b64 (s &key (scheme :original)) - (b64:encode-bytes (to-bytes s) :scheme scheme)) + (str:trim-right (b64:encode-bytes (to-bytes s) :scheme scheme) :char-bag "=")) ;;;; directory and pathname utilities