# Path: record/encryption.py
# def kdf(key):
# def gen_nonce(bits = 32):
# def int2hex(integer):
# def aes_encrypt(key, plain):
# def aes_decrypt(key, ciphertext, plain_nonce, iv):
# def hmac_sha512(key, message):
# def encrypt_then_mac(key, plain):
# def decrypt_and_mac(key, message):


import sys
import unittest
import os
import random
from record import encryption
#! /usr/bin/env python2
# coding: utf8
sys.path.append("..")


def verify_format(testcase, encrypted_msg):
    testcase.assertEqual(len(encrypted_msg.split('$')), 4)
    for part in encrypted_msg.split('$'):
        testcase.assertIsInstance(part, str)
        testcase.assertTrue(len(part) > 0)
        try:
            part.decode("hex") # see if this rasies TypeError
        except TypeError:
            print part
            print encrypted_msg
            raise TypeError
    _ = int(encrypted_msg.split("$")[1], 16) # See if this rasies an error
    #method = hashed_msg.split('$')[0]
    #_ = getattr(hashing, 'hash_'+method) # See if this raises AttributeError


def verify_reproducible(testcase, plaintext_msg, encrypted_msg, key):

# Path: record/encryption.py
# def kdf(key):
# def gen_nonce(bits = 32):
# def int2hex(integer):
# def aes_encrypt(key, plain):
# def aes_decrypt(key, ciphertext, plain_nonce, iv):
# def hmac_sha512(key, message):
# def encrypt_then_mac(key, plain):
# def decrypt_and_mac(key, message):


# Path: test/test_encryption.py
import sys
import unittest
import os
import random
from record import encryption

#! /usr/bin/env python2
# coding: utf8
sys.path.append("..")


def verify_format(testcase, encrypted_msg):
    testcase.assertEqual(len(encrypted_msg.split('$')), 4)
    for part in encrypted_msg.split('$'):
        testcase.assertIsInstance(part, str)
        testcase.assertTrue(len(part) > 0)
        try:
            part.decode("hex") # see if this rasies TypeError
        except TypeError:
            print part
            print encrypted_msg
            raise TypeError
    _ = int(encrypted_msg.split("$")[1], 16) # See if this rasies an error
    #method = hashed_msg.split('$')[0]
    #_ = getattr(hashing, 'hash_'+method) # See if this raises AttributeError


def verify_reproducible(testcase, plaintext_msg, encrypted_msg, key):

    testcase.assertEquals(encryption.decrypt_and_mac(key, encrypted_msg), plaintext_msg)