# Path: auxlib/crypt.py
#     AES_BLOCK_SIZE = AES.block_size
# AES_KEY_SIZE = 32   # 32 byte key size ==> AES-256
# HMAC_SIG_SIZE = hashlib.sha256().digest_size
# def encrypt(secret_key, data):
# def decrypt(secret_key, encryption_key_encrypted, encrypted_data):
# def as_base64(content):
# def from_base64(content):
# def generate_encryption_key():
# def generate_hash_from_secret(secret):
# def aes_encrypt(base64_encryption_key, data):
# def aes_decrypt(base64_encryption_key, base64_data):
# def _pad(s):
# def _unpad(s):
# def _extract_keys(key_str):
# 
# Path: auxlib/crypt.py
#     AES_BLOCK_SIZE = AES.block_size
# AES_KEY_SIZE = 32   # 32 byte key size ==> AES-256
# HMAC_SIG_SIZE = hashlib.sha256().digest_size
# def encrypt(secret_key, data):
# def decrypt(secret_key, encryption_key_encrypted, encrypted_data):
# def as_base64(content):
# def from_base64(content):
# def generate_encryption_key():
# def generate_hash_from_secret(secret):
# def aes_encrypt(base64_encryption_key, data):
# def aes_decrypt(base64_encryption_key, base64_data):
# def _pad(s):
# def _unpad(s):
# def _extract_keys(key_str):


from unittest import TestCase
from auxlib import crypt
from auxlib.crypt import AuthenticationError, encrypt, decrypt
import os
        self.assertEqual(crypt.from_base64(crypt.as_base64(test_str)),
                         test_str)


class TestKeyCreation(TestCase):

    def test_create_keys(self):
        key = crypt.generate_encryption_key()
        self.assertEquals(len(crypt.from_base64(key)),
                          crypt.AES_KEY_SIZE + crypt.HMAC_SIG_SIZE)

        # generate new key, and make sure it's different than the last
        self.assertNotEqual(crypt.generate_encryption_key(), key)

    def test_hashing_secret(self):
        secret = 'test secret'
        key_hash = crypt.generate_hash_from_secret(secret)
        self.assertEquals(len(crypt.from_base64(key_hash)),
                          crypt.AES_KEY_SIZE + crypt.HMAC_SIG_SIZE)

        # hash should always be the same
        self.assertEqual(key_hash, crypt.generate_hash_from_secret(secret))


class TestAESEncryption(TestCase):

    def test_encrypt_and_decrypt_end_to_end(self):
        test_data = u"Mickey & Miννie Μouse"
        encryption_key = crypt.generate_encryption_key()
        encrypted_data = crypt.aes_encrypt(encryption_key, test_data)

# Path: auxlib/crypt.py
#     AES_BLOCK_SIZE = AES.block_size
# AES_KEY_SIZE = 32   # 32 byte key size ==> AES-256
# HMAC_SIG_SIZE = hashlib.sha256().digest_size
# def encrypt(secret_key, data):
# def decrypt(secret_key, encryption_key_encrypted, encrypted_data):
# def as_base64(content):
# def from_base64(content):
# def generate_encryption_key():
# def generate_hash_from_secret(secret):
# def aes_encrypt(base64_encryption_key, data):
# def aes_decrypt(base64_encryption_key, base64_data):
# def _pad(s):
# def _unpad(s):
# def _extract_keys(key_str):
# 
# Path: auxlib/crypt.py
#     AES_BLOCK_SIZE = AES.block_size
# AES_KEY_SIZE = 32   # 32 byte key size ==> AES-256
# HMAC_SIG_SIZE = hashlib.sha256().digest_size
# def encrypt(secret_key, data):
# def decrypt(secret_key, encryption_key_encrypted, encrypted_data):
# def as_base64(content):
# def from_base64(content):
# def generate_encryption_key():
# def generate_hash_from_secret(secret):
# def aes_encrypt(base64_encryption_key, data):
# def aes_decrypt(base64_encryption_key, base64_data):
# def _pad(s):
# def _unpad(s):
# def _extract_keys(key_str):


# Path: tests/test_crypt.py
from unittest import TestCase
from auxlib import crypt
from auxlib.crypt import AuthenticationError, encrypt, decrypt
import os

        self.assertEqual(crypt.from_base64(crypt.as_base64(test_str)),
                         test_str)


class TestKeyCreation(TestCase):

    def test_create_keys(self):
        key = crypt.generate_encryption_key()
        self.assertEquals(len(crypt.from_base64(key)),
                          crypt.AES_KEY_SIZE + crypt.HMAC_SIG_SIZE)

        # generate new key, and make sure it's different than the last
        self.assertNotEqual(crypt.generate_encryption_key(), key)

    def test_hashing_secret(self):
        secret = 'test secret'
        key_hash = crypt.generate_hash_from_secret(secret)
        self.assertEquals(len(crypt.from_base64(key_hash)),
                          crypt.AES_KEY_SIZE + crypt.HMAC_SIG_SIZE)

        # hash should always be the same
        self.assertEqual(key_hash, crypt.generate_hash_from_secret(secret))


class TestAESEncryption(TestCase):

    def test_encrypt_and_decrypt_end_to_end(self):
        test_data = u"Mickey & Miννie Μouse"
        encryption_key = crypt.generate_encryption_key()
        encrypted_data = crypt.aes_encrypt(encryption_key, test_data)

        decrypted_data = crypt.aes_decrypt(encryption_key, encrypted_data)