-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for secp256k1 algorithms (AKA ES256K) #439
Conversation
|
||
@Test | ||
public void shouldAddKeyIdIfAvailableFromECDSAKAlgorithms() throws Exception { | ||
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256K |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit to fix running the formatter.
|
||
String signed = JWT.create().sign(Algorithm.ECDSA256K(publicKey, privateKey) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to run the formatter shortcut option+command+L
to update all these changes
String signed = JWT.create().sign(Algorithm.ECDSA256K(publicKey, privateKey) ); | |
String signed = JWT.create().sign(Algorithm.ECDSA256K(publicKey, privateKey)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, added a commit to do just that.
import java.security.spec.InvalidKeySpecException; | ||
import java.security.spec.PKCS8EncodedKeySpec; | ||
import java.security.spec.X509EncodedKeySpec; | ||
import java.security.spec.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the other approach but this is a test so it's fine. However, try running the import organizer shortcut control+option+O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Good to merge 👍 |
Changes
This replaces #428 to add support for the secp256k1 algorithm. The only changes from that original PR are the ones requested on the review:
It also removes the README txt file.
For review purposes, see the commits for this PR; the changes to the original PR have been captured as separate commits.
References
#428
Testing
How to create a secp256k1 key to be used with ES256K algorithm:
Generate the key
openssl ecparam -genkey -name secp256k1 -out KEY.pem -text
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in KEY.pem -out ec256k-key.private.pem
The public key is then calculated as follows:
openssl ec -pubout -in KEY.pem -out ec256k-key-public.pem
How to get DER signature:
Checklist