Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11130)

Issue 10944043: X509 module for parsing certificates

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 10 months ago by ekasper
Modified:
10 years, 9 months ago
CC:
ctlog-opensource-review_google.com
Visibility:
Public.

Description

X509 module for parsing certificates

Patch Set 1 #

Patch Set 2 : pychecker errors #

Total comments: 20

Patch Set 3 : Ben's comments #

Patch Set 4 : remove condition #

Patch Set 5 : y #

Patch Set 6 : wrap #

Total comments: 19

Patch Set 7 : comments #

Patch Set 8 : newline #

Patch Set 9 : fix flag parsing and add a missing wrap check #

Total comments: 8

Patch Set 10 : more comments #

Total comments: 13

Patch Set 11 : more comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1447 lines, --2 lines) Patch
M src/python/Makefile View 1 2 3 4 5 6 7 8 9 1 chunk +6 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/__init__.py View 1 2 3 4 5 6 0 chunks +-1 lines, --1 lines 0 comments Download
A src/python/ct/crypto/asn1/oid.py View 1 2 3 4 5 6 7 8 9 10 1 chunk +105 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/oid_test.py View 1 2 3 4 5 6 1 chunk +26 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/print_util.py View 1 2 3 4 5 6 7 8 9 10 1 chunk +87 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/print_util_test.py View 1 2 3 4 5 6 1 chunk +51 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/types.py View 1 2 3 4 5 6 7 8 9 1 chunk +349 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/types_test.py View 1 2 3 4 5 6 7 8 9 10 1 chunk +130 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/x509.py View 1 2 3 4 5 6 1 chunk +133 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/x509_name.py View 1 2 1 chunk +284 lines, -0 lines 0 comments Download
A src/python/ct/crypto/asn1/x509_name_test.py View 1 2 1 chunk +23 lines, -0 lines 0 comments Download
A src/python/ct/crypto/cert.py View 1 2 3 4 5 6 7 1 chunk +135 lines, -0 lines 0 comments Download
A src/python/ct/crypto/cert_test.py View 1 2 3 4 5 6 7 8 1 chunk +78 lines, -0 lines 0 comments Download
M src/python/ct/crypto/error.py View 1 chunk +8 lines, -0 lines 0 comments Download
A src/python/ct/crypto/testdata/google_cert.der View 0 chunks +-1 lines, --1 lines 0 comments Download
A src/python/ct/crypto/testdata/google_cert.pem View 1 chunk +34 lines, -0 lines 0 comments Download

Messages

