提交 8829ce30 编写于 作者: F FdaSilvaYY 提交者: Rich Salz

Cast to right type, simplify array args

Reviewed-by: NRichard Levitte <levitte@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1342)
上级 3331e43b
...@@ -606,9 +606,10 @@ static int EVP_Digest_MD2_loop(void *args) ...@@ -606,9 +606,10 @@ static int EVP_Digest_MD2_loop(void *args)
unsigned char *buf = tempargs->buf; unsigned char *buf = tempargs->buf;
unsigned char md2[MD2_DIGEST_LENGTH]; unsigned char md2[MD2_DIGEST_LENGTH];
int count; int count;
for (count = 0; COND(c[D_MD2][testnum]); count++) { for (count = 0; COND(c[D_MD2][testnum]); count++) {
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(md2[0]), NULL, if (!EVP_Digest(buf, (size_t)lengths[testnum], md2, NULL, EVP_md2(),
EVP_md2(), NULL)) NULL))
return -1; return -1;
} }
return count; return count;
...@@ -622,9 +623,10 @@ static int EVP_Digest_MDC2_loop(void *args) ...@@ -622,9 +623,10 @@ static int EVP_Digest_MDC2_loop(void *args)
unsigned char *buf = tempargs->buf; unsigned char *buf = tempargs->buf;
unsigned char mdc2[MDC2_DIGEST_LENGTH]; unsigned char mdc2[MDC2_DIGEST_LENGTH];
int count; int count;
for (count = 0; COND(c[D_MDC2][testnum]); count++) { for (count = 0; COND(c[D_MDC2][testnum]); count++) {
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(mdc2[0]), NULL, if (!EVP_Digest(buf, (size_t)lengths[testnum], mdc2, NULL, EVP_mdc2(),
EVP_mdc2(), NULL)) NULL))
return -1; return -1;
} }
return count; return count;
...@@ -638,9 +640,10 @@ static int EVP_Digest_MD4_loop(void *args) ...@@ -638,9 +640,10 @@ static int EVP_Digest_MD4_loop(void *args)
unsigned char *buf = tempargs->buf; unsigned char *buf = tempargs->buf;
unsigned char md4[MD4_DIGEST_LENGTH]; unsigned char md4[MD4_DIGEST_LENGTH];
int count; int count;
for (count = 0; COND(c[D_MD4][testnum]); count++) { for (count = 0; COND(c[D_MD4][testnum]); count++) {
if (!EVP_Digest(&(buf[0]), (unsigned long)lengths[testnum], &(md4[0]), if (!EVP_Digest(buf, (size_t)lengths[testnum], md4, NULL, EVP_md4(),
NULL, EVP_md4(), NULL)) NULL))
return -1; return -1;
} }
return count; return count;
...@@ -666,10 +669,11 @@ static int HMAC_loop(void *args) ...@@ -666,10 +669,11 @@ static int HMAC_loop(void *args)
HMAC_CTX *hctx = tempargs->hctx; HMAC_CTX *hctx = tempargs->hctx;
unsigned char hmac[MD5_DIGEST_LENGTH]; unsigned char hmac[MD5_DIGEST_LENGTH];
int count; int count;
for (count = 0; COND(c[D_HMAC][testnum]); count++) { for (count = 0; COND(c[D_HMAC][testnum]); count++) {
HMAC_Init_ex(hctx, NULL, 0, NULL, NULL); HMAC_Init_ex(hctx, NULL, 0, NULL, NULL);
HMAC_Update(hctx, buf, lengths[testnum]); HMAC_Update(hctx, buf, lengths[testnum]);
HMAC_Final(hctx, &(hmac[0]), NULL); HMAC_Final(hctx, hmac, NULL);
} }
return count; return count;
} }
...@@ -729,7 +733,7 @@ static int EVP_Digest_RMD160_loop(void *args) ...@@ -729,7 +733,7 @@ static int EVP_Digest_RMD160_loop(void *args)
unsigned char rmd160[RIPEMD160_DIGEST_LENGTH]; unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
int count; int count;
for (count = 0; COND(c[D_RMD160][testnum]); count++) { for (count = 0; COND(c[D_RMD160][testnum]); count++) {
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(rmd160[0]), if (!EVP_Digest(buf, (size_t)lengths[testnum], &(rmd160[0]),
NULL, EVP_ripemd160(), NULL)) NULL, EVP_ripemd160(), NULL))
return -1; return -1;
} }
...@@ -745,7 +749,7 @@ static int RC4_loop(void *args) ...@@ -745,7 +749,7 @@ static int RC4_loop(void *args)
unsigned char *buf = tempargs->buf; unsigned char *buf = tempargs->buf;
int count; int count;
for (count = 0; COND(c[D_RC4][testnum]); count++) for (count = 0; COND(c[D_RC4][testnum]); count++)
RC4(&rc4_ks, (unsigned int)lengths[testnum], buf, buf); RC4(&rc4_ks, (size_t)lengths[testnum], buf, buf);
return count; return count;
} }
#endif #endif
...@@ -790,7 +794,7 @@ static int AES_cbc_128_encrypt_loop(void *args) ...@@ -790,7 +794,7 @@ static int AES_cbc_128_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_CBC_128_AES][testnum]); count++) for (count = 0; COND(c[D_CBC_128_AES][testnum]); count++)
AES_cbc_encrypt(buf, buf, AES_cbc_encrypt(buf, buf,
(unsigned long)lengths[testnum], &aes_ks1, (size_t)lengths[testnum], &aes_ks1,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -802,7 +806,7 @@ static int AES_cbc_192_encrypt_loop(void *args) ...@@ -802,7 +806,7 @@ static int AES_cbc_192_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_CBC_192_AES][testnum]); count++) for (count = 0; COND(c[D_CBC_192_AES][testnum]); count++)
AES_cbc_encrypt(buf, buf, AES_cbc_encrypt(buf, buf,
(unsigned long)lengths[testnum], &aes_ks2, (size_t)lengths[testnum], &aes_ks2,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -814,7 +818,7 @@ static int AES_cbc_256_encrypt_loop(void *args) ...@@ -814,7 +818,7 @@ static int AES_cbc_256_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_CBC_256_AES][testnum]); count++) for (count = 0; COND(c[D_CBC_256_AES][testnum]); count++)
AES_cbc_encrypt(buf, buf, AES_cbc_encrypt(buf, buf,
(unsigned long)lengths[testnum], &aes_ks3, (size_t)lengths[testnum], &aes_ks3,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -827,7 +831,7 @@ static int AES_ige_128_encrypt_loop(void *args) ...@@ -827,7 +831,7 @@ static int AES_ige_128_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_IGE_128_AES][testnum]); count++) for (count = 0; COND(c[D_IGE_128_AES][testnum]); count++)
AES_ige_encrypt(buf, buf2, AES_ige_encrypt(buf, buf2,
(unsigned long)lengths[testnum], &aes_ks1, (size_t)lengths[testnum], &aes_ks1,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -840,7 +844,7 @@ static int AES_ige_192_encrypt_loop(void *args) ...@@ -840,7 +844,7 @@ static int AES_ige_192_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_IGE_192_AES][testnum]); count++) for (count = 0; COND(c[D_IGE_192_AES][testnum]); count++)
AES_ige_encrypt(buf, buf2, AES_ige_encrypt(buf, buf2,
(unsigned long)lengths[testnum], &aes_ks2, (size_t)lengths[testnum], &aes_ks2,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -853,7 +857,7 @@ static int AES_ige_256_encrypt_loop(void *args) ...@@ -853,7 +857,7 @@ static int AES_ige_256_encrypt_loop(void *args)
int count; int count;
for (count = 0; COND(c[D_IGE_256_AES][testnum]); count++) for (count = 0; COND(c[D_IGE_256_AES][testnum]); count++)
AES_ige_encrypt(buf, buf2, AES_ige_encrypt(buf, buf2,
(unsigned long)lengths[testnum], &aes_ks3, (size_t)lengths[testnum], &aes_ks3,
iv, AES_ENCRYPT); iv, AES_ENCRYPT);
return count; return count;
} }
...@@ -1922,6 +1926,9 @@ int speed_main(int argc, char **argv) ...@@ -1922,6 +1926,9 @@ int speed_main(int argc, char **argv)
#ifndef OPENSSL_NO_MD5 #ifndef OPENSSL_NO_MD5
if (doit[D_HMAC]) { if (doit[D_HMAC]) {
char hmac_key[] = "This is a key...";
int len = strlen(hmac_key);
for (i = 0; i < loopargs_len; i++) { for (i = 0; i < loopargs_len; i++) {
loopargs[i].hctx = HMAC_CTX_new(); loopargs[i].hctx = HMAC_CTX_new();
if (loopargs[i].hctx == NULL) { if (loopargs[i].hctx == NULL) {
...@@ -1929,8 +1936,7 @@ int speed_main(int argc, char **argv) ...@@ -1929,8 +1936,7 @@ int speed_main(int argc, char **argv)
exit(1); exit(1);
} }
HMAC_Init_ex(loopargs[i].hctx, (unsigned char *)"This is a key...", HMAC_Init_ex(loopargs[i].hctx, hmac_key, len, EVP_md5(), NULL);
16, EVP_md5(), NULL);
} }
for (testnum = 0; testnum < SIZE_NUM; testnum++) { for (testnum = 0; testnum < SIZE_NUM; testnum++) {
print_message(names[D_HMAC], c[D_HMAC][testnum], lengths[testnum]); print_message(names[D_HMAC], c[D_HMAC][testnum], lengths[testnum]);
...@@ -2118,7 +2124,7 @@ int speed_main(int argc, char **argv) ...@@ -2118,7 +2124,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_128_CML][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_128_CML][testnum]); count++)
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &camellia_ks1, (size_t)lengths[testnum], &camellia_ks1,
iv, CAMELLIA_ENCRYPT); iv, CAMELLIA_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_128_CML, testnum, count, d); print_result(D_CBC_128_CML, testnum, count, d);
...@@ -2135,7 +2141,7 @@ int speed_main(int argc, char **argv) ...@@ -2135,7 +2141,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_192_CML][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_192_CML][testnum]); count++)
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &camellia_ks2, (size_t)lengths[testnum], &camellia_ks2,
iv, CAMELLIA_ENCRYPT); iv, CAMELLIA_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_192_CML, testnum, count, d); print_result(D_CBC_192_CML, testnum, count, d);
...@@ -2152,7 +2158,7 @@ int speed_main(int argc, char **argv) ...@@ -2152,7 +2158,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_256_CML][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_256_CML][testnum]); count++)
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &camellia_ks3, (size_t)lengths[testnum], &camellia_ks3,
iv, CAMELLIA_ENCRYPT); iv, CAMELLIA_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_256_CML, testnum, count, d); print_result(D_CBC_256_CML, testnum, count, d);
...@@ -2170,7 +2176,7 @@ int speed_main(int argc, char **argv) ...@@ -2170,7 +2176,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_IDEA][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_IDEA][testnum]); count++)
IDEA_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, IDEA_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &idea_ks, (size_t)lengths[testnum], &idea_ks,
iv, IDEA_ENCRYPT); iv, IDEA_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_IDEA, testnum, count, d); print_result(D_CBC_IDEA, testnum, count, d);
...@@ -2188,7 +2194,7 @@ int speed_main(int argc, char **argv) ...@@ -2188,7 +2194,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_SEED][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_SEED][testnum]); count++)
SEED_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, SEED_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &seed_ks, iv, 1); (size_t)lengths[testnum], &seed_ks, iv, 1);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_SEED, testnum, count, d); print_result(D_CBC_SEED, testnum, count, d);
} }
...@@ -2205,7 +2211,7 @@ int speed_main(int argc, char **argv) ...@@ -2205,7 +2211,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_RC2][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_RC2][testnum]); count++)
RC2_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, RC2_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &rc2_ks, (size_t)lengths[testnum], &rc2_ks,
iv, RC2_ENCRYPT); iv, RC2_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_RC2, testnum, count, d); print_result(D_CBC_RC2, testnum, count, d);
...@@ -2223,7 +2229,7 @@ int speed_main(int argc, char **argv) ...@@ -2223,7 +2229,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_RC5][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_RC5][testnum]); count++)
RC5_32_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, RC5_32_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &rc5_ks, (size_t)lengths[testnum], &rc5_ks,
iv, RC5_ENCRYPT); iv, RC5_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_RC5, testnum, count, d); print_result(D_CBC_RC5, testnum, count, d);
...@@ -2241,7 +2247,7 @@ int speed_main(int argc, char **argv) ...@@ -2241,7 +2247,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_BF][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_BF][testnum]); count++)
BF_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, BF_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &bf_ks, (size_t)lengths[testnum], &bf_ks,
iv, BF_ENCRYPT); iv, BF_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_BF, testnum, count, d); print_result(D_CBC_BF, testnum, count, d);
...@@ -2259,7 +2265,7 @@ int speed_main(int argc, char **argv) ...@@ -2259,7 +2265,7 @@ int speed_main(int argc, char **argv)
Time_F(START); Time_F(START);
for (count = 0, run = 1; COND(c[D_CBC_CAST][testnum]); count++) for (count = 0, run = 1; COND(c[D_CBC_CAST][testnum]); count++)
CAST_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, CAST_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
(unsigned long)lengths[testnum], &cast_ks, (size_t)lengths[testnum], &cast_ks,
iv, CAST_ENCRYPT); iv, CAST_ENCRYPT);
d = Time_F(STOP); d = Time_F(STOP);
print_result(D_CBC_CAST, testnum, count, d); print_result(D_CBC_CAST, testnum, count, d);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册