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

Side by Side Diff: third_party/tlslite/tlslite/utils/tripledes.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Author: Trevor Perrin
2 # See the LICENSE file for legal information regarding use of this file.
3
1 """Abstract class for 3DES.""" 4 """Abstract class for 3DES."""
2 5
3 from compat import * #For True 6 class TripleDES(object):
4
5 class TripleDES:
6 def __init__(self, key, mode, IV, implementation): 7 def __init__(self, key, mode, IV, implementation):
7 if len(key) != 24: 8 if len(key) != 24:
8 raise ValueError() 9 raise ValueError()
9 if mode != 2: 10 if mode != 2:
10 raise ValueError() 11 raise ValueError()
11 if len(IV) != 8: 12 if len(IV) != 8:
12 raise ValueError() 13 raise ValueError()
13 self.isBlockCipher = True 14 self.isBlockCipher = True
14 self.block_size = 8 15 self.block_size = 8
15 self.implementation = implementation 16 self.implementation = implementation
16 self.name = "3des" 17 self.name = "3des"
17 18
18 #CBC-Mode encryption, returns ciphertext 19 #CBC-Mode encryption, returns ciphertext
19 #WARNING: *MAY* modify the input as well 20 #WARNING: *MAY* modify the input as well
20 def encrypt(self, plaintext): 21 def encrypt(self, plaintext):
21 assert(len(plaintext) % 8 == 0) 22 assert(len(plaintext) % 8 == 0)
22 23
23 #CBC-Mode decryption, returns plaintext 24 #CBC-Mode decryption, returns plaintext
24 #WARNING: *MAY* modify the input as well 25 #WARNING: *MAY* modify the input as well
25 def decrypt(self, ciphertext): 26 def decrypt(self, ciphertext):
26 assert(len(ciphertext) % 8 == 0) 27 assert(len(ciphertext) % 8 == 0)
OLDNEW
« no previous file with comments | « third_party/tlslite/tlslite/utils/tackwrapper.py ('k') | third_party/tlslite/tlslite/utils/win32prng.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698