buddy-sign
buddy-sign copied to clipboard
Errors in using :eddsa algo for claims signing
Hi, Firstly, thanks for creating the Buddy security libraries for Clojure. I am going through the code examples in your documentation, but did not see any specific examples for using ED25519 even though I see that it is supported using the :eddsa algorithm options.
I created a ED25519 keypair using OpenSSL v1.1.1g for testing buddy-sign claims signing using the :eddsa.
$ openssl genpkey -algorithm ED25519 > test-ed-privkey.pem
$ openssl pkey -in test-ed-privkey.pem -pubout > test-ed-pubkey.pem
And then wrote a very simple test on the Clojure repl:
(require '[buddy.sign.jwt :as jwt])
(require '[buddy.core.keys :as keys])
(def ed-privkey (keys/private-key "./test-ed-privkey.pem"))
(def ed-pubkey (keys/public-key "./test-ed-pubkey.pem"))
(jwt/sign {:userid 22} ed-privkey {:alg :eddsa})
That last line threw an InvalidKeyException with the message
cannot identify EdDSA private key: class org.bouncycastle.jcajce.provider.asymmetric.edec.BCEdDSAPrivateKey.
I am using these versions of Clojure and the buddy-sign libraries
[buddy/buddy-core "1.6.0"]
[buddy/buddy-sign "3.1.0"]
[org.clojure/clojure "1.10.0"]
on Mac OS v10.14.6.