Beispiel #1
0
def test_add_round_key_raises_exception_if_key_is_not_array():
    with pytest.raises(TypeError):
        aes.add_round_key(keys='foo',
                          state=np.random.randint(0, 255, (16), dtype='uint8'))
    with pytest.raises(TypeError):
        aes.add_round_key(keys=12,
                          state=np.random.randint(0, 255, (16), dtype='uint8'))
Beispiel #2
0
def test_add_round_key_raises_exception_if_key_and_state_dims_are_incompatible(
):
    with pytest.raises(ValueError):
        aes.add_round_key(keys=np.random.randint(0,
                                                 255, (12, 16),
                                                 dtype='uint8'),
                          state=np.random.randint(0,
                                                  255, (10, 16),
                                                  dtype='uint8'))
Beispiel #3
0
def test_add_round_key_raises_exception_if_key_is_not_a_correct_array():
    with pytest.raises(ValueError):
        aes.add_round_key(keys=np.random.randint(0,
                                                 255, (12, 12),
                                                 dtype='uint8'),
                          state=np.random.randint(0, 255, (16), dtype='uint8'))
    with pytest.raises(ValueError):
        aes.add_round_key(keys=np.random.randint(0,
                                                 255, (12, 16),
                                                 dtype='uint16'),
                          state=np.random.randint(0, 255, (16), dtype='uint8'))
Beispiel #4
0
def test_add_round_key_returns_correct_result_array_batch_of_1_key_and_n_rows_state(
        aes_data):
    state = aes_data['input_state']
    key = aes_data['input_round_key'][0]
    expected = aes_data['expected_add_round_key_1_key']
    assert np.array_equal(expected, aes.add_round_key(state=state, keys=key))
    assert expected.shape == state.shape
Beispiel #5
0
def test_add_round_key_returns_correct_result_array_batch_of_n_key_and_1_row_state(aes_datas):
    state = aes_datas['input_state'][0]
    key = aes_datas['input_round_key']
    expected = aes_datas['expected_add_round_key_1_state']
    assert np.array_equal(
        expected,
        aes.add_round_key(state=state, keys=key)
    )