fix warnings in tests

This commit is contained in:
Steffen Jaeckel 2014-05-01 18:01:13 +02:00
parent c211ce7f66
commit 4929e4e989
6 changed files with 55 additions and 51 deletions

View File

@ -555,7 +555,7 @@ void ocb3_gen(void)
plaintext[z] = (unsigned char)(z & 255);
}
len = sizeof(tag);
if ((err = ocb3_encrypt_authenticate_memory(x, key, kl, nonce, cipher_descriptor[x].block_length, "AAD", 3, plaintext, y1, plaintext, tag, &len)) != CRYPT_OK) {
if ((err = ocb3_encrypt_authenticate_memory(x, key, kl, nonce, cipher_descriptor[x].block_length, (unsigned char*)"AAD", 3, plaintext, y1, plaintext, tag, &len)) != CRYPT_OK) {
printf("Error OCB'ing: %s\n", error_to_string(err));
exit(EXIT_FAILURE);
}

View File

@ -29,7 +29,7 @@ int base64_test(void)
for (x = 0; x < sizeof(cases)/sizeof(cases[0]); ++x) {
slen1 = strlen(cases[x].s);
l1 = sizeof(out);
DO(base64_encode(cases[x].s, slen1, out, &l1));
DO(base64_encode((unsigned char*)cases[x].s, slen1, out, &l1));
l2 = sizeof(tmp);
DO(base64_decode(out, l1, tmp, &l2));
if (l2 != slen1 || l1 != strlen(cases[x].b64) || memcmp(tmp, cases[x].s, l2) || memcmp(out, cases[x].b64, l1)) {

View File

@ -2,7 +2,7 @@
#ifdef LTC_MECC
static int sizes[] = {
static unsigned int sizes[] = {
#ifdef ECC112
14,
#endif
@ -47,7 +47,7 @@ int ecc_test_shamir(void)
for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
/* get the base point */
for (z = 0; ltc_ecc_sets[z].name; z++) {
if (sizes[z] < ltc_ecc_sets[z].size) break;
if (sizes[z] < (unsigned int)ltc_ecc_sets[z].size) break;
}
LTC_ARGCHK(ltc_ecc_sets[z].name != NULL);

View File

@ -5,7 +5,7 @@
int pkcs_1_test(void)
{
unsigned char buf[3][128];
int res1, res2, res3, prng_idx, hash_idx, err;
int res1, res2, res3, prng_idx, hash_idx;
unsigned long x, y, l1, l2, l3, i1, i2, lparamlen, saltlen, modlen;
static const unsigned char lparam[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };

View File

@ -59,6 +59,7 @@ int ecc_tests(void);
int dsa_test(void);
int der_tests(void);
int misc_test(void);
int base64_test(void);
/* timing */
#define KTIMES 25
@ -85,6 +86,7 @@ int time_keysched(void);
int time_cipher(void);
int time_cipher2(void);
int time_cipher3(void);
int time_cipher4(void);
int time_hash(void);
void time_mult(void);
void time_sqr(void);

View File

@ -48,9 +48,12 @@ ulong64 rdtsc (void)
asm ( " rdtsc ":"=A"(a));
return a;
#elif defined(__i386__) || defined(__x86_64__)
ulong64 a;
asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx");
return a;
/* version from http://www.mcs.anl.gov/~kazutomo/rdtsc.html
* the old code always got a warning issued by gcc, clang did not complain...
*/
unsigned hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ((ulong64)lo)|( ((ulong64)hi)<<32);
#elif defined(LTC_PPC32) || defined(TFM_PPC32)
unsigned long a, b;
__asm__ __volatile__ ("mftbu %1 \nmftb %0\n":"=r"(a), "=r"(b));
@ -104,14 +107,13 @@ ulong64 t_read(void)
void init_timer(void)
{
ulong64 c1, c2, t1, t2, t3;
ulong64 c1, c2, t1, t2;
unsigned long y1;
c1 = c2 = (ulong64)-1;
for (y1 = 0; y1 < TIMES*100; y1++) {
t_start();
t1 = t_read();
t3 = t_read();
t2 = (t_read() - t1)>>1;
c1 = (t1 > c1) ? t1 : c1;
@ -1345,7 +1347,7 @@ void time_encmacs_(unsigned long MAC_SIZE)
t_start();
t1 = t_read();
z = 16;
if ((err = ocb3_encrypt_authenticate_memory(cipher_idx, key, 16, IV, 16, "", 0, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) {
if ((err = ocb3_encrypt_authenticate_memory(cipher_idx, key, 16, IV, 16, (unsigned char*)"", 0, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) {
fprintf(stderr, "\nOCB3 error... %s\n", error_to_string(err));
exit(EXIT_FAILURE);
}