File: rc4_decrypter.py

package info (click to toggle)
dfvfs 20201219-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 284,900 kB
  • sloc: python: 30,025; vhdl: 1,921; sh: 465; makefile: 16
file content (35 lines) | stat: -rw-r--r-- 931 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for the RC4 decrypter object."""

from __future__ import unicode_literals

import unittest

from dfvfs.encryption import rc4_decrypter

from tests.encryption import test_lib


class RC4DecrypterTestCase(test_lib.DecrypterTestCase):
  """Tests for the RC4 decrypter object."""

  def testInitialize(self):
    """Tests the __init__ method."""
    decrypter = rc4_decrypter.RC4Decrypter(key=b'test1')
    self.assertIsNotNone(decrypter)

    with self.assertRaises(ValueError):
      rc4_decrypter.RC4Decrypter()

  def testDecrypt(self):
    """Tests the Decrypt method."""
    decrypter = rc4_decrypter.RC4Decrypter(key=b'test1')

    decrypted_data, _ = decrypter.Decrypt(b'\xef6\xcd\x14\xfe\xf5+y')
    expected_decrypted_data = b'\x01\x02\x03\x04\x05\x06\x07\x08'
    self.assertEqual(decrypted_data, expected_decrypted_data)


if __name__ == '__main__':
  unittest.main()