Пример #1
0
    def test_string_encryption_100x(self):
        for i in range(0,100):
            message = "Lorem ipsum dolor sit amet, justo tortor praesent a dui at. Amet leo. Accumsan nec venenatis eget, imperdiet vitae pellentesque maecenas ut. Aut ac eleifend at nonummy nec, litora quam hymenaeos vehicula sed diam, blandit duis fermentum lacus ante, accumsan velit nonummy eleifend, id ante. Ultrices elit ipsum. Integer est, posuere sed duis odio. Praesent per ante eligendi etiam, integer convallis vestibulum et ultricies, porta mauris, ab dui a nulla vitae ac aliquet, erat sem integer. Fermentum risus nulla, risus eget mi. Taciti dui justo feugiat malesuada adipiscing arcu, ac sapien sed phasellus vitae porta, vel quisque mattis nunc ultricies fames, volutpat ipsum et. Mauris vestibulum justo augue phasellus lacinia, consectetuer urna ut, est consectetuer enim porta nulla. Viverra amet sodales nam duis maecenas, vitae quis ornare officia integer non, placeat tristique placerat at wisi sit, ut urna enim fusce sit et, amet libero pharetra. Morbi nascetur ipsum malesuada neque, mollis justo ipsum neque accumsan eget, nullam proin aliquam elementum."
            pre_shared_key = '0123456789qazWSXedcRFV'

            #generate the encrypted package
            enc_derived_key, enc_salt, enc_iv, real_gist_file_name = gister_transmit.generate_key_material(pre_shared_key)
            encrypted_package = gister_transmit.generate_upload_package(message, enc_derived_key, enc_iv, real_gist_file_name)
            
            #pass the encrypted package, key, and iv to the decrypter
            derived_key = gister_receive.gen_derived_key(pre_shared_key, enc_salt)
            decrypted_message = gister_receive.decrypt_message(encrypted_package, derived_key)

            self.assertTrue(decrypted_message == message)
Пример #2
0
    def test_encryption_large_blob_10x(self):
        blob_size = 100000
        for i in range(0,10):
            message = ''.join(chr(random.SystemRandom().randint(0,255)) for _ in range(random.SystemRandom().randint(blob_size,blob_size*10)))
            pre_shared_key = '0192837465OKMijnUHBygv'

            #generate the encrypted package
            enc_derived_key, enc_salt, enc_iv, real_gist_file_name = gister_transmit.generate_key_material(pre_shared_key)
            encrypted_package = gister_transmit.generate_upload_package(message, enc_derived_key, enc_iv, real_gist_file_name)
            
            #pass the encrypted package, key, and iv to the decrypter
            decrypted_message = gister_receive.decrypt_message(encrypted_package, enc_derived_key)

            self.assertTrue(decrypted_message == message)