#include <polarssl/config.h>
#include <polarssl/aes.h>
#include <inttypes.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | rnd_buf_info |
struct | rnd_pseudo_info |
Info structure for the pseudo random function. More... | |
Defines | |
#define | TEST_SUITE_ACTIVE |
#define | TEST_ASSERT(TEST) |
Functions | |
static int | unhexify (unsigned char *obuf, const char *ibuf) |
static void | hexify (unsigned char *obuf, const unsigned char *ibuf, int len) |
static int | rnd_std_rand (void *rng_state, unsigned char *output, size_t len) |
This function just returns data from rand(). | |
static int | rnd_zero_rand (void *rng_state, unsigned char *output, size_t len) |
This function only returns zeros. | |
static int | rnd_buffer_rand (void *rng_state, unsigned char *output, size_t len) |
This function returns random based on a buffer it receives. | |
static int | rnd_pseudo_rand (void *rng_state, unsigned char *output, size_t len) |
This function returns random based on a pseudo random function. | |
static int | test_assert (int correct, char *test) |
int | verify_string (char **str) |
int | verify_int (char *str, int *value) |
void | test_suite_aes_encrypt_ecb (char *hex_key_string, char *hex_src_string, char *hex_dst_string, int setkey_result) |
void | test_suite_aes_decrypt_ecb (char *hex_key_string, char *hex_src_string, char *hex_dst_string, int setkey_result) |
void | test_suite_aes_encrypt_cbc (char *hex_key_string, char *hex_iv_string, char *hex_src_string, char *hex_dst_string, int cbc_result) |
void | test_suite_aes_decrypt_cbc (char *hex_key_string, char *hex_iv_string, char *hex_src_string, char *hex_dst_string, int cbc_result) |
void | test_suite_aes_encrypt_cfb128 (char *hex_key_string, char *hex_iv_string, char *hex_src_string, char *hex_dst_string) |
void | test_suite_aes_decrypt_cfb128 (char *hex_key_string, char *hex_iv_string, char *hex_src_string, char *hex_dst_string) |
void | test_suite_aes_selftest () |
int | dep_check (char *str) |
int | dispatch_test (int cnt, char *params[50]) |
int | get_line (FILE *f, char *buf, size_t len) |
int | parse_arguments (char *buf, size_t len, char *params[50]) |
int | main () |
Variables | |
static int | test_errors = 0 |
#define TEST_ASSERT | ( | TEST | ) |
do { test_assert( (TEST) ? 1 : 0, #TEST ); \ if( test_errors) return; \ } while (0)
Definition at line 301 of file test_suite_aes.cbc.c.
Referenced by test_suite_aes_decrypt_cbc(), test_suite_aes_decrypt_cfb128(), test_suite_aes_decrypt_ecb(), test_suite_aes_encrypt_cbc(), test_suite_aes_encrypt_cfb128(), test_suite_aes_encrypt_ecb(), test_suite_aes_selftest(), test_suite_arc4_crypt(), test_suite_arc4_selftest(), test_suite_base64_decode(), test_suite_base64_encode(), test_suite_base64_selftest(), test_suite_blowfish_decrypt_cbc(), test_suite_blowfish_decrypt_cfb64(), test_suite_blowfish_decrypt_ecb(), test_suite_blowfish_encrypt_cbc(), test_suite_blowfish_encrypt_cfb64(), test_suite_blowfish_encrypt_ctr(), test_suite_blowfish_encrypt_ecb(), test_suite_camellia_decrypt_cbc(), test_suite_camellia_decrypt_cfb128(), test_suite_camellia_decrypt_ecb(), test_suite_camellia_encrypt_cbc(), test_suite_camellia_encrypt_cfb128(), test_suite_camellia_encrypt_ecb(), test_suite_camellia_selftest(), test_suite_check_compiletime_version(), test_suite_check_padding(), test_suite_check_runtime_version(), test_suite_cipher_selftest(), test_suite_ctr_drbg_validate_nopr(), test_suite_ctr_drbg_validate_pr(), test_suite_debug_print_crt(), test_suite_debug_print_mpi(), test_suite_dec_empty_buf(), test_suite_decrypt_test_vec(), test_suite_des3_decrypt_cbc(), test_suite_des3_decrypt_ecb(), test_suite_des3_encrypt_cbc(), test_suite_des3_encrypt_ecb(), test_suite_des_decrypt_cbc(), test_suite_des_decrypt_ecb(), test_suite_des_encrypt_cbc(), test_suite_des_encrypt_ecb(), test_suite_des_key_parity_run(), test_suite_des_selftest(), test_suite_dhm_do_dhm(), test_suite_dhm_selftest(), test_suite_ecdh_exchange(), test_suite_ecdh_primitive_random(), test_suite_ecdh_primitive_testvec(), test_suite_ecdsa_prim_random(), test_suite_ecdsa_prim_test_vectors(), test_suite_ecdsa_write_read_random(), test_suite_ecp_check_privkey(), test_suite_ecp_fast_mod(), test_suite_ecp_gen_keypair(), test_suite_ecp_read_binary(), test_suite_ecp_selftest(), test_suite_ecp_small_add(), test_suite_ecp_small_check_pub(), test_suite_ecp_small_mul(), test_suite_ecp_small_sub(), test_suite_ecp_test_vect(), test_suite_ecp_tls_read_group(), test_suite_ecp_tls_read_point(), test_suite_ecp_tls_write_read_group(), test_suite_ecp_tls_write_read_point(), test_suite_ecp_write_binary(), test_suite_enc_dec_buf(), test_suite_enc_dec_buf_multipart(), test_suite_enc_fail(), test_suite_error_strerror(), test_suite_gcm_decrypt_and_verify(), test_suite_gcm_encrypt_and_tag(), test_suite_gcm_selftest(), test_suite_md5_file(), test_suite_md5_hmac(), test_suite_md5_selftest(), test_suite_md5_text(), test_suite_md_file(), test_suite_md_hex(), test_suite_md_hex_multi(), test_suite_md_hmac(), test_suite_md_hmac_multi(), test_suite_md_text(), test_suite_md_text_multi(), test_suite_mpi_add_abs(), test_suite_mpi_add_abs_add_first(), test_suite_mpi_add_abs_add_second(), test_suite_mpi_add_int(), test_suite_mpi_add_mpi(), test_suite_mpi_cmp_abs(), test_suite_mpi_cmp_int(), test_suite_mpi_cmp_mpi(), test_suite_mpi_copy(), test_suite_mpi_copy_self(), test_suite_mpi_div_int(), test_suite_mpi_div_mpi(), test_suite_mpi_exp_mod(), test_suite_mpi_gcd(), test_suite_mpi_get_bit(), test_suite_mpi_inv_mod(), test_suite_mpi_is_prime(), test_suite_mpi_lsb(), test_suite_mpi_mod_int(), test_suite_mpi_mod_mpi(), test_suite_mpi_msb(), test_suite_mpi_mul_int(), test_suite_mpi_mul_mpi(), test_suite_mpi_read_binary(), test_suite_mpi_read_file(), test_suite_mpi_read_write_string(), test_suite_mpi_selftest(), test_suite_mpi_set_bit(), test_suite_mpi_shift_l(), test_suite_mpi_shift_r(), test_suite_mpi_sub_abs(), test_suite_mpi_sub_int(), test_suite_mpi_sub_mpi(), test_suite_mpi_swap(), test_suite_mpi_write_binary(), test_suite_mpi_write_file(), test_suite_pbkdf2_hmac(), test_suite_pk_ec_nocrypt(), test_suite_pk_ec_test_vec(), test_suite_pk_parse_key_rsa(), test_suite_pk_parse_keyfile_ec(), test_suite_pk_parse_keyfile_rsa(), test_suite_pk_parse_public_keyfile_ec(), test_suite_pk_parse_public_keyfile_rsa(), test_suite_pk_rsa_decrypt_test_vec(), test_suite_pk_rsa_encrypt_test_vec(), test_suite_pk_rsa_verify_test_vec(), test_suite_pk_sign_verify(), test_suite_pk_utils(), test_suite_pk_write_key_check(), test_suite_pk_write_pubkey_check(), test_suite_pkcs1_rsaes_oaep_decrypt(), test_suite_pkcs1_rsaes_oaep_encrypt(), test_suite_pkcs1_rsassa_pss_sign(), test_suite_pkcs1_rsassa_pss_verify(), test_suite_rsa_check_privkey(), test_suite_rsa_check_privkey_null(), test_suite_rsa_check_pubkey(), test_suite_rsa_pkcs1_decrypt(), test_suite_rsa_pkcs1_encrypt(), test_suite_rsa_pkcs1_encrypt_bad_rng(), test_suite_rsa_pkcs1_sign(), test_suite_rsa_pkcs1_sign_raw(), test_suite_rsa_pkcs1_verify(), test_suite_rsa_pkcs1_verify_raw(), test_suite_rsa_private(), test_suite_rsa_public(), test_suite_rsa_selftest(), test_suite_sha1(), test_suite_sha1_file(), test_suite_sha1_hmac(), test_suite_sha1_selftest(), test_suite_sha224(), test_suite_sha224_file(), test_suite_sha224_hmac(), test_suite_sha256(), test_suite_sha256_file(), test_suite_sha256_hmac(), test_suite_sha256_selftest(), test_suite_sha384(), test_suite_sha384_file(), test_suite_sha384_hmac(), test_suite_sha512(), test_suite_sha512_file(), test_suite_sha512_hmac(), test_suite_sha512_selftest(), test_suite_test_vec_ecb(), test_suite_x509_cert_info(), test_suite_x509_crl_info(), test_suite_x509_crt_check(), test_suite_x509_csr_check(), test_suite_x509_dn_gets(), test_suite_x509_selftest(), test_suite_x509_time_expired(), test_suite_x509_verify(), test_suite_x509parse_crl(), test_suite_x509parse_crt(), test_suite_xtea_decrypt_ecb(), test_suite_xtea_encrypt_ecb(), and test_suite_xtea_selftest().
#define TEST_SUITE_ACTIVE |
Definition at line 286 of file test_suite_aes.cbc.c.
int dep_check | ( | char * | str | ) |
Definition at line 563 of file test_suite_aes.cbc.c.
Referenced by main().
int dispatch_test | ( | int | cnt, | |
char * | params[50] | |||
) |
Definition at line 573 of file test_suite_aes.cbc.c.
References test_suite_aes_decrypt_cbc(), test_suite_aes_decrypt_cfb128(), test_suite_aes_decrypt_ecb(), test_suite_aes_encrypt_cbc(), test_suite_aes_encrypt_cfb128(), test_suite_aes_encrypt_ecb(), test_suite_aes_selftest(), verify_int(), and verify_string().
Referenced by main().
int get_line | ( | FILE * | f, | |
char * | buf, | |||
size_t | len | |||
) |
Definition at line 773 of file test_suite_aes.cbc.c.
Referenced by main().
static void hexify | ( | unsigned char * | obuf, | |
const unsigned char * | ibuf, | |||
int | len | |||
) | [static] |
Definition at line 89 of file test_suite_aes.cbc.c.
Referenced by test_suite_aes_decrypt_cbc(), test_suite_aes_decrypt_cfb128(), test_suite_aes_decrypt_ecb(), test_suite_aes_encrypt_cbc(), test_suite_aes_encrypt_cfb128(), and test_suite_aes_encrypt_ecb().
int main | ( | ) |
Definition at line 850 of file test_suite_aes.cbc.c.
References dep_check(), dispatch_test(), get_line(), and parse_arguments().
int parse_arguments | ( | char * | buf, | |
size_t | len, | |||
char * | params[50] | |||
) |
Definition at line 789 of file test_suite_aes.cbc.c.
Referenced by main().
static int rnd_buffer_rand | ( | void * | rng_state, | |
unsigned char * | output, | |||
size_t | len | |||
) | [static] |
This function returns random based on a buffer it receives.
rng_state shall be a pointer to a rnd_buf_info structure.
The number of bytes released from the buffer on each call to the random function is specified by per_call. (Can be between 1 and 4)
After the buffer is empty it will return rand();
Definition at line 167 of file test_suite_aes.cbc.c.
References rnd_buf_info::buf, rnd_buf_info::length, and rnd_std_rand().
static int rnd_pseudo_rand | ( | void * | rng_state, | |
unsigned char * | output, | |||
size_t | len | |||
) | [static] |
This function returns random based on a pseudo random function.
This means the results should be identical on all systems. Pseudo random is based on the XTEA encryption algorithm to generate pseudorandom.
rng_state shall be a pointer to a rnd_pseudo_info structure.
Definition at line 213 of file test_suite_aes.cbc.c.
References rnd_pseudo_info::key, PUT_UINT32_BE, rnd_std_rand(), rnd_pseudo_info::v0, and rnd_pseudo_info::v1.
static int rnd_std_rand | ( | void * | rng_state, | |
unsigned char * | output, | |||
size_t | len | |||
) | [static] |
This function just returns data from rand().
Although predictable and often similar on multiple runs, this does not result in identical random on each run. So do not use this if the results of a test depend on the random data that is generated.
rng_state shall be NULL.
Definition at line 122 of file test_suite_aes.cbc.c.
Referenced by rnd_buffer_rand(), and rnd_pseudo_rand().
static int rnd_zero_rand | ( | void * | rng_state, | |
unsigned char * | output, | |||
size_t | len | |||
) | [static] |
This function only returns zeros.
rng_state shall be NULL.
Definition at line 140 of file test_suite_aes.cbc.c.
static int test_assert | ( | int | correct, | |
char * | test | |||
) | [static] |
Definition at line 288 of file test_suite_aes.cbc.c.
void test_suite_aes_decrypt_cbc | ( | char * | hex_key_string, | |
char * | hex_iv_string, | |||
char * | hex_src_string, | |||
char * | hex_dst_string, | |||
int | cbc_result | |||
) |
Definition at line 457 of file test_suite_aes.cbc.c.
References aes_crypt_cbc(), AES_DECRYPT, aes_setkey_dec(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_decrypt_cfb128 | ( | char * | hex_key_string, | |
char * | hex_iv_string, | |||
char * | hex_src_string, | |||
char * | hex_dst_string | |||
) |
Definition at line 522 of file test_suite_aes.cbc.c.
References aes_crypt_cfb128(), AES_DECRYPT, aes_setkey_enc(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_decrypt_ecb | ( | char * | hex_key_string, | |
char * | hex_src_string, | |||
char * | hex_dst_string, | |||
int | setkey_result | |||
) |
Definition at line 394 of file test_suite_aes.cbc.c.
References aes_crypt_ecb(), AES_DECRYPT, aes_setkey_dec(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_encrypt_cbc | ( | char * | hex_key_string, | |
char * | hex_iv_string, | |||
char * | hex_src_string, | |||
char * | hex_dst_string, | |||
int | cbc_result | |||
) |
Definition at line 423 of file test_suite_aes.cbc.c.
References aes_crypt_cbc(), AES_ENCRYPT, aes_setkey_enc(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_encrypt_cfb128 | ( | char * | hex_key_string, | |
char * | hex_iv_string, | |||
char * | hex_src_string, | |||
char * | hex_dst_string | |||
) |
Definition at line 491 of file test_suite_aes.cbc.c.
References aes_crypt_cfb128(), AES_ENCRYPT, aes_setkey_enc(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_encrypt_ecb | ( | char * | hex_key_string, | |
char * | hex_src_string, | |||
char * | hex_dst_string, | |||
int | setkey_result | |||
) |
Definition at line 366 of file test_suite_aes.cbc.c.
References aes_crypt_ecb(), AES_ENCRYPT, aes_setkey_enc(), hexify(), key_len, TEST_ASSERT, and unhexify().
Referenced by dispatch_test().
void test_suite_aes_selftest | ( | ) |
Definition at line 553 of file test_suite_aes.cbc.c.
References aes_self_test(), and TEST_ASSERT.
Referenced by dispatch_test().
static int unhexify | ( | unsigned char * | obuf, | |
const char * | ibuf | |||
) | [static] |
Definition at line 55 of file test_suite_aes.cbc.c.
Referenced by test_suite_aes_decrypt_cbc(), test_suite_aes_decrypt_cfb128(), test_suite_aes_decrypt_ecb(), test_suite_aes_encrypt_cbc(), test_suite_aes_encrypt_cfb128(), and test_suite_aes_encrypt_ecb().
int verify_int | ( | char * | str, | |
int * | value | |||
) |
Definition at line 321 of file test_suite_aes.cbc.c.
Referenced by dispatch_test().
int verify_string | ( | char ** | str | ) |
Definition at line 306 of file test_suite_aes.cbc.c.
Referenced by dispatch_test().
int test_errors = 0 [static] |
Definition at line 282 of file test_suite_aes.cbc.c.