<s> """<STR_LIT>""" <EOL> from Crypto . Cipher import DES3 <EOL> from dfvfs . encryption import decrypter <EOL> from dfvfs . encryption import manager <EOL> from dfvfs . lib import definitions <EOL> class DES3Decrypter ( decrypter . Decrypter ) : <EOL> """<STR_LIT>""" <EOL> ENCRYPTION_METHOD = definitions . ENCRYPTION_METHOD_DES3 <EOL> ENCRYPTION_MODES = { <EOL> definitions . ENCRYPTION_MODE_CBC : DES3 . MODE_CBC , <EOL> definitions . ENCRYPTION_MODE_CFB : DES3 . MODE_CFB , <EOL> definitions . ENCRYPTION_MODE_ECB : DES3 . MODE_ECB , <EOL> definitions . ENCRYPTION_MODE_OFB : DES3 . MODE_OFB } <EOL> def __init__ ( self , key = None , mode = None , initialization_vector = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if not key : <EOL> raise ValueError ( u'<STR_LIT>' ) <EOL> if len ( key ) not in DES3 . key_size : <EOL> raise ValueError ( u'<STR_LIT>' ) <EOL> if initialization_vector is not None : <EOL> if len ( initialization_vector ) != DES3 . block_size : <EOL> raise ValueError ( u'<STR_LIT>' ) <EOL> else : <EOL> initialization_vector = <NUM_LIT:0> <EOL> if not mode : <EOL> raise ValueError ( u'<STR_LIT>' ) <EOL> if mode not in self . ENCRYPTION_MODES : <EOL> raise ValueError ( u'<STR_LIT>' . format ( mode ) ) <EOL> mode = self . ENCRYPTION_MODES [ mode ] <EOL> super ( DES3Decrypter , self ) . __init__ ( ) <EOL> self . _des3_cipher = DES3 . new ( key , mode = mode , IV = initialization_vector ) <EOL> def Decrypt ( self , encrypted_data ) : <EOL> """<STR_LIT>""" <EOL> index_split = - ( len ( encrypted_data ) % DES3 . block_size ) <EOL> if index_split : <EOL> remaining_encrypted_data = encrypted_data [ index_split : ] <EOL> encrypted_data = encrypted_data [ : index_split ] <EOL> else : <EOL> remaining_encrypted_data = b'<STR_LIT>' <EOL> decrypted_data = self . _des3_cipher . decrypt ( encrypted_data ) <EOL> return decrypted_data , remaining_encrypted_data <EOL> manager . EncryptionManager . RegisterDecrypter ( DES3Decrypter ) </s>
