Back
jwk->public-key (clj)
(source)function
(jwk->public-key jwk)
Converts clojure map representing JWK object to java.security.PublicKey
Examples
funcool/buddy-core
Reference:
https://tools.ietf.org/html/rfc8037#section-2"
(:require [buddy.core.keys.jwk.proto :as proto]
[buddy.core.hash :as hash]
[cheshire.core :as json])
(:import (java.io StringWriter)
(com.fasterxml.jackson.core JsonGenerator)))
(defmethod proto/jwk->public-key "OKP"
[jwk]
(jwkokp->public-key jwk))
funcool/buddy-core
(ns buddy.core.keys.jwk.rsa
"JWK support for RSA keys"
(:require [buddy.core.codecs.base64 :as b64]
[buddy.core.codecs :as codecs]
[buddy.core.keys.jwk.proto :as proto]
[buddy.core.hash :as hash]
[cheshire.core :as json])
(:import (java.security.interfaces RSAPrivateKey RSAPublicKey)
(java.io StringWriter)
(com.fasterxml.jackson.core JsonGenerator)
(java.security KeyFactory)
(java.security.spec RSAPrivateKeySpec RSAPublicKeySpec)))
(defmethod proto/jwk->public-key "RSA"
[jwk]
(let [n (proto/b64str->bigint (:n jwk))
e (proto/b64str->bigint (:e jwk))
kf (KeyFactory/getInstance "RSA" "BC")]
(.generatePublic kf (RSAPublicKeySpec. n e))))