Total messages: 10
ekasper
This CL implements the first half of RFC 5280 (todo: extensions and time). How to ...
10 years, 10 months ago (2013-07-04 18:45:14 UTC) #1
ekasper
I probably went a little OCD on the cert printing code but given how many ...
10 years, 10 months ago (2013-07-04 18:50:54 UTC) #2
Ben Laurie (Google)
DBC... Also, why is testdata/google_cert.der empty? https://codereview.appspot.com/10944043/diff/3001/src/python/ct/crypto/asn1/str_util.py File src/python/ct/crypto/asn1/str_util.py (right): https://codereview.appspot.com/10944043/diff/3001/src/python/ct/crypto/asn1/str_util.py#newcode5 src/python/ct/crypto/asn1/str_util.py:5: '[1,0,0,1,1,0,1,0,0,1,0]' becomes 04:d2. ...
10 years, 10 months ago (2013-07-05 09:32:19 UTC) #3
ekasper
the DER cert is not empty btw: diff --git a/src/python/ct/crypto/testdata/google_cert.der b/src/python/ct/crypto/testdata/google_cert.der new file mode 100644 ...
10 years, 10 months ago (2013-07-05 10:43:52 UTC) #4
Eran
Some comments. It's not a complete review, though. I will take a closer look at ...
10 years, 9 months ago (2013-07-08 18:27:12 UTC) #5
ekasper
https://codereview.appspot.com/10944043/diff/22001/src/python/ct/crypto/asn1/__init__.py File src/python/ct/crypto/asn1/__init__.py (right): https://codereview.appspot.com/10944043/diff/22001/src/python/ct/crypto/asn1/__init__.py#newcode1 src/python/ct/crypto/asn1/__init__.py:1: #!/usr/bin/env python On 2013/07/08 18:27:12, Eran wrote: > This ...
10 years, 9 months ago (2013-07-09 10:47:26 UTC) #6
Eran
https://codereview.appspot.com/10944043/diff/22001/src/python/ct/crypto/asn1/types.py File src/python/ct/crypto/asn1/types.py (right): https://codereview.appspot.com/10944043/diff/22001/src/python/ct/crypto/asn1/types.py#newcode67 src/python/ct/crypto/asn1/types.py:67: pass On 2013/07/09 10:47:26, ekasper wrote: > On 2013/07/08 ...
10 years, 9 months ago (2013-07-10 08:59:03 UTC) #7
ekasper
https://codereview.appspot.com/10944043/diff/38001/src/python/ct/crypto/asn1/types.py File src/python/ct/crypto/asn1/types.py (right): https://codereview.appspot.com/10944043/diff/38001/src/python/ct/crypto/asn1/types.py#newcode52 src/python/ct/crypto/asn1/types.py:52: class AbstractBaseType(object): On 2013/07/10 08:59:04, Eran wrote: > As ...
10 years, 9 months ago (2013-07-10 11:19:24 UTC) #8
Eran
Overall LGTM. Minor comments below, I believe the printing code is clearer now. https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/oid.py File ...
10 years, 9 months ago (2013-07-11 13:29:33 UTC) #9
ekasper
10 years, 9 months ago (2013-07-11 15:07:41 UTC) #10
Do you want to take another look or is the LGTM sticky?

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
File src/python/ct/crypto/asn1/oid.py (right):

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/oid.py:14: return _OID_NAME_DICT[self][1]
On 2013/07/11 13:29:33, Eran wrote:
> What's the benefit of looking up self in an external dictionary? A
> straightforward way would be to have the short and long names as optional
fields
> and simply return them. You could then avoid this dict, which means:
> * one less data structure around.
> * Clear mapping between oid and names (no need to see where the oid is mapped
to
> a name).

But who sets the name fields, and how? The ASN.1 wire encoding doesn't include
them...

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/oid.py:18: return ".".join(map(str, tuple(self)))
On 2013/07/11 13:29:33, Eran wrote:
> Seem this try/except clause is common between this and the next method,
consider
> extracting a common one.

Done, and simplified a bit.

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
File src/python/ct/crypto/asn1/print_util.py (right):

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/print_util.py:15: bitstring = "0"*pad_length +
"".join(map(str, bit_array))
On 2013/07/11 13:29:33, Eran wrote:
> Would it be possible to get to the byte representation without going through
the
> string representation? Simply extend the input array by pad_length zeros and
do
> the same iteration?

I don't know of a more straightforward way to convert a 0-1 int array to a byte,
do you?

However going to chr only to go back to ord in bytes_to_hex is unnecessary, so
I've killed that.

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/print_util.py:51: """Split long lines into multiple
chunks according to the wrap limit.
On 2013/07/11 13:29:33, Eran wrote:
> according to the wrap limit *and* newlines.

Clarified.

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/print_util.py:63: lines = []
On 2013/07/11 13:29:33, Eran wrote:
> nit: you have line and lines, two variables which differ by one character
only.
> Rename one of them to clarify what's input and what's output.

Done.

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
File src/python/ct/crypto/asn1/types_test.py (right):

https://codereview.appspot.com/10944043/diff/43001/src/python/ct/crypto/asn1/...
src/python/ct/crypto/asn1/types_test.py:52: s =
types.PrintableString(hello).string_value()
On 2013/07/11 13:29:33, Eran wrote:
> You could iterate over the types:
> for t in (types.PrintableString, types.UniversalString, ...):
>   s = t(hello).string_value()
>   self.assertTrue...

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b