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

Side by Side Diff: third_party/tlslite/tlslite/utils/cryptomath.py

Issue 2881026: Replaced sha, md5 module imports with hashlib (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « third_party/tlslite/tlslite/messages.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """cryptomath module 1 """cryptomath module
2 2
3 This module has basic math/crypto code.""" 3 This module has basic math/crypto code."""
4 4
5 import os 5 import os
6 import math 6 import math
7 import base64 7 import base64
8 import binascii 8 import binascii
9 import sha 9
10 # The sha module is deprecated in Python 2.6
11 try:
12 import sha
13 except ImportError:
14 from hashlib import sha1 as sha
15
16 # The md5 module is deprecated in Python 2.6
17 try:
18 import md5
19 except ImportError:
20 from hashlib import md5
10 21
11 from compat import * 22 from compat import *
12 23
13 24
14 # ************************************************************************** 25 # **************************************************************************
15 # Load Optional Modules 26 # Load Optional Modules
16 # ************************************************************************** 27 # **************************************************************************
17 28
18 # Try to load M2Crypto/OpenSSL 29 # Try to load M2Crypto/OpenSSL
19 try: 30 try:
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (q >= high): 402 if (q >= high):
392 q = getRandomNumber(low, high) 403 q = getRandomNumber(low, high)
393 q += 29 - (q % 30) 404 q += 29 - (q % 30)
394 #Ideas from Tom Wu's SRP code 405 #Ideas from Tom Wu's SRP code
395 #Do trial division on p and q before Rabin-Miller 406 #Do trial division on p and q before Rabin-Miller
396 if isPrime(q, 0, display=display): 407 if isPrime(q, 0, display=display):
397 p = (2 * q) + 1 408 p = (2 * q) + 1
398 if isPrime(p, display=display): 409 if isPrime(p, display=display):
399 if isPrime(q, display=display): 410 if isPrime(q, display=display):
400 return p 411 return p
OLDNEW
« no previous file with comments | « third_party/tlslite/tlslite/messages.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698