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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 diff --git a/third_party/tlslite/tlslite/utils/RSAKey.py b/third_party/tlslite/t lslite/utils/RSAKey.py 1 diff --git a/third_party/tlslite/tlslite/utils/compat.py b/third_party/tlslite/t lslite/utils/compat.py
2 index 37c292d..1b91742 100644 2 index 2bcaede..db95ac1 100755
3 --- a/third_party/tlslite/tlslite/utils/RSAKey.py 3 --- a/third_party/tlslite/tlslite/utils/compat.py
4 +++ b/third_party/tlslite/tlslite/utils/RSAKey.py 4 +++ b/third_party/tlslite/tlslite/utils/compat.py
5 @@ -117,7 +117,7 @@ class RSAKey: 5 @@ -51,6 +51,9 @@ if sys.version_info >= (3,0):
6 if m >= self.n: 6 def readStdinBinary():
7 raise ValueError() 7 return sys.stdin.buffer.read()
8 c = self._rawPrivateKeyOp(m)
9 - sigBytes = numberToBytes(c)
10 + sigBytes = numberToBytes(c, numBytes(self.n))
11 return sigBytes
12 8
13 def verify(self, sigBytes, bytes): 9 + def long(n):
10 + return n
11 +
12 else:
13 # Python 2.6 requires strings instead of bytearrays in a couple places,
14 # so we define this function so it does the conversion if needed.
14 diff --git a/third_party/tlslite/tlslite/utils/cryptomath.py b/third_party/tlsli te/tlslite/utils/cryptomath.py 15 diff --git a/third_party/tlslite/tlslite/utils/cryptomath.py b/third_party/tlsli te/tlslite/utils/cryptomath.py
15 index 385095d..86da25e 100644 16 index ce56b4b..30354b2 100755
16 --- a/third_party/tlslite/tlslite/utils/cryptomath.py 17 --- a/third_party/tlslite/tlslite/utils/cryptomath.py
17 +++ b/third_party/tlslite/tlslite/utils/cryptomath.py 18 +++ b/third_party/tlslite/tlslite/utils/cryptomath.py
18 @@ -129,8 +129,9 @@ def bytesToNumber(bytes): 19 @@ -94,7 +94,9 @@ def bytesToNumber(b):
20 byte = b[count]
21 total += multiplier * byte
19 multiplier *= 256 22 multiplier *= 256
20 return total 23 - return total
24 + # Force-cast to long to appease PyCrypto.
25 + # https://github.com/trevp/tlslite/issues/15
26 + return long(total)
21 27
22 -def numberToBytes(n): 28 def numberToByteArray(n, howManyBytes=None):
23 - howManyBytes = numBytes(n) 29 """Convert an integer into a bytearray, zero-pad to howManyBytes.
24 +def numberToBytes(n, howManyBytes=None): 30 diff --git a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py b/third_party/ tlslite/tlslite/utils/pycrypto_rsakey.py
25 + if howManyBytes == None: 31 index 3d56228..4de5436 100755
26 + howManyBytes = numBytes(n) 32 --- a/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
27 bytes = createByteArrayZeros(howManyBytes) 33 +++ b/third_party/tlslite/tlslite/utils/pycrypto_rsakey.py
28 for count in range(howManyBytes-1, -1, -1): 34 @@ -26,13 +26,13 @@ if pycryptoLoaded:
29 bytes[count] = int(n % 256) 35 return self.rsa.has_private()
36
37 def _rawPrivateKeyOp(self, m):
38 - s = numberToString(m, numBytes(self.n))
39 - c = stringToNumber(self.rsa.decrypt((s,)))
40 + s = bytes(numberToByteArray(m, numBytes(self.n)))
41 + c = bytesToNumber(bytearray(self.rsa.decrypt((s,))))
42 return c
43
44 def _rawPublicKeyOp(self, c):
45 - s = numberToString(c, numBytes(self.n))
46 - m = stringToNumber(self.rsa.encrypt(s, None)[0])
47 + s = bytes(numberToByteArray(c, numBytes(self.n)))
48 + m = bytesToNumber(bytearray(self.rsa.encrypt(s, None)[0]))
49 return m
50
51 def generate(bits):
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698