OLD | NEW |
1 """Pure-Python RSA implementation.""" | 1 """Pure-Python RSA implementation.""" |
2 | 2 |
3 from cryptomath import * | 3 from cryptomath import * |
4 import xmltools | 4 import xmltools |
5 from ASN1Parser import ASN1Parser | 5 from asn1parser import ASN1Parser |
6 from RSAKey import * | 6 from rsakey import * |
7 | 7 |
8 class Python_RSAKey(RSAKey): | 8 class Python_RSAKey(RSAKey): |
9 def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): | 9 def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): |
10 if (n and not e) or (e and not n): | 10 if (n and not e) or (e and not n): |
11 raise AssertionError() | 11 raise AssertionError() |
12 self.n = n | 12 self.n = n |
13 self.e = e | 13 self.e = e |
14 self.d = d | 14 self.d = d |
15 self.p = p | 15 self.p = p |
16 self.q = q | 16 self.q = q |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 #Parse private values, if present | 200 #Parse private values, if present |
201 if element.childNodes.length>=3: | 201 if element.childNodes.length>=3: |
202 d = base64ToNumber(xmltools.getText(xmltools.getChild(element, 2, "d
"), xmltools.base64RegEx)) | 202 d = base64ToNumber(xmltools.getText(xmltools.getChild(element, 2, "d
"), xmltools.base64RegEx)) |
203 p = base64ToNumber(xmltools.getText(xmltools.getChild(element, 3, "p
"), xmltools.base64RegEx)) | 203 p = base64ToNumber(xmltools.getText(xmltools.getChild(element, 3, "p
"), xmltools.base64RegEx)) |
204 q = base64ToNumber(xmltools.getText(xmltools.getChild(element, 4, "q
"), xmltools.base64RegEx)) | 204 q = base64ToNumber(xmltools.getText(xmltools.getChild(element, 4, "q
"), xmltools.base64RegEx)) |
205 dP = base64ToNumber(xmltools.getText(xmltools.getChild(element, 5, "
dP"), xmltools.base64RegEx)) | 205 dP = base64ToNumber(xmltools.getText(xmltools.getChild(element, 5, "
dP"), xmltools.base64RegEx)) |
206 dQ = base64ToNumber(xmltools.getText(xmltools.getChild(element, 6, "
dQ"), xmltools.base64RegEx)) | 206 dQ = base64ToNumber(xmltools.getText(xmltools.getChild(element, 6, "
dQ"), xmltools.base64RegEx)) |
207 qInv = base64ToNumber(xmltools.getText(xmltools.getLastChild(element
, 7, "qInv"), xmltools.base64RegEx)) | 207 qInv = base64ToNumber(xmltools.getText(xmltools.getLastChild(element
, 7, "qInv"), xmltools.base64RegEx)) |
208 return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) | 208 return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) |
209 _parseXML = staticmethod(_parseXML) | 209 _parseXML = staticmethod(_parseXML) |
OLD | NEW |