ed25519-java icon indicating copy to clipboard operation
ed25519-java copied to clipboard

How to import/export keys from/to a file

Open maxidorius opened this issue 8 years ago • 6 comments

Most likely I am missing something obvious, not having a lot of experience with cryptographic APIs - apologizes if that is the case.

I am trying to general a pub/priv pair of keys and I would like to export those to a file so I can re-use them next time my application start. How can it be done here? Should I export the seed of the private key and recreate the object later? Are there factory methods/classes somewhere that allow such operation?

If someone could provide a sample code, that would be the best. Thanks!

maxidorius avatar Jan 22 '17 18:01 maxidorius

ping! I am currently looking at a way to extract the private key from openssh private key file, which has proven to be quite a challenge in java. Any pointers there would be very helpful.

om26er avatar Dec 12 '17 21:12 om26er

For anyone interested how to do this, here is how I've done it, only storing the seed in a file.

maxidorius avatar Dec 13 '17 00:12 maxidorius

@om26er Are you sure this is the right project? SSH key tend to be RSA, not ed25519

maxidorius avatar Dec 13 '17 00:12 maxidorius

@om26er Are you sure this is the right project? SSH key tend to be RSA, not ed25519

OPENSSH keys can also be ed25519. I figured what I was looking for, took me a while but here https://gist.github.com/om26er/494b2b34bd605ec081b9d7057cc4aa2f

om26er avatar Dec 13 '17 18:12 om26er

Sadly this issue is still open and doesn't have a solution for me. I want to be able to work with an Arduino and my app. The Arduino Cryptography Library works with the raw keys (the java equivalent would be PublicKey.getEncoded()). Now I want to use one of these raw keys to create an EdDSAPublicKey (storing the seed like @maxidorius isn't an option, as the Arduino-library doesn't supply the seed). Any ideas on how I can achieve this?

eschoenawa avatar Jan 12 '20 06:01 eschoenawa

I recommend using my newer library https://github.com/cryptography-cafe/ed25519-elisabeth for non-JCA usage. It's still in beta, so now would be a good time to test it and give feedback.

str4d avatar Jan 12 '20 07:01 str4d