Resolve compiler warnings in the test programs
This commit is contained in:
parent
36ee258db7
commit
1767f7c117
4 changed files with 41 additions and 39 deletions
|
@ -148,14 +148,14 @@ static int test_cbc(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memcpy(buf, tv->plain, tv->len);
|
memcpy(buf, tv->plain, tv->len);
|
||||||
aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len);
|
if (aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len) ||
|
||||||
if (memcmp(buf, tv->cipher, tv->len) != 0) {
|
memcmp(buf, tv->cipher, tv->len) != 0) {
|
||||||
printf("AES-CBC encrypt %d failed\n", i);
|
printf("AES-CBC encrypt %d failed\n", i);
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
memcpy(buf, tv->cipher, tv->len);
|
memcpy(buf, tv->cipher, tv->len);
|
||||||
aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len);
|
if (aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len) ||
|
||||||
if (memcmp(buf, tv->plain, tv->len) != 0) {
|
memcmp(buf, tv->plain, tv->len) != 0) {
|
||||||
printf("AES-CBC decrypt %d failed\n", i);
|
printf("AES-CBC decrypt %d failed\n", i);
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
@ -272,8 +272,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
|
for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
|
||||||
tv = &test_vectors[i];
|
tv = &test_vectors[i];
|
||||||
omac1_aes_128(tv->k, tv->msg, tv->msg_len, result);
|
if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
|
||||||
if (memcmp(result, tv->tag, 16) != 0) {
|
memcmp(result, tv->tag, 16) != 0) {
|
||||||
printf("OMAC1-AES-128 test vector %d failed\n", i);
|
printf("OMAC1-AES-128 test vector %d failed\n", i);
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
@ -287,8 +287,9 @@ int main(int argc, char *argv[])
|
||||||
addr[1] = tv->msg + 1;
|
addr[1] = tv->msg + 1;
|
||||||
len[1] = tv->msg_len - 1;
|
len[1] = tv->msg_len - 1;
|
||||||
|
|
||||||
omac1_aes_128_vector(tv->k, 2, addr, len, result);
|
if (omac1_aes_128_vector(tv->k, 2, addr, len,
|
||||||
if (memcmp(result, tv->tag, 16) != 0) {
|
result) ||
|
||||||
|
memcmp(result, tv->tag, 16) != 0) {
|
||||||
printf("OMAC1-AES-128(vector) test vector %d "
|
printf("OMAC1-AES-128(vector) test vector %d "
|
||||||
"failed\n", i);
|
"failed\n", i);
|
||||||
ret++;
|
ret++;
|
||||||
|
|
|
@ -21,7 +21,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
char *data;
|
char *data;
|
||||||
u8 *hash;
|
char *hash;
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{
|
{
|
||||||
"",
|
"",
|
||||||
|
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
|
||||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
||||||
printf("MD5 test case %d:", i);
|
printf("MD5 test case %d:", i);
|
||||||
|
|
||||||
addr[0] = tests[i].data;
|
addr[0] = (u8 *) tests[i].data;
|
||||||
len[0] = strlen(tests[i].data);
|
len[0] = strlen(tests[i].data);
|
||||||
md5_vector(1, addr, len, hash);
|
md5_vector(1, addr, len, hash);
|
||||||
if (memcmp(hash, tests[i].hash, 16) != 0) {
|
if (memcmp(hash, tests[i].hash, 16) != 0) {
|
||||||
|
@ -80,9 +80,9 @@ int main(int argc, char *argv[])
|
||||||
printf(" OK");
|
printf(" OK");
|
||||||
|
|
||||||
if (len[0]) {
|
if (len[0]) {
|
||||||
addr[0] = tests[i].data;
|
addr[0] = (u8 *) tests[i].data;
|
||||||
len[0] = strlen(tests[i].data);
|
len[0] = strlen(tests[i].data);
|
||||||
addr[1] = tests[i].data + 1;
|
addr[1] = (u8 *) tests[i].data + 1;
|
||||||
len[1] = strlen(tests[i].data) - 1;
|
len[1] = strlen(tests[i].data) - 1;
|
||||||
md5_vector(1, addr, len, hash);
|
md5_vector(1, addr, len, hash);
|
||||||
if (memcmp(hash, tests[i].hash, 16) != 0) {
|
if (memcmp(hash, tests[i].hash, 16) != 0) {
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* Test vector from RFC2759 example */
|
/* Test vector from RFC2759 example */
|
||||||
u8 *username = "User";
|
char *username = "User";
|
||||||
u8 *password = "clientPass";
|
char *password = "clientPass";
|
||||||
u8 auth_challenge[] = {
|
u8 auth_challenge[] = {
|
||||||
0x5B, 0x5D, 0x7C, 0x7D, 0x7B, 0x3F, 0x2F, 0x3E,
|
0x5B, 0x5D, 0x7C, 0x7D, 0x7B, 0x3F, 0x2F, 0x3E,
|
||||||
0x3C, 0x2C, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28
|
0x3C, 0x2C, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28
|
||||||
|
@ -61,53 +61,54 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
printf("Testing ms_funcs.c\n");
|
printf("Testing ms_funcs.c\n");
|
||||||
|
|
||||||
challenge_hash(peer_challenge, auth_challenge,
|
if (challenge_hash(peer_challenge, auth_challenge,
|
||||||
username, strlen(username),
|
(u8 *) username, strlen(username),
|
||||||
buf);
|
buf) ||
|
||||||
if (memcmp(challenge, buf, sizeof(challenge)) != 0) {
|
memcmp(challenge, buf, sizeof(challenge)) != 0) {
|
||||||
printf("challenge_hash failed\n");
|
printf("challenge_hash failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
nt_password_hash(password, strlen(password), buf);
|
if (nt_password_hash((u8 *) password, strlen(password), buf) ||
|
||||||
if (memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
|
memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
|
||||||
printf("nt_password_hash failed\n");
|
printf("nt_password_hash failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_nt_response(auth_challenge, peer_challenge,
|
if (generate_nt_response(auth_challenge, peer_challenge,
|
||||||
username, strlen(username),
|
(u8 *) username, strlen(username),
|
||||||
password, strlen(password),
|
(u8 *) password, strlen(password),
|
||||||
buf);
|
buf) ||
|
||||||
if (memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
|
memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
|
||||||
printf("generate_nt_response failed\n");
|
printf("generate_nt_response failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_nt_password_hash(password_hash, buf);
|
if (hash_nt_password_hash(password_hash, buf) ||
|
||||||
if (memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
|
memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
|
||||||
printf("hash_nt_password_hash failed\n");
|
printf("hash_nt_password_hash failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_authenticator_response(password, strlen(password),
|
if (generate_authenticator_response((u8 *) password, strlen(password),
|
||||||
peer_challenge, auth_challenge,
|
peer_challenge, auth_challenge,
|
||||||
username, strlen(username),
|
(u8 *) username, strlen(username),
|
||||||
nt_response, buf);
|
nt_response, buf) ||
|
||||||
if (memcmp(authenticator_response, buf, sizeof(authenticator_response))
|
memcmp(authenticator_response, buf, sizeof(authenticator_response))
|
||||||
!= 0) {
|
!= 0) {
|
||||||
printf("generate_authenticator_response failed\n");
|
printf("generate_authenticator_response failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_master_key(password_hash_hash, nt_response, buf);
|
if (get_master_key(password_hash_hash, nt_response, buf) ||
|
||||||
if (memcmp(master_key, buf, sizeof(master_key)) != 0) {
|
memcmp(master_key, buf, sizeof(master_key)) != 0) {
|
||||||
printf("get_master_key failed\n");
|
printf("get_master_key failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_asymetric_start_key(master_key, buf, sizeof(send_start_key), 1, 1);
|
if (get_asymetric_start_key(master_key, buf, sizeof(send_start_key),
|
||||||
if (memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
|
1, 1) ||
|
||||||
|
memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
|
||||||
printf("get_asymetric_start_key failed\n");
|
printf("get_asymetric_start_key failed\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,9 +137,9 @@ static int test_eap_fast(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("- PRF (TLS, SHA1/MD5) test case / key_block\n");
|
printf("- PRF (TLS, SHA1/MD5) test case / key_block\n");
|
||||||
tls_prf(master_secret, sizeof(master_secret), "key expansion",
|
if (tls_prf(master_secret, sizeof(master_secret), "key expansion",
|
||||||
seed, sizeof(seed), buf, sizeof(key_block));
|
seed, sizeof(seed), buf, sizeof(key_block)) ||
|
||||||
if (memcmp(key_block, buf, sizeof(key_block)) != 0) {
|
memcmp(key_block, buf, sizeof(key_block)) != 0) {
|
||||||
printf("PRF test - FAILED!\n");
|
printf("PRF test - FAILED!\n");
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue