def testComparable(self): """Tests the path specification comparable property.""" path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=u'test', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = u'\n'.join([ u'type: TEST', u'type: ENCRYPTED_STREAM, encryption_method: test', u'' ]) self.assertEqual(path_spec.comparable, expected_comparable) # Test with credentials. path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( cipher_mode=definitions.ENCRYPTION_MODE_CBC, encryption_method=u'test', initialization_vector=u'This is IV.', key=u'This is key.', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = u'\n'.join([ u'type: TEST', (u'type: ENCRYPTED_STREAM, cipher_mode: cbc, encryption_method: test, ' u'initialization_vector: 546869732069732049562e, ' u'key: 54686973206973206b65792e'), u'' ]) self.assertEqual(path_spec.comparable, expected_comparable)
def testComparable(self): """Tests the path specification comparable property.""" path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method='test', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = '\n'.join([ 'type: TEST', 'type: ENCRYPTED_STREAM, encryption_method: test', '']) self.assertEqual(path_spec.comparable, expected_comparable) # Test with credentials. path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( cipher_mode=definitions.ENCRYPTION_MODE_CBC, encryption_method='test', initialization_vector=b'\x54\x68\x69\x73\x20\x69\x73\x20\x49\x56\x2e', key=b'\x54\x68\x69\x73\x20\x69\x73\x20\x6b\x65\x79\x2e', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = '\n'.join([ 'type: TEST', ('type: ENCRYPTED_STREAM, cipher_mode: cbc, encryption_method: test, ' 'initialization_vector: 546869732069732049562e, ' 'key: 54686973206973206b65792e'), '']) self.assertEqual(path_spec.comparable, expected_comparable)
def testInitialize(self): """Tests the path specification initialization.""" path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method='test', parent=self._path_spec) self.assertIsNotNone(path_spec) with self.assertRaises(ValueError): encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method='test', parent=None) with self.assertRaises(ValueError): encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=None, parent=self._path_spec) with self.assertRaises(ValueError): encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method='test', parent=self._path_spec, bogus='BOGUS')
def GetRootFileEntry(self): """Retrieves the root file entry. Returns: A file entry (instance of vfs.FileEntry) or None. """ path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=self._encryption_method, parent=self._path_spec.parent) return self.GetFileEntryByPathSpec(path_spec)
def GetRootFileEntry(self): """Retrieves the root file entry. Returns: EncryptedStreamFileEntry: a file entry or None if not available. """ path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=self._encryption_method, parent=self._path_spec.parent) return self.GetFileEntryByPathSpec(path_spec)
def setUp(self): """Sets up the needed objects used throughout the test.""" self._resolver_context = context.Context() test_file = self._GetTestFilePath(['syslog.rc4']) path_spec = os_path_spec.OSPathSpec(location=test_file) self._encrypted_stream_path_spec = ( encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=definitions.ENCRYPTION_METHOD_RC4, parent=path_spec)) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, 'key', self._RC4_KEY)
def testComparable(self): """Tests the path specification comparable property.""" path_spec = encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=u'test', parent=self._path_spec) self.assertIsNotNone(path_spec) expected_comparable = u'\n'.join([ u'type: TEST', u'type: ENCRYPTED_STREAM, encryption_method: test', u'' ]) self.assertEqual(path_spec.comparable, expected_comparable)
def setUp(self): """Sets up the needed objects used throughout the test.""" self._resolver_context = context.Context() test_file = self._GetTestFilePath([u'syslog.aes']) self._os_path_spec = os_path_spec.OSPathSpec(location=test_file) self._encrypted_stream_path_spec = ( encrypted_stream_path_spec.EncryptedStreamPathSpec( cipher_mode=self._AES_CIPHER_MODE, encryption_method=definitions.ENCRYPTION_METHOD_AES, initialization_vector=self._AES_INITIALIZATION_VECTOR, key=self._AES_KEY, parent=self._os_path_spec)) self.padding_size = 1
def setUp(self): """Sets up the needed objects used throughout the test.""" self._resolver_context = context.Context() test_file = os.path.join(u'test_data', u'syslog.aes') self._os_path_spec = os_path_spec.OSPathSpec(location=test_file) self._encrypted_stream_path_spec = ( encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=definitions.ENCRYPTION_METHOD_AES, parent=self._os_path_spec)) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'key', self._AES_KEY) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'initialization_vector', self._AES_IV) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'mode', self._AES_MODE) self.padding_size = 1
def setUp(self): """Sets up the needed objects used throughout the test.""" self._resolver_context = context.Context() test_file = self._GetTestFilePath([u'syslog.des3']) self._os_path_spec = os_path_spec.OSPathSpec(location=test_file) self._encrypted_stream_path_spec = ( encrypted_stream_path_spec.EncryptedStreamPathSpec( encryption_method=definitions.ENCRYPTION_METHOD_DES3, parent=self._os_path_spec)) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'key', self._DES3_KEY) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'initialization_vector', self._DES3_IV) resolver.Resolver.key_chain.SetCredential( self._encrypted_stream_path_spec, u'cipher_mode', self._DES3_MODE) self.padding_size = 1