File: dump_sctlist.py

package info (click to toggle)
golang-github-google-certificate-transparency 0.0~git20160709.0.0f6e3d1~ds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 5,676 kB
  • sloc: cpp: 35,278; python: 11,838; java: 1,911; sh: 1,885; makefile: 950; xml: 520; ansic: 225
file content (30 lines) | stat: -rwxr-xr-x 1,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
""" This is a util to dump the SCTs contained within a
    SignedCertificateTimestampList structure.
    This structure is used to represent a collection of SCTs being passed over
    a TLS handshake.  See RFC6962 section 3.3 for more details. """
import sys
from ct.proto import client_pb2
from ct.serialization import tls_message

def dump_sctlist(sct_list):
    """Prints the proto representation of the SCTs contained in sct_list.
       Arguments:
       sct_list the packed SignedCertificateTransparencyList structure.
    """
    tr = tls_message.TLSReader(sct_list)
    sctlist = client_pb2.SignedCertificateTimestampList()
    tr.read(sctlist)
    for s in sctlist.sct_list:
        sct = client_pb2.SignedCertificateTimestamp()
        tls_message.decode(s, sct)
        print sct

if __name__ == "__main__":
    if len(sys.argv) == 1:
        print "Usage: dump_sctlist.py <file_containing_sct_list>"
        sys.exit(1)

    with open(sys.argv[1]) as f:
        data = f.read()
    dump_sctlist(data)