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

Unified Diff: third_party/tlslite/patches/pycrypto_python2.patch

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 side-by-side diff with in-line comments
Download patch
Index: third_party/tlslite/patches/pycrypto_python2.patch
diff --git a/third_party/tlslite/patches/rsa_signature_length.patch b/third_party/tlslite/patches/pycrypto_python2.patch
similarity index 11%
rename from third_party/tlslite/patches/rsa_signature_length.patch
rename to third_party/tlslite/patches/pycrypto_python2.patch
index 5f936a5aab6da933478003e7d3982f3e5bc5b831..923c1d4d6b0ae5b67d4283ed5cf120237ac0676e 100644
--- a/third_party/tlslite/patches/rsa_signature_length.patch
+++ b/third_party/tlslite/patches/pycrypto_python2.patch
@@ -1,29 +1,51 @@
-diff --git a/third_party/tlslite/tlslite/utils/RSAKey.py b/third_party/tlslite/tlslite/utils/RSAKey.py
-index 37c292d..1b91742 100644
---- a/third_party/tlslite/tlslite/utils/RSAKey.py
-+++ b/third_party/tlslite/tlslite/utils/RSAKey.py
-@@ -117,7 +117,7 @@ class RSAKey:
- if m >= self.n:
- raise ValueError()
- c = self._rawPrivateKeyOp(m)
-- sigBytes = numberToBytes(c)
-+ sigBytes = numberToBytes(c, numBytes(self.n))
- return sigBytes
+diff --git a/third_party/tlslite/tlslite/utils/compat.py b/third_party/tlslite/tlslite/utils/compat.py
+index 2bcaede..db95ac1 100755
+--- a/third_party/tlslite/tlslite/utils/compat.py
++++ b/third_party/tlslite/tlslite/utils/compat.py
+@@ -51,6 +51,9 @@ if sys.version_info >= (3,0):
+ def readStdinBinary():
+ return sys.stdin.buffer.read()
- def verify(self, sigBytes, bytes):
++ def long(n):
++ return n
++
+ else:
+ # Python 2.6 requires strings instead of bytearrays in a couple places,
+ # so we define this function so it does the conversion if needed.
diff --git a/third_party/tlslite/tlslite/utils/cryptomath.py b/third_party/tlslite/tlslite/utils/cryptomath.py
-index 385095d..86da25e 100644
+index ce56b4b..30354b2 100755
--- a/third_party/tlslite/tlslite/utils/cryptomath.py
+++ b/third_party/tlslite/tlslite/utils/cryptomath.py
-@@ -129,8 +129,9 @@ def bytesToNumber(bytes):
+@@ -94,7 +94,9 @@ def bytesToNumber(b):
+ byte = b[count]
+ total += multiplier * byte
multiplier *= 256
- return total
+- return total
++ # Force-cast to long to appease PyCrypto.
++ # https://github.com/trevp/tlslite/issues/15
++ return long(total)
--def numberToBytes(n):
-- howManyBytes = numBytes(n)
-+def numberToBytes(n, howManyBytes=None):
-+ if howManyBytes == None:
-+ howManyBytes = numBytes(n)
- bytes = createByteArrayZeros(howManyBytes)
- for count in range(howManyBytes-1, -1, -1):
- bytes[count] = int(n % 256)
+ def numberToByteArray(n, howManyBytes=None):
+ """Convert an integer into a bytearray, zero-pad to howManyBytes.
+diff --git a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py b/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
+index 3d56228..4de5436 100755
+--- a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
++++ b/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
+@@ -26,13 +26,13 @@ if pycryptoLoaded:
+ return self.rsa.has_private()
+
+ def _rawPrivateKeyOp(self, m):
+- s = numberToString(m, numBytes(self.n))
+- 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, numBytes(self.n))
+- 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 generate(bits):

Powered by Google App Engine
This is Rietveld 408576698