Coder Social home page Coder Social logo

Comments (1)

armfazh avatar armfazh commented on September 27, 2024

The issue is that the size of P384 keys must be 48 bytes.

The zero byte at the beginning is due to the ANS1 encoding of octet strings. Look at this link

To get the right value, use the asn1 parser:

$ openssl ec -in key.pem | openssl asn1parse 
read EC key
writing EC key
    0:d=0  hl=3 l= 164 cons: SEQUENCE          
    3:d=1  hl=2 l=   1 prim: INTEGER           :01
    6:d=1  hl=2 l=  48 prim: OCTET STRING      [HEX DUMP]:E3247D99980FEB85A041DFAFF11DA95081F1FD9DF9CBCBD21237BD9131B79EB084FF24A5E2BA462677E234998F69483F
   56:d=1  hl=2 l=   7 cons: cont [ 0 ]        
   58:d=2  hl=2 l=   5 prim: OBJECT            :secp384r1
   65:d=1  hl=2 l= 100 cons: cont [ 1 ]        
   67:d=2  hl=2 l=  98 prim: BIT STRING      

More specifically:

$ openssl ec -in key.pem | openssl asn1parse -offset 6 -item ASN1_OCTET_STRING 
read EC key
writing EC key
ASN1_OCTET_STRING: 
  0000 - e3 24 7d 99 98 0f eb 85-a0 41 df af f1 1d a9 50   .$}......A.....P
  0010 - 81 f1 fd 9d f9 cb cb d2-12 37 bd 91 31 b7 9e b0   .........7..1...
  0020 - 84 ff 24 a5 e2 ba 46 26-77 e2 34 99 8f 69 48 3f   ..$...F&w.4..iH?

from circl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.