# Path: aespython/aes_tables.py



from .aes_tables import sbox,rcon
AES Key Expansion

Expands 128, 192, or 256 bit key for use with AES

Algorithm per NIST FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf

Copyright (c) 2010, Adam Newman http://www.caller9.com
Licensed under the MIT license http://www.opensource.org/licenses/mit-license.php
"""
__all__ = "expandKey",
_expanded_key_length={16:176,24:208,32:240}
def expandKey(new_key):
    """Expand the encryption key per AES key schedule specifications
        http://en.wikipedia.org/wiki/Rijndael_key_schedule#Key_schedule_description"""
    _n=len(new_key)
    if _n not in (16,24,32):
        raise RuntimeError('expand(): key size is invalid')
    rcon_iter=1
    _nn16=_n!=16
    _n32=_n==32
    n0=new_key[-4]
    n1=new_key[-3]
    n2=new_key[-2]
    n3=new_key[-1]
    _n0=-_n
    _n1=1-_n
    _n2=2-_n
    _n3=3-_n
    _n=_expanded_key_length[_n]-_n
    nex=new_key.extend

# Path: aespython/aes_tables.py



# Path: aespython/key_expander.py
from .aes_tables import sbox,rcon

AES Key Expansion

Expands 128, 192, or 256 bit key for use with AES

Algorithm per NIST FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf

Copyright (c) 2010, Adam Newman http://www.caller9.com
Licensed under the MIT license http://www.opensource.org/licenses/mit-license.php
"""
__all__ = "expandKey",
_expanded_key_length={16:176,24:208,32:240}
def expandKey(new_key):
    """Expand the encryption key per AES key schedule specifications
        http://en.wikipedia.org/wiki/Rijndael_key_schedule#Key_schedule_description"""
    _n=len(new_key)
    if _n not in (16,24,32):
        raise RuntimeError('expand(): key size is invalid')
    rcon_iter=1
    _nn16=_n!=16
    _n32=_n==32
    n0=new_key[-4]
    n1=new_key[-3]
    n2=new_key[-2]
    n3=new_key[-1]
    _n0=-_n
    _n1=1-_n
    _n2=2-_n
    _n3=3-_n
    _n=_expanded_key_length[_n]-_n
    nex=new_key.extend

    while 1: