Skip to content

.der enocded RSA public key in test does not appear to be a valid key #470

Closed

Description

@heartsucker

I noticed this when I was unable to get the ring library to verify an RSASSA-PSS signature.

heartsucker@pythagoras:~/code/misc/ring (master)$ openssl version
OpenSSL 1.1.0e  16 Feb 2017
heartsucker@pythagoras:~/code/misc/ring (master)$ openssl rsa -pubin -in ./src/rsa/signature_rsa_example_public_key.der -inform DER -outform PEM 
unable to load Public Key
139706476819648:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../crypto/asn1/tasn_dec.c:1112:
139706476819648:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../crypto/asn1/tasn_dec.c:274:Type=X509_ALGOR
139706476819648:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../crypto/asn1/tasn_dec.c:609:Field=algor, Type=X509_PUBKEY

Activity

  1. changed the title [-].der enocded RSA public key in test does not appear to a valid key[/-] [+].der enocded RSA public key in test does not appear to be a valid key[/+] on Mar 1, 2017
  2. lawliet89 commented on Mar 3, 2017

    @lawliet89
    Contributor

    Try it with openssl rsa -RSAPublicKey_in -in ./src/rsa/signature_rsa_example_public_key.der -inform DER -RSAPublicKey_out -outform PEM instead.

    The RSAPublicKey_in is different.

    Wrote the following documentation for my library after trying for an hour to figure out why my signature verification was not working:

    To generate the public key from your DER-encoded private key

    openssl rsa -in private_key.der \
                -inform DER
                -RSAPublicKey_out \
                -outform DER \
                -out public_key.der

    To convert a PEM formatted public key

    openssl rsa -RSAPublicKey_in \
                -in public_key.pem \
                -inform PEM \
                -outform DER \
                -RSAPublicKey_out \
                -out public_key.der
  3. briansmith commented on Mar 6, 2017

    @briansmith
    Owner

    Thanks to both of you for pointing this out. I'm going to close this in favor of landing #472, which will hopefully clear things up. I suspect #384 will also help people learn the right format to use. Also #378 will add support for parsing the RSAPublicKey format out of SubjectPublicKeyInfo format keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions