Skip to content

Commit

Permalink
Fix base64url decoder
Browse files Browse the repository at this point in the history
cl-base64 semantics is good!
  • Loading branch information
kkazuo committed Nov 10, 2018
1 parent 7cafefe commit 484584b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
6 changes: 3 additions & 3 deletions openid-key.asd
Expand Up @@ -3,14 +3,14 @@
|#

(defsystem "openid-key"
:version "0.1.0"
:version "0.1.1"
:author "Koga Kazuo"
:license "MIT"
:depends-on ("dexador"
:depends-on ("cl-base64"
"dexador"
"ironclad"
"jonathan"
"local-time"
"qbase64"
"quri"
"trivial-rfc-1123")
:components ((:module "src"
Expand Down
13 changes: 2 additions & 11 deletions src/openid-key.lisp
Expand Up @@ -33,18 +33,9 @@
(setf (quri:uri-path config) well-known))
config))

(defun padding (s)
(let ((p (- 4 (rem (length s) 4))))
(case p
((1) (concatenate 'string s "="))
((2) (concatenate 'string s "=="))
((3) (concatenate 'string s "==="))
(otherwise s))))

(defun b64-integer (s)
(let* ((b (qbase64:decode-string (padding s) :scheme :uri))
(v (make-array (length b) :element-type '(unsigned-byte 8) :initial-contents b)))
(ironclad:octets-to-integer v)))
(ironclad:octets-to-integer
(base64:base64-string-to-usb8-array s :uri t)))

(defun jwk-key (jwk)
(when (equal "RSA" (cdr (assoc "kty" jwk :test 'equal)))
Expand Down

0 comments on commit 484584b

Please sign in to comment.