fix warnings in tests
This commit is contained in:
parent
c211ce7f66
commit
4929e4e989
@ -555,7 +555,7 @@ void ocb3_gen(void)
|
|||||||
plaintext[z] = (unsigned char)(z & 255);
|
plaintext[z] = (unsigned char)(z & 255);
|
||||||
}
|
}
|
||||||
len = sizeof(tag);
|
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));
|
printf("Error OCB'ing: %s\n", error_to_string(err));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ int base64_test(void)
|
|||||||
for (x = 0; x < sizeof(cases)/sizeof(cases[0]); ++x) {
|
for (x = 0; x < sizeof(cases)/sizeof(cases[0]); ++x) {
|
||||||
slen1 = strlen(cases[x].s);
|
slen1 = strlen(cases[x].s);
|
||||||
l1 = sizeof(out);
|
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);
|
l2 = sizeof(tmp);
|
||||||
DO(base64_decode(out, l1, tmp, &l2));
|
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)) {
|
if (l2 != slen1 || l1 != strlen(cases[x].b64) || memcmp(tmp, cases[x].s, l2) || memcmp(out, cases[x].b64, l1)) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#ifdef LTC_MECC
|
#ifdef LTC_MECC
|
||||||
|
|
||||||
static int sizes[] = {
|
static unsigned int sizes[] = {
|
||||||
#ifdef ECC112
|
#ifdef ECC112
|
||||||
14,
|
14,
|
||||||
#endif
|
#endif
|
||||||
@ -47,7 +47,7 @@ int ecc_test_shamir(void)
|
|||||||
for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
|
for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
|
||||||
/* get the base point */
|
/* get the base point */
|
||||||
for (z = 0; ltc_ecc_sets[z].name; z++) {
|
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);
|
LTC_ARGCHK(ltc_ecc_sets[z].name != NULL);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
int pkcs_1_test(void)
|
int pkcs_1_test(void)
|
||||||
{
|
{
|
||||||
unsigned char buf[3][128];
|
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;
|
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 };
|
static const unsigned char lparam[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ int ecc_tests(void);
|
|||||||
int dsa_test(void);
|
int dsa_test(void);
|
||||||
int der_tests(void);
|
int der_tests(void);
|
||||||
int misc_test(void);
|
int misc_test(void);
|
||||||
|
int base64_test(void);
|
||||||
|
|
||||||
/* timing */
|
/* timing */
|
||||||
#define KTIMES 25
|
#define KTIMES 25
|
||||||
@ -85,6 +86,7 @@ int time_keysched(void);
|
|||||||
int time_cipher(void);
|
int time_cipher(void);
|
||||||
int time_cipher2(void);
|
int time_cipher2(void);
|
||||||
int time_cipher3(void);
|
int time_cipher3(void);
|
||||||
|
int time_cipher4(void);
|
||||||
int time_hash(void);
|
int time_hash(void);
|
||||||
void time_mult(void);
|
void time_mult(void);
|
||||||
void time_sqr(void);
|
void time_sqr(void);
|
||||||
|
@ -48,9 +48,12 @@ ulong64 rdtsc (void)
|
|||||||
asm ( " rdtsc ":"=A"(a));
|
asm ( " rdtsc ":"=A"(a));
|
||||||
return a;
|
return a;
|
||||||
#elif defined(__i386__) || defined(__x86_64__)
|
#elif defined(__i386__) || defined(__x86_64__)
|
||||||
ulong64 a;
|
/* version from http://www.mcs.anl.gov/~kazutomo/rdtsc.html
|
||||||
asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx");
|
* the old code always got a warning issued by gcc, clang did not complain...
|
||||||
return a;
|
*/
|
||||||
|
unsigned hi, lo;
|
||||||
|
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||||
|
return ((ulong64)lo)|( ((ulong64)hi)<<32);
|
||||||
#elif defined(LTC_PPC32) || defined(TFM_PPC32)
|
#elif defined(LTC_PPC32) || defined(TFM_PPC32)
|
||||||
unsigned long a, b;
|
unsigned long a, b;
|
||||||
__asm__ __volatile__ ("mftbu %1 \nmftb %0\n":"=r"(a), "=r"(b));
|
__asm__ __volatile__ ("mftbu %1 \nmftb %0\n":"=r"(a), "=r"(b));
|
||||||
@ -104,14 +107,13 @@ ulong64 t_read(void)
|
|||||||
|
|
||||||
void init_timer(void)
|
void init_timer(void)
|
||||||
{
|
{
|
||||||
ulong64 c1, c2, t1, t2, t3;
|
ulong64 c1, c2, t1, t2;
|
||||||
unsigned long y1;
|
unsigned long y1;
|
||||||
|
|
||||||
c1 = c2 = (ulong64)-1;
|
c1 = c2 = (ulong64)-1;
|
||||||
for (y1 = 0; y1 < TIMES*100; y1++) {
|
for (y1 = 0; y1 < TIMES*100; y1++) {
|
||||||
t_start();
|
t_start();
|
||||||
t1 = t_read();
|
t1 = t_read();
|
||||||
t3 = t_read();
|
|
||||||
t2 = (t_read() - t1)>>1;
|
t2 = (t_read() - t1)>>1;
|
||||||
|
|
||||||
c1 = (t1 > c1) ? t1 : c1;
|
c1 = (t1 > c1) ? t1 : c1;
|
||||||
@ -1345,7 +1347,7 @@ void time_encmacs_(unsigned long MAC_SIZE)
|
|||||||
t_start();
|
t_start();
|
||||||
t1 = t_read();
|
t1 = t_read();
|
||||||
z = 16;
|
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));
|
fprintf(stderr, "\nOCB3 error... %s\n", error_to_string(err));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user