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

Unified Diff: third_party/tlslite/tlslite/utils/pycrypto_rsakey.py

Issue 210323002: Update tlslite to 0.4.6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Executable bit and --similarity=80 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
diff --git a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py b/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
index 94e8578322f1c45d15bf0de1f1c67c3c23b4aeda..4de543638fb68ebc06d692eb06aab6b3cb52cfc6 100644
--- a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
+++ b/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
@@ -1,9 +1,12 @@
+# Author: Trevor Perrin
+# See the LICENSE file for legal information regarding use of this file.
+
"""PyCrypto RSA implementation."""
-from cryptomath import *
+from .cryptomath import *
-from rsakey import *
-from python_rsakey import Python_RSAKey
+from .rsakey import *
+from .python_rsakey import Python_RSAKey
if pycryptoLoaded:
@@ -22,40 +25,20 @@ if pycryptoLoaded:
def hasPrivateKey(self):
return self.rsa.has_private()
- def hash(self):
- return Python_RSAKey(self.n, self.e).hash()
-
def _rawPrivateKeyOp(self, m):
- s = numberToString(m)
- byteLength = numBytes(self.n)
- if len(s)== byteLength:
- pass
- elif len(s) == byteLength-1:
- s = '\0' + s
- else:
- raise AssertionError()
- c = stringToNumber(self.rsa.decrypt((s,)))
+ s = bytes(numberToByteArray(m, numBytes(self.n)))
+ c = bytesToNumber(bytearray(self.rsa.decrypt((s,))))
return c
def _rawPublicKeyOp(self, c):
- s = numberToString(c)
- byteLength = numBytes(self.n)
- if len(s)== byteLength:
- pass
- elif len(s) == byteLength-1:
- s = '\0' + s
- else:
- raise AssertionError()
- m = stringToNumber(self.rsa.encrypt(s, None)[0])
+ s = bytes(numberToByteArray(c, numBytes(self.n)))
+ m = bytesToNumber(bytearray(self.rsa.encrypt(s, None)[0]))
return m
- def writeXMLPublicKey(self, indent=''):
- return Python_RSAKey(self.n, self.e).write(indent)
-
def generate(bits):
key = PyCrypto_RSAKey()
def f(numBytes):
- return bytesToString(getRandomBytes(numBytes))
+ return bytes(getRandomBytes(numBytes))
key.rsa = RSA.generate(bits, f)
return key
generate = staticmethod(generate)
« no previous file with comments | « third_party/tlslite/tlslite/utils/pycrypto_rc4.py ('k') | third_party/tlslite/tlslite/utils/pycrypto_tripledes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698