예제 #1
0
def test_add_round_key_raises_exception_if_key_is_not_array():
    with pytest.raises(TypeError):
        des.add_round_key(keys='foo',
                          state=np.random.randint(0, 63, (8), dtype='uint8'))
    with pytest.raises(TypeError):
        des.add_round_key(keys=12,
                          state=np.random.randint(0, 63, (8), dtype='uint8'))
예제 #2
0
def test_add_round_key_raises_exception_if_key_and_state_dims_are_incompatible(
):
    with pytest.raises(ValueError):
        des.add_round_key(keys=np.random.randint(0, 63, (12, 8),
                                                 dtype='uint8'),
                          state=np.random.randint(0,
                                                  63, (10, 8),
                                                  dtype='uint8'))
예제 #3
0
def test_add_round_key_raises_exception_if_key_is_not_a_correct_array():
    with pytest.raises(ValueError):
        des.add_round_key(keys=np.random.randint(0,
                                                 63, (12, 12),
                                                 dtype='uint8'),
                          state=np.random.randint(0, 63, (8), dtype='uint8'))
    with pytest.raises(ValueError):
        des.add_round_key(keys=np.random.randint(0,
                                                 63, (12, 8),
                                                 dtype='uint16'),
                          state=np.random.randint(0, 63, (8), dtype='uint8'))
예제 #4
0
def test_add_round_key_returns_correct_result_array_batch_of_n_key_and_1_row_state(
        des_data):
    state = des_data['expected_expansive_permutation'][0]
    key = des_data['des_key_schedule_output']
    expected = des_data['expected_add_round_key_1_state']
    assert np.array_equal(expected, des.add_round_key(state=state, keys=key))
    assert expected.shape == key.shape == (16, 8)
예제 #5
0
def test_add_round_key_returns_array_of_6bits_numbers():
    state = np.random.randint(0, 63, (1000, 8), dtype='uint8')
    key = np.random.randint(0, 63, (1000, 8), dtype='uint8')
    expected = des.add_round_key(state, key)
    for element in np.nditer(expected):
        assert element <= 63