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

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: 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
« no previous file with comments | « third_party/tlslite/patches/parse_chain.patch ('k') | third_party/tlslite/patches/python26.patch » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tlslite/patches/pycrypto_python2.patch
diff --git a/third_party/tlslite/patches/pycrypto_python2.patch b/third_party/tlslite/patches/pycrypto_python2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..923c1d4d6b0ae5b67d4283ed5cf120237ac0676e
--- /dev/null
+++ b/third_party/tlslite/patches/pycrypto_python2.patch
@@ -0,0 +1,51 @@
+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 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 ce56b4b..30354b2 100755
+--- a/third_party/tlslite/tlslite/utils/cryptomath.py
++++ b/third_party/tlslite/tlslite/utils/cryptomath.py
+@@ -94,7 +94,9 @@ def bytesToNumber(b):
+ byte = b[count]
+ total += multiplier * byte
+ multiplier *= 256
+- return total
++ # Force-cast to long to appease PyCrypto.
++ # https://github.com/trevp/tlslite/issues/15
++ return long(total)
+
+ 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):
« no previous file with comments | « third_party/tlslite/patches/parse_chain.patch ('k') | third_party/tlslite/patches/python26.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698