]> Cypherpunks repositories - gostls13.git/commit
crypto/x509: memorize chain building.
authorAdam Langley <agl@golang.org>
Tue, 26 Apr 2011 14:26:22 +0000 (10:26 -0400)
committerAdam Langley <agl@golang.org>
Tue, 26 Apr 2011 14:26:22 +0000 (10:26 -0400)
commit8803d57f3e1c78c9e0ce3e50819c272db818c5ee
tree45022b8448aa0a6df05a8565cd34e6b76f69c05c
parent839e9eada0300387f678013f9dc50c47a277639b
crypto/x509: memorize chain building.

I ran the new verification code against a large number of certificates
with a huge (>1000) number of intermediates.

I had previously convinced myself that a cycle in the certificate
graph implied a cycle in the hash graph (and thus, a contradiction).
This is bogus because the signatures don't cover each other.

Secondly, I managed to drive the verification into a time explosion
with a fully connected graph of certificates. The code would try to
walk the factorial number of paths.

This change switches the CertPool to dealing with indexes of
certificates rather than pointers: this makes equality easy. (I didn't
want to compare pointers because a reasonable gc could move objects
around over time.)

Secondly, verification now memorizes the chains from a given
certificate. This is dynamic programming for the lazy, but there's a
solid reason behind it: dynamic programming would ignore the Issuer
hints that we can exploit by walking up the chain rather than down.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4439070
src/pkg/crypto/x509/cert_pool.go
src/pkg/crypto/x509/verify.go
src/pkg/crypto/x509/verify_test.go