Fix java.security interop
This commit is contained in:
parent
c1412f9b31
commit
5e4ce8e093
2 changed files with 22 additions and 1 deletions
|
|
@ -786,6 +786,8 @@
|
|||
java.security.KeyPairGenerator
|
||||
(instance? java.security.Signature v)
|
||||
java.security.Signature
|
||||
(instance? java.security.Key v)
|
||||
java.security.Key
|
||||
(instance? java.util.Set v)
|
||||
java.util.Set
|
||||
(instance? java.io.Closeable v)
|
||||
|
|
|
|||
|
|
@ -166,4 +166,23 @@
|
|||
public-key (.getPublic key-pair)
|
||||
message "This is a secret message"
|
||||
signed-data (create-signature private-key message)]
|
||||
(verify-signature public-key message signed-data)))))))
|
||||
(verify-signature public-key message signed-data))))))
|
||||
|
||||
(is (true?
|
||||
(bb nil '(do (import
|
||||
'[java.security KeyPairGenerator]
|
||||
'[java.security.spec ECGenParameterSpec])
|
||||
|
||||
(def keypair-algo "EC")
|
||||
(def keypair-curve "secp256r1")
|
||||
|
||||
(defn keypair
|
||||
"Generates a new key pair with the given alias, using the keypair-algo and keypair-curve"
|
||||
[]
|
||||
(let [keygen (KeyPairGenerator/getInstance keypair-algo)]
|
||||
(.initialize keygen (ECGenParameterSpec. keypair-curve))
|
||||
(.generateKeyPair keygen)))
|
||||
|
||||
(let [kp (keypair)
|
||||
pk (.getPublic kp)]
|
||||
(bytes? (.getEncoded pk))))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue