Code Monkey home page Code Monkey logo

Comments (2)

geitda avatar geitda commented on June 12, 2024

OpenSSL is apparently more forgiving and treats the negative integer as a positive one, essentially adding one null '00' octet on the front. The output from the command even shows it as "00:81:55:22..." even though that is NOT what's encoded in the ASN.1. OpenSSL does not try re-encoding the certificate, either: it will spit out exactly what it took in, so that representation is very misleading. However, openssl x509 -inform der -pubkey -noout < der_cert_bytes will produce a corrected key.
In short, however, this certificate is malformed, period.
asn1crypto doesn't make any such assumptions, and keeps it as a negative integer. I would have to imagine plenty of other crypto software would choke: see mirleft/ocaml-x509#56 (comment) for this exact same problem surfacing elsewhere, and I agree with the sentiment, "I am very reluctant to add warts to support other people's old bugs."

OpenSSL's own asn1parse command will show you that it's a negative value:

> openssl asn1parse -offset 146 -length 73 < der_cert_bytes
    0:d=0  hl=2 l=  71 cons: SEQUENCE
    2:d=1  hl=2 l=  64 prim: INTEGER           :-7EAADD46755B901229182699F0AA4328322A43B1BFFDDE5D4E0878CF7AA12D0DBB4623648A4904B9A0BD4962DCC9F421ABF03242E066D5EFA7EE34BF344A58BF
   68:d=1  hl=2 l=   3 prim: INTEGER           :010001

The offset is necessary since asn1parse won't try to read inside the bit-string where the public key is stored.

from asn1crypto.

AndyCWB avatar AndyCWB commented on June 12, 2024

@geitda I meant to respond to this earlier - thank you for the explanation. I also agree with not adding warts to support other people's old bugs, even though the project I'm working on is surfacing an awful lot of other people's old bugs!

from asn1crypto.

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.