OLD | NEW |
---|---|
1 """Class representing an X.509 certificate.""" | 1 """Class representing an X.509 certificate.""" |
2 | 2 |
3 from utils.ASN1Parser import ASN1Parser | 3 from utils.ASN1Parser import ASN1Parser |
4 from utils.cryptomath import * | 4 from utils.cryptomath import * |
5 from utils.keyfactory import _createPublicRSAKey | 5 from utils.keyfactory import _createPublicRSAKey |
6 | 6 |
7 | 7 |
8 class X509: | 8 class X509: |
9 """This class represents an X.509 certificate. | 9 """This class represents an X.509 certificate. |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 #Get the modulus and exponent | 92 #Get the modulus and exponent |
93 modulusP = subjectPublicKeyP.getChild(0) | 93 modulusP = subjectPublicKeyP.getChild(0) |
94 publicExponentP = subjectPublicKeyP.getChild(1) | 94 publicExponentP = subjectPublicKeyP.getChild(1) |
95 | 95 |
96 #Decode them into numbers | 96 #Decode them into numbers |
97 n = bytesToNumber(modulusP.value) | 97 n = bytesToNumber(modulusP.value) |
98 e = bytesToNumber(publicExponentP.value) | 98 e = bytesToNumber(publicExponentP.value) |
99 | 99 |
100 #Create a public key instance | 100 #Create a public key instance |
101 self.publicKey = _createPublicRSAKey(n, e) | 101 self.publicKey = _createPublicRSAKey(n, e) |
102 return self | |
Ryan Sleevi
2012/02/29 01:01:59
justification: matches line 45
| |
102 | 103 |
103 def getFingerprint(self): | 104 def getFingerprint(self): |
104 """Get the hex-encoded fingerprint of this certificate. | 105 """Get the hex-encoded fingerprint of this certificate. |
105 | 106 |
106 @rtype: str | 107 @rtype: str |
107 @return: A hex-encoded fingerprint. | 108 @return: A hex-encoded fingerprint. |
108 """ | 109 """ |
109 return sha.sha(self.bytes).hexdigest() | 110 return sha.sha(self.bytes).hexdigest() |
110 | 111 |
111 def getCommonName(self): | 112 def getCommonName(self): |
(...skipping 20 matching lines...) Expand all Loading... | |
132 if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND: | 133 if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND: |
133 returnVal = None | 134 returnVal = None |
134 return returnVal | 135 return returnVal |
135 finally: | 136 finally: |
136 cryptlib_py.cryptDestroyCert(c) | 137 cryptlib_py.cryptDestroyCert(c) |
137 | 138 |
138 def writeBytes(self): | 139 def writeBytes(self): |
139 return self.bytes | 140 return self.bytes |
140 | 141 |
141 | 142 |
OLD | NEW |