Exemplo n.º 1
0
def test_encrypt_decrypt_large(key):
    message = """Output FeedBack (OFB). This mode is very similar to CBC, but 
    it transforms the underlying block cipher into a stream cipher. The 
    keystream is the iterated block encryption of an Initialization Vector (IV).

    The IV is a data block to be transmitted to the receiver. The IV can be 
    made public, but it should be picked randomly.

    Reusing the same IV for encryptions done with the same key lead to 
    catastrophic cryptograhic failures."""
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Exemplo n.º 2
0
def test_encrypt_decrypt_large(key):
    message = """Output FeedBack (OFB). This mode is very similar to CBC, but 
    it transforms the underlying block cipher into a stream cipher. The 
    keystream is the iterated block encryption of an Initialization Vector (IV).

    The IV is a data block to be transmitted to the receiver. The IV can be 
    made public, but it should be picked randomly.

    Reusing the same IV for encryptions done with the same key lead to 
    catastrophic cryptograhic failures."""
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Exemplo n.º 3
0
def test_encrypt_decrypt_zero_bytes(key):
    message = ''.join(chr(int(c)) for c in '0' * crypt.BLOCK)
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Exemplo n.º 4
0
def test_encrypt_decrypt_small(key):
    message = "This is the message to encrypt"
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Exemplo n.º 5
0
def test_encrypt_decrypt_zero_bytes(key):
	message = ''.join(chr(int(c)) for c in '0' * crypt.BLOCK)
	out = crypt.encrypt(message, key)
	assert message == crypt.decrypt(out, key)
Exemplo n.º 6
0
def test_encrypt_decrypt_small(key):
    message = "This is the message to encrypt"
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Exemplo n.º 7
0
def save_ciphertext(tmp_file, filename, pass_key):
    tmp_file.seek(0)
    ciphertext = crypt.encrypt(tmp_file.read(), pass_key)
    with open(filename, 'w') as f:
        f.write(ciphertext)