Git Product home page Git Product logo

ctutils's People

Contributors

fotisl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ctutils's Issues

Incorrect SignedCertificateTimestamp encoding/decoding

Good job, Fotis!

But your decoding/encoding of SignedCertificateTimestamp is not precisely correct. Your problem that you missed just one detail in documentation.

So, definition of the SignedCertificateTimestamp class looks like:

struct {
	Version sct_version;
	LogID id;
	uint64 timestamp;
	CtExtensions extensions;
	digitally-signed struct {
		Version sct_version;
		SignatureType signature_type = certificate_timestamp;
		uint64 timestamp;
		LogEntryType entry_type;
		select(entry_type) {
			case x509_entry: ASN.1Cert;
			case precert_entry: PreCert;
		} signed_entry;
		CtExtensions extensions;
	};
} SignedCertificateTimestamp;

And in fact you decoded almost all from the data. Except that you missed that digitally-signed is itself a pre-defined type:

struct {
   SignatureAndHashAlgorithm algorithm;
   opaque signature<0..2^16-1>;
} DigitallySigned;

And the SignatureAndHashAlgorithm has this definition:

enum {
    none(0), md5(1), sha1(2), sha224(3), sha256(4), sha384(5),
    sha512(6), (255)
} HashAlgorithm;

enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), (255) }
  SignatureAlgorithm;

struct {
      HashAlgorithm hash;
      SignatureAlgorithm signature;
} SignatureAndHashAlgorithm;

And when you decode signature like this:

const signature = sctBinView.slice(43 + extLen).buffer;

then you loose information about hashAlgorithm, signatureAlgorithm and correct signatureLength - all these would be in your incorrect block for signature.

For the further reading I do recommend you this link.

Also I want to say that recently I append to PKIjs support for decoding/encoding the SignedCertificateTimestamp class - check it here. There is no verify function there, but probably I would implement it soon.

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.