|
@@ -46,10 +46,10 @@ void aes_test_expand_key() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
uint8_t* round_keys = aes__expand_key(test_key);
|
|
uint8_t* round_keys = aes__expand_key(test_key);
|
|
|
-
|
|
|
|
|
- assert(arrays_eq(round_keys, expected_round_keys, BLOCK_LENGTH));
|
|
|
|
|
-
|
|
|
|
|
|
|
+ int result = arrays_eq(round_keys, expected_round_keys, BLOCK_LENGTH);
|
|
|
free(round_keys);
|
|
free(round_keys);
|
|
|
|
|
+
|
|
|
|
|
+ assert(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void aes_test_block_cipher() {
|
|
void aes_test_block_cipher() {
|
|
@@ -62,9 +62,9 @@ void aes_test_block_cipher() {
|
|
|
aes__encrypt_block(test_data, round_keys);
|
|
aes__encrypt_block(test_data, round_keys);
|
|
|
aes__decrypt_block(test_data, round_keys);
|
|
aes__decrypt_block(test_data, round_keys);
|
|
|
|
|
|
|
|
- assert(arrays_eq(test_data, original_data, BLOCK_LENGTH));
|
|
|
|
|
-
|
|
|
|
|
free(round_keys);
|
|
free(round_keys);
|
|
|
|
|
+
|
|
|
|
|
+ assert(arrays_eq(test_data, original_data, BLOCK_LENGTH));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void aes_test_padding_validation() {
|
|
void aes_test_padding_validation() {
|
|
@@ -108,6 +108,9 @@ void aes_test_create_padding() {
|
|
|
assert(padded.data_length_before_pad == 16);
|
|
assert(padded.data_length_before_pad == 16);
|
|
|
assert(padded.length == 32);
|
|
assert(padded.length == 32);
|
|
|
assert(arrays_eq(padded.padded_block, expected_padding, BLOCK_LENGTH));
|
|
assert(arrays_eq(padded.padded_block, expected_padding, BLOCK_LENGTH));
|
|
|
|
|
+
|
|
|
|
|
+ uint8_t* data_ret = aes_drop_padded_data_container(&padded);
|
|
|
|
|
+ assert(data_ret == data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// TODO: Doesn't test padded block
|
|
// TODO: Doesn't test padded block
|
|
@@ -135,4 +138,6 @@ void aes_test_cipher() {
|
|
|
|
|
|
|
|
aes_cbc(decryption, &padded, key);
|
|
aes_cbc(decryption, &padded, key);
|
|
|
assert(arrays_eq(padded.data, original, padded.data_length_before_pad));
|
|
assert(arrays_eq(padded.data, original, padded.data_length_before_pad));
|
|
|
|
|
+
|
|
|
|
|
+ aes_drop_padded_data_container(&padded);
|
|
|
}
|
|
}
|