Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/tlslite/tlslite/utils/asn1parser.py

Issue 210323002: Update tlslite to 0.4.6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rietveld, please behave Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Author: Trevor Perrin
2 # Patch from Google adding getChildBytes()
3 #
4 # See the LICENSE file for legal information regarding use of this file.
5
1 """Class for parsing ASN.1""" 6 """Class for parsing ASN.1"""
2 from compat import * 7 from .compat import *
3 from codec import * 8 from .codec import *
4 9
5 #Takes a byte array which has a DER TLV field at its head 10 #Takes a byte array which has a DER TLV field at its head
6 class ASN1Parser: 11 class ASN1Parser(object):
7 def __init__(self, bytes): 12 def __init__(self, bytes):
8 p = Parser(bytes) 13 p = Parser(bytes)
9 p.get(1) #skip Type 14 p.get(1) #skip Type
10 15
11 #Get Length 16 #Get Length
12 self.length = self._getASN1Length(p) 17 self.length = self._getASN1Length(p)
13 18
14 #Get Value 19 #Get Value
15 self.value = p.getFixBytes(self.length) 20 self.value = p.getFixBytes(self.length)
16 21
(...skipping 11 matching lines...) Expand all
28 return p.bytes[markIndex : p.index] 33 return p.bytes[markIndex : p.index]
29 34
30 #Decode the ASN.1 DER length field 35 #Decode the ASN.1 DER length field
31 def _getASN1Length(self, p): 36 def _getASN1Length(self, p):
32 firstLength = p.get(1) 37 firstLength = p.get(1)
33 if firstLength<=127: 38 if firstLength<=127:
34 return firstLength 39 return firstLength
35 else: 40 else:
36 lengthLength = firstLength & 0x7F 41 lengthLength = firstLength & 0x7F
37 return p.get(lengthLength) 42 return p.get(lengthLength)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698