MCPcopy Create free account
hub / github.com/mozilla/cipherscan / parse

Method parse

cscan/messages.py:99–122  ·  view source on GitHub ↗

Deserialise the object from binary data.

(self, parser)

Source from the content-addressed store, hash-verified

97 """Class with more robust certificate parsing and serialisation."""
98
99 def parse(self, parser):
100 """Deserialise the object from binary data."""
101 index = parser.index
102 try:
103 return super(Certificate, self).parse(parser)
104 except (AssertionError, SyntaxError):
105 pass
106 parser.index = index
107 parser.startLengthCheck(3)
108 if self.certificateType == CertificateType.x509:
109 chainLength = parser.get(3)
110 index = 0
111 certificate_list = []
112 while index != chainLength:
113 certBytes = parser.getVarBytes(3)
114 certificate_list.append(certBytes)
115 index += len(certBytes)+3
116 if certificate_list:
117 self.certChain = certificate_list
118 else:
119 raise AssertionError()
120
121 parser.stopLengthCheck()
122 return self
123
124 def __format__(self, formatstr):
125 """Advanced formatting for messages."""

Callers 1

parseMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected