break;
}
memcpy(buf, tv->plain, tv->len);
- aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len);
- if (memcmp(buf, tv->cipher, tv->len) != 0) {
+ if (aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len) ||
+ memcmp(buf, tv->cipher, tv->len) != 0) {
printf("AES-CBC encrypt %d failed\n", i);
ret++;
}
memcpy(buf, tv->cipher, tv->len);
- aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len);
- if (memcmp(buf, tv->plain, tv->len) != 0) {
+ if (aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len) ||
+ memcmp(buf, tv->plain, tv->len) != 0) {
printf("AES-CBC decrypt %d failed\n", i);
ret++;
}
for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
tv = &test_vectors[i];
- omac1_aes_128(tv->k, tv->msg, tv->msg_len, result);
- if (memcmp(result, tv->tag, 16) != 0) {
+ if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
+ memcmp(result, tv->tag, 16) != 0) {
printf("OMAC1-AES-128 test vector %d failed\n", i);
ret++;
}
addr[1] = tv->msg + 1;
len[1] = tv->msg_len - 1;
- omac1_aes_128_vector(tv->k, 2, addr, len, result);
- if (memcmp(result, tv->tag, 16) != 0) {
+ if (omac1_aes_128_vector(tv->k, 2, addr, len,
+ result) ||
+ memcmp(result, tv->tag, 16) != 0) {
printf("OMAC1-AES-128(vector) test vector %d "
"failed\n", i);
ret++;
{
struct {
char *data;
- u8 *hash;
+ char *hash;
} tests[] = {
{
"",
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
printf("MD5 test case %d:", i);
- addr[0] = tests[i].data;
+ addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
md5_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
printf(" OK");
if (len[0]) {
- addr[0] = tests[i].data;
+ addr[0] = (u8 *) 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;
md5_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
int main(int argc, char *argv[])
{
/* Test vector from RFC2759 example */
- u8 *username = "User";
- u8 *password = "clientPass";
+ char *username = "User";
+ char *password = "clientPass";
u8 auth_challenge[] = {
0x5B, 0x5D, 0x7C, 0x7D, 0x7B, 0x3F, 0x2F, 0x3E,
0x3C, 0x2C, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28
printf("Testing ms_funcs.c\n");
- challenge_hash(peer_challenge, auth_challenge,
- username, strlen(username),
- buf);
- if (memcmp(challenge, buf, sizeof(challenge)) != 0) {
+ if (challenge_hash(peer_challenge, auth_challenge,
+ (u8 *) username, strlen(username),
+ buf) ||
+ memcmp(challenge, buf, sizeof(challenge)) != 0) {
printf("challenge_hash failed\n");
errors++;
}
- nt_password_hash(password, strlen(password), buf);
- if (memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
+ if (nt_password_hash((u8 *) password, strlen(password), buf) ||
+ memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
printf("nt_password_hash failed\n");
errors++;
}
- generate_nt_response(auth_challenge, peer_challenge,
- username, strlen(username),
- password, strlen(password),
- buf);
- if (memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
+ if (generate_nt_response(auth_challenge, peer_challenge,
+ (u8 *) username, strlen(username),
+ (u8 *) password, strlen(password),
+ buf) ||
+ memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
printf("generate_nt_response failed\n");
errors++;
}
- hash_nt_password_hash(password_hash, buf);
- if (memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
+ if (hash_nt_password_hash(password_hash, buf) ||
+ memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
printf("hash_nt_password_hash failed\n");
errors++;
}
- generate_authenticator_response(password, strlen(password),
- peer_challenge, auth_challenge,
- username, strlen(username),
- nt_response, buf);
- if (memcmp(authenticator_response, buf, sizeof(authenticator_response))
+ if (generate_authenticator_response((u8 *) password, strlen(password),
+ peer_challenge, auth_challenge,
+ (u8 *) username, strlen(username),
+ nt_response, buf) ||
+ memcmp(authenticator_response, buf, sizeof(authenticator_response))
!= 0) {
printf("generate_authenticator_response failed\n");
errors++;
}
- get_master_key(password_hash_hash, nt_response, buf);
- if (memcmp(master_key, buf, sizeof(master_key)) != 0) {
+ if (get_master_key(password_hash_hash, nt_response, buf) ||
+ memcmp(master_key, buf, sizeof(master_key)) != 0) {
printf("get_master_key failed\n");
errors++;
}
- get_asymetric_start_key(master_key, buf, sizeof(send_start_key), 1, 1);
- if (memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
+ if (get_asymetric_start_key(master_key, buf, sizeof(send_start_key),
+ 1, 1) ||
+ memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
printf("get_asymetric_start_key failed\n");
errors++;
}