Skip to content
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

Errors dealing with Ed25519 keys and certificates #83

Open
danicuki opened this issue Dec 23, 2024 · 0 comments
Open

Errors dealing with Ed25519 keys and certificates #83

danicuki opened this issue Dec 23, 2024 · 0 comments

Comments

@danicuki
Copy link

danicuki commented Dec 23, 2024

I have this private key:

-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END PRIVATE KEY-----

I can successfully read it using:

{:ok, k} = X509.PrivateKey.from_pem("-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n-----END PRIVATE KEY-----")
{:ok,
 {:ECPrivateKey, 1,
  <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0>>, {:namedCurve, {1, 3, 101, 112}}, :asn1_NOVALUE,
  :asn1_NOVALUE}}

when I run openssl pkey -in key.pem -pubout I get:

$  openssl pkey -in ./test/system/network/alice_key.pem -pubout
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAO2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2ik=
-----END PUBLIC KEY-----

But when I take the existing key and convert it to pem again I get:

 IO.puts X509.PrivateKey.to_pem(k)
-----BEGIN EC PRIVATE KEY-----
MCwCAQEEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAUGAytlcA==
-----END EC PRIVATE KEY-----

(different from the original key)

and when I run openssl pkey -in generated_key.pem -pubout (with this new output), I get:

$ openssl pkey -in teste.pem -pubout
Could not find private key of key from teste.pem
40F8B1FE01000000:error:1608010C:STORE routines:ossl_store_handle_load_result:unsupported:crypto/store/store_result.c:151:

There is something wrong with this key pem generation. Am I doing something wrong or is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant