Package viff :: Module aes :: Class AES
[hide private]
[frames] | no frames]

Class AES

source code

AES instantiation.

This class is used together with a viff.runtime.Runtime object:

aes = AES(runtime, 192)
cleartext = [Share(runtime, GF256, GF256(0)) for i in range(128/8)]
key = [runtime.prss_share_random(GF256) for i in range(192/8)]
ciphertext = aes.encrypt("abcdefghijklmnop", key)
ciphertext = aes.encrypt(cleartext, "keykeykeykeykeykeykeykey")
ciphertext = aes.encrypt(cleartext, key)

In every case ciphertext will be a list of shares over GF256.

Instance Methods [hide private]
 
__init__(self, runtime, key_size, block_size=128, use_exponentiation=False, quiet=False)
Initialize Rijndael.
source code
 
invert_by_masking(self, byte) source code
 
invert_by_masked_exponentiation(self, byte) source code
 
invert_by_exponentiation(self, byte) source code
 
invert_by_exponentiation_with_less_rounds(self, byte) source code
 
invert_by_exponentiation_with_least_rounds(self, byte) source code
 
byte_sub(self, state, use_lin_comb=True)
ByteSub operation of Rijndael.
source code
 
shift_row(self, state)
Rijndael ShiftRow.
source code
 
mix_column(self, state, use_lin_comb=True)
Rijndael MixColumn.
source code
 
add_round_key(self, state, round_key)
Rijndael AddRoundKey.
source code
 
key_expansion(self, key, new_length=None)
Rijndael key expansion.
source code
 
preprocess(self, input) source code
 
encrypt(self, cleartext, key, benchmark=False, prepare_at_once=False)
Rijndael encryption.
source code
Class Variables [hide private]
  exponentiation_variants = ['standard_square_and_multiply', 'sh...
  A = Matrix([[1, 0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1, 1,...
  C = Matrix(C)
  i = 3
  row = [[3], [1], [1], [2]]
Method Details [hide private]

__init__(self, runtime, key_size, block_size=128, use_exponentiation=False, quiet=False)
(Constructor)

source code 

Initialize Rijndael.

AES(runtime, key_size, block_size), whereas key size and block size must be given in bits. Block size defaults to 128.

byte_sub(self, state, use_lin_comb=True)

source code 

ByteSub operation of Rijndael.

The first argument should be a matrix consisting of elements of GF(2^8).

shift_row(self, state)

source code 

Rijndael ShiftRow.

State should be a list of 4 rows.

mix_column(self, state, use_lin_comb=True)

source code 

Rijndael MixColumn.

Input should be a list of 4 rows.

add_round_key(self, state, round_key)

source code 

Rijndael AddRoundKey.

State should be a list of 4 rows and round_key a list of 4-byte columns (words).

key_expansion(self, key, new_length=None)

source code 

Rijndael key expansion.

Input and output are lists of 4-byte columns (words). new_length is the round for which the key should be expanded. If ommitted, the key is expanded for all rounds.

encrypt(self, cleartext, key, benchmark=False, prepare_at_once=False)

source code 

Rijndael encryption.

Cleartext and key should be either a string or a list of bytes (possibly shared as elements of GF256).


Class Variable Details [hide private]

exponentiation_variants

Value:
['standard_square_and_multiply',
 'shortest_sequential_chain',
 'shortest_chain_with_least_rounds',
 'chain_with_least_rounds',
 'masked']

A

Value:
Matrix([[1, 0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1, 1], [1, \
1, 1, 0, 0, 0, 1, 1, 0], [1, 1, 1, 1, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, \
0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 0, 1],\
 [0, 0, 0, 1, 1, 1, 1, 1, 0]])