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

Side by Side Diff: third_party/tlslite/tlslite/utils/cryptlib_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
(Empty)
1 """Cryptlib 3DES implementation."""
2
3 from cryptomath import *
4
5 from tripledes import *
6
7 if cryptlibpyLoaded:
8
9 def new(key, mode, IV):
10 return Cryptlib_TripleDES(key, mode, IV)
11
12 class Cryptlib_TripleDES(TripleDES):
13
14 def __init__(self, key, mode, IV):
15 TripleDES.__init__(self, key, mode, IV, "cryptlib")
16 self.context = cryptlib_py.cryptCreateContext(cryptlib_py.CRYPT_UNUS ED, cryptlib_py.CRYPT_ALGO_3DES)
17 cryptlib_py.cryptSetAttribute(self.context, cryptlib_py.CRYPT_CTXINF O_MODE, cryptlib_py.CRYPT_MODE_CBC)
18 cryptlib_py.cryptSetAttribute(self.context, cryptlib_py.CRYPT_CTXINF O_KEYSIZE, len(key))
19 cryptlib_py.cryptSetAttributeString(self.context, cryptlib_py.CRYPT_ CTXINFO_KEY, key)
20 cryptlib_py.cryptSetAttributeString(self.context, cryptlib_py.CRYPT_ CTXINFO_IV, IV)
21
22 def __del__(self):
23 cryptlib_py.cryptDestroyContext(self.context)
24
25 def encrypt(self, plaintext):
26 TripleDES.encrypt(self, plaintext)
27 bytes = stringToBytes(plaintext)
28 cryptlib_py.cryptEncrypt(self.context, bytes)
29 return bytesToString(bytes)
30
31 def decrypt(self, ciphertext):
32 TripleDES.decrypt(self, ciphertext)
33 bytes = stringToBytes(ciphertext)
34 cryptlib_py.cryptDecrypt(self.context, bytes)
35 return bytesToString(bytes)
OLDNEW
« no previous file with comments | « third_party/tlslite/tlslite/utils/cryptlib_rc4.py ('k') | third_party/tlslite/tlslite/utils/cryptomath.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698