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

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

Issue 875683002: Implement AES-GCM in tlslite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « third_party/tlslite/tlslite/utils/rc4.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 # Author: Trevor Perrin 1 # Author: Trevor Perrin
2 # See the LICENSE file for legal information regarding use of this file. 2 # See the LICENSE file for legal information regarding use of this file.
3 3
4 """Abstract class for 3DES.""" 4 """Abstract class for 3DES."""
5 5
6 class TripleDES(object): 6 class TripleDES(object):
7 def __init__(self, key, mode, IV, implementation): 7 def __init__(self, key, mode, IV, implementation):
8 if len(key) != 24: 8 if len(key) != 24:
9 raise ValueError() 9 raise ValueError()
10 if mode != 2: 10 if mode != 2:
11 raise ValueError() 11 raise ValueError()
12 if len(IV) != 8: 12 if len(IV) != 8:
13 raise ValueError() 13 raise ValueError()
14 self.isBlockCipher = True 14 self.isBlockCipher = True
15 self.isAEAD = False
15 self.block_size = 8 16 self.block_size = 8
16 self.implementation = implementation 17 self.implementation = implementation
17 self.name = "3des" 18 self.name = "3des"
18 19
19 #CBC-Mode encryption, returns ciphertext 20 #CBC-Mode encryption, returns ciphertext
20 #WARNING: *MAY* modify the input as well 21 #WARNING: *MAY* modify the input as well
21 def encrypt(self, plaintext): 22 def encrypt(self, plaintext):
22 assert(len(plaintext) % 8 == 0) 23 assert(len(plaintext) % 8 == 0)
23 24
24 #CBC-Mode decryption, returns plaintext 25 #CBC-Mode decryption, returns plaintext
25 #WARNING: *MAY* modify the input as well 26 #WARNING: *MAY* modify the input as well
26 def decrypt(self, ciphertext): 27 def decrypt(self, ciphertext):
27 assert(len(ciphertext) % 8 == 0) 28 assert(len(ciphertext) % 8 == 0)
OLDNEW
« no previous file with comments | « third_party/tlslite/tlslite/utils/rc4.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698