mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 19:24:37 +00:00
check return values for EVP_Digest*() APIs
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
1fc431ba57
commit
d166ed8c11
@ -287,7 +287,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
|||||||
char *salt_out;
|
char *salt_out;
|
||||||
int n;
|
int n;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
EVP_MD_CTX *md, *md2;
|
EVP_MD_CTX *md = NULL, *md2 = NULL;
|
||||||
size_t passwd_len, salt_len;
|
size_t passwd_len, salt_len;
|
||||||
|
|
||||||
passwd_len = strlen(passwd);
|
passwd_len = strlen(passwd);
|
||||||
@ -303,49 +303,65 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
|||||||
assert(salt_len <= 8);
|
assert(salt_len <= 8);
|
||||||
|
|
||||||
md = EVP_MD_CTX_new();
|
md = EVP_MD_CTX_new();
|
||||||
if (md == NULL)
|
if (md == NULL
|
||||||
return NULL;
|
|| !EVP_DigestInit_ex(md, EVP_md5(), NULL)
|
||||||
EVP_DigestInit_ex(md, EVP_md5(), NULL);
|
|| !EVP_DigestUpdate(md, passwd, passwd_len)
|
||||||
EVP_DigestUpdate(md, passwd, passwd_len);
|
|| !EVP_DigestUpdate(md, "$", 1)
|
||||||
EVP_DigestUpdate(md, "$", 1);
|
|| !EVP_DigestUpdate(md, magic, strlen(magic))
|
||||||
EVP_DigestUpdate(md, magic, strlen(magic));
|
|| !EVP_DigestUpdate(md, "$", 1)
|
||||||
EVP_DigestUpdate(md, "$", 1);
|
|| !EVP_DigestUpdate(md, salt_out, salt_len))
|
||||||
EVP_DigestUpdate(md, salt_out, salt_len);
|
|
||||||
|
|
||||||
md2 = EVP_MD_CTX_new();
|
md2 = EVP_MD_CTX_new();
|
||||||
if (md2 == NULL)
|
if (md2 == NULL
|
||||||
return NULL;
|
|| !EVP_DigestInit_ex(md2, EVP_md5(), NULL)
|
||||||
EVP_DigestInit_ex(md2, EVP_md5(), NULL);
|
|| !EVP_DigestUpdate(md2, passwd, passwd_len)
|
||||||
EVP_DigestUpdate(md2, passwd, passwd_len);
|
|| !EVP_DigestUpdate(md2, salt_out, salt_len)
|
||||||
EVP_DigestUpdate(md2, salt_out, salt_len);
|
|| !EVP_DigestUpdate(md2, passwd, passwd_len)
|
||||||
EVP_DigestUpdate(md2, passwd, passwd_len);
|
|| !EVP_DigestFinal_ex(md2, buf, NULL))
|
||||||
EVP_DigestFinal_ex(md2, buf, NULL);
|
goto err;
|
||||||
|
|
||||||
for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
|
for (i = passwd_len; i > sizeof buf; i -= sizeof buf) {
|
||||||
EVP_DigestUpdate(md, buf, sizeof buf);
|
if (!EVP_DigestUpdate(md, buf, sizeof buf))
|
||||||
EVP_DigestUpdate(md, buf, i);
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestUpdate(md, buf, i))
|
||||||
|
goto err;
|
||||||
|
|
||||||
n = passwd_len;
|
n = passwd_len;
|
||||||
while (n) {
|
while (n) {
|
||||||
EVP_DigestUpdate(md, (n & 1) ? "\0" : passwd, 1);
|
if (!EVP_DigestUpdate(md, (n & 1) ? "\0" : passwd, 1))
|
||||||
|
goto err;
|
||||||
n >>= 1;
|
n >>= 1;
|
||||||
}
|
}
|
||||||
EVP_DigestFinal_ex(md, buf, NULL);
|
if (!EVP_DigestFinal_ex(md, buf, NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < 1000; i++) {
|
for (i = 0; i < 1000; i++) {
|
||||||
EVP_DigestInit_ex(md2, EVP_md5(), NULL);
|
if (!EVP_DigestInit_ex(md2, EVP_md5(), NULL))
|
||||||
EVP_DigestUpdate(md2, (i & 1) ? (unsigned const char *)passwd : buf,
|
goto err;
|
||||||
(i & 1) ? passwd_len : sizeof buf);
|
if (!EVP_DigestUpdate(md2,
|
||||||
if (i % 3)
|
(i & 1) ? (unsigned const char *)passwd : buf,
|
||||||
EVP_DigestUpdate(md2, salt_out, salt_len);
|
(i & 1) ? passwd_len : sizeof buf))
|
||||||
if (i % 7)
|
goto err;
|
||||||
EVP_DigestUpdate(md2, passwd, passwd_len);
|
if (i % 3) {
|
||||||
EVP_DigestUpdate(md2, (i & 1) ? buf : (unsigned const char *)passwd,
|
if (!EVP_DigestUpdate(md2, salt_out, salt_len))
|
||||||
(i & 1) ? sizeof buf : passwd_len);
|
goto err;
|
||||||
EVP_DigestFinal_ex(md2, buf, NULL);
|
}
|
||||||
|
if (i % 7) {
|
||||||
|
if (!EVP_DigestUpdate(md2, passwd, passwd_len))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestUpdate(md2,
|
||||||
|
(i & 1) ? buf : (unsigned const char *)passwd,
|
||||||
|
(i & 1) ? sizeof buf : passwd_len))
|
||||||
|
goto err;
|
||||||
|
if (!EVP_DigestFinal_ex(md2, buf, NULL))
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
EVP_MD_CTX_free(md2);
|
EVP_MD_CTX_free(md2);
|
||||||
EVP_MD_CTX_free(md);
|
EVP_MD_CTX_free(md);
|
||||||
|
md2 = NULL;
|
||||||
|
md = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
/* transform buf into output string */
|
/* transform buf into output string */
|
||||||
@ -386,6 +402,11 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return out_buf;
|
return out_buf;
|
||||||
|
|
||||||
|
err:
|
||||||
|
EVP_MD_CTX_free(md2);
|
||||||
|
EVP_MD_CTX_free(md);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
43
apps/speed.c
43
apps/speed.c
@ -601,9 +601,11 @@ 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++) {
|
||||||
EVP_Digest(buf, (unsigned long)lengths[testnum], &(md2[0]), NULL,
|
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(md2[0]), NULL,
|
||||||
EVP_md2(), NULL);
|
EVP_md2(), NULL))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -615,9 +617,11 @@ 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++) {
|
||||||
EVP_Digest(buf, (unsigned long)lengths[testnum], &(mdc2[0]), NULL,
|
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(mdc2[0]), NULL,
|
||||||
EVP_mdc2(), NULL);
|
EVP_mdc2(), NULL))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -629,9 +633,11 @@ 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++) {
|
||||||
EVP_Digest(&(buf[0]), (unsigned long)lengths[testnum], &(md4[0]),
|
if (!EVP_Digest(&(buf[0]), (unsigned long)lengths[testnum], &(md4[0]),
|
||||||
NULL, EVP_md4(), NULL);
|
NULL, EVP_md4(), NULL))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -717,9 +723,11 @@ static int EVP_Digest_RMD160_loop(void *args)
|
|||||||
unsigned char *buf = tempargs->buf;
|
unsigned char *buf = tempargs->buf;
|
||||||
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++) {
|
||||||
EVP_Digest(buf, (unsigned long)lengths[testnum], &(rmd160[0]), NULL,
|
if (!EVP_Digest(buf, (unsigned long)lengths[testnum], &(rmd160[0]),
|
||||||
EVP_ripemd160(), NULL);
|
NULL, EVP_ripemd160(), NULL))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -888,9 +896,10 @@ static int EVP_Digest_loop(void *args)
|
|||||||
unsigned char md[EVP_MAX_MD_SIZE];
|
unsigned char md[EVP_MAX_MD_SIZE];
|
||||||
int count;
|
int count;
|
||||||
for (count = 0;
|
for (count = 0;
|
||||||
COND(save_count * 4 * lengths[0] / lengths[testnum]); count++)
|
COND(save_count * 4 * lengths[0] / lengths[testnum]); count++) {
|
||||||
EVP_Digest(buf, lengths[testnum], &(md[0]), NULL, evp_md, NULL);
|
if (!EVP_Digest(buf, lengths[testnum], &(md[0]), NULL, evp_md, NULL))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2845,6 +2854,10 @@ static void pkey_print_message(const char *str, const char *str2, long num,
|
|||||||
|
|
||||||
static void print_result(int alg, int run_no, int count, double time_used)
|
static void print_result(int alg, int run_no, int count, double time_used)
|
||||||
{
|
{
|
||||||
|
if (count == -1) {
|
||||||
|
BIO_puts(bio_err, "EVP error!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
mr ? "+R:%d:%s:%f\n"
|
mr ? "+R:%d:%s:%f\n"
|
||||||
: "%d %s's in %.2fs\n", count, names[alg], time_used);
|
: "%d %s's in %.2fs\n", count, names[alg], time_used);
|
||||||
|
23
apps/ts.c
23
apps/ts.c
@ -492,28 +492,30 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
|
|||||||
unsigned char **md_value)
|
unsigned char **md_value)
|
||||||
{
|
{
|
||||||
int md_value_len;
|
int md_value_len;
|
||||||
|
int rv = 0;
|
||||||
|
EVP_MD_CTX *md_ctx = NULL;
|
||||||
|
|
||||||
md_value_len = EVP_MD_size(md);
|
md_value_len = EVP_MD_size(md);
|
||||||
if (md_value_len < 0)
|
if (md_value_len < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
|
|
||||||
unsigned char buffer[4096];
|
unsigned char buffer[4096];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
md_ctx = EVP_MD_CTX_new();
|
||||||
if (md_ctx == NULL)
|
if (md_ctx == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
*md_value = app_malloc(md_value_len, "digest buffer");
|
*md_value = app_malloc(md_value_len, "digest buffer");
|
||||||
EVP_DigestInit(md_ctx, md);
|
if (!EVP_DigestInit(md_ctx, md))
|
||||||
|
goto err;
|
||||||
while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) {
|
while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) {
|
||||||
EVP_DigestUpdate(md_ctx, buffer, length);
|
if (!EVP_DigestUpdate(md_ctx, buffer, length))
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
if (!EVP_DigestFinal(md_ctx, *md_value, NULL)) {
|
if (!EVP_DigestFinal(md_ctx, *md_value, NULL))
|
||||||
EVP_MD_CTX_free(md_ctx);
|
goto err;
|
||||||
return 0;
|
md_value_len = EVP_MD_size(md);
|
||||||
}
|
|
||||||
EVP_MD_CTX_free(md_ctx);
|
|
||||||
} else {
|
} else {
|
||||||
long digest_len;
|
long digest_len;
|
||||||
*md_value = OPENSSL_hexstr2buf(digest, &digest_len);
|
*md_value = OPENSSL_hexstr2buf(digest, &digest_len);
|
||||||
@ -525,7 +527,10 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return md_value_len;
|
rv = md_value_len;
|
||||||
|
err:
|
||||||
|
EVP_MD_CTX_free(md_ctx);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ASN1_INTEGER *create_nonce(int bits)
|
static ASN1_INTEGER *create_nonce(int bits)
|
||||||
|
@ -117,8 +117,8 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
|
|||||||
goto err;
|
goto err;
|
||||||
for (i = 1;; i++) {
|
for (i = 1;; i++) {
|
||||||
unsigned char mtmp[EVP_MAX_MD_SIZE];
|
unsigned char mtmp[EVP_MAX_MD_SIZE];
|
||||||
EVP_DigestInit_ex(mctx, md, NULL);
|
if (!EVP_DigestInit_ex(mctx, md, NULL)
|
||||||
if (!EVP_DigestUpdate(mctx, Z, Zlen))
|
|| !EVP_DigestUpdate(mctx, Z, Zlen))
|
||||||
goto err;
|
goto err;
|
||||||
ctr[3] = i & 0xFF;
|
ctr[3] = i & 0xFF;
|
||||||
ctr[2] = (i >> 8) & 0xFF;
|
ctr[2] = (i >> 8) & 0xFF;
|
||||||
|
@ -34,7 +34,8 @@ int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
|
|||||||
mdlen = EVP_MD_size(md);
|
mdlen = EVP_MD_size(md);
|
||||||
for (i = 1;; i++) {
|
for (i = 1;; i++) {
|
||||||
unsigned char mtmp[EVP_MAX_MD_SIZE];
|
unsigned char mtmp[EVP_MAX_MD_SIZE];
|
||||||
EVP_DigestInit_ex(mctx, md, NULL);
|
if (!EVP_DigestInit_ex(mctx, md, NULL))
|
||||||
|
goto err;
|
||||||
ctr[3] = i & 0xFF;
|
ctr[3] = i & 0xFF;
|
||||||
ctr[2] = (i >> 8) & 0xFF;
|
ctr[2] = (i >> 8) & 0xFF;
|
||||||
ctr[1] = (i >> 16) & 0xFF;
|
ctr[1] = (i >> 16) & 0xFF;
|
||||||
|
@ -60,7 +60,7 @@ static CRYPTO_THREAD_ID locking_threadid;
|
|||||||
int rand_predictable = 0;
|
int rand_predictable = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void rand_hw_seed(EVP_MD_CTX *ctx);
|
static int rand_hw_seed(EVP_MD_CTX *ctx);
|
||||||
|
|
||||||
static void rand_cleanup(void);
|
static void rand_cleanup(void);
|
||||||
static int rand_seed(const void *buf, int num);
|
static int rand_seed(const void *buf, int num);
|
||||||
@ -446,7 +446,8 @@ static int rand_bytes(unsigned char *buf, int num, int pseudo)
|
|||||||
if (!MD_Update(m, (unsigned char *)&tv, sizeof tv))
|
if (!MD_Update(m, (unsigned char *)&tv, sizeof tv))
|
||||||
goto err;
|
goto err;
|
||||||
curr_time = 0;
|
curr_time = 0;
|
||||||
rand_hw_seed(m);
|
if (!rand_hw_seed(m))
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
if (!MD_Update(m, local_md, MD_DIGEST_LENGTH))
|
if (!MD_Update(m, local_md, MD_DIGEST_LENGTH))
|
||||||
goto err;
|
goto err;
|
||||||
@ -597,18 +598,20 @@ static int rand_status(void)
|
|||||||
size_t OPENSSL_ia32_rdrand(void);
|
size_t OPENSSL_ia32_rdrand(void);
|
||||||
extern unsigned int OPENSSL_ia32cap_P[];
|
extern unsigned int OPENSSL_ia32cap_P[];
|
||||||
|
|
||||||
static void rand_hw_seed(EVP_MD_CTX *ctx)
|
static int rand_hw_seed(EVP_MD_CTX *ctx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (!(OPENSSL_ia32cap_P[1] & (1 << (62 - 32))))
|
if (!(OPENSSL_ia32cap_P[1] & (1 << (62 - 32))))
|
||||||
return;
|
return 1;
|
||||||
for (i = 0; i < RDRAND_CALLS; i++) {
|
for (i = 0; i < RDRAND_CALLS; i++) {
|
||||||
size_t rnd;
|
size_t rnd;
|
||||||
rnd = OPENSSL_ia32_rdrand();
|
rnd = OPENSSL_ia32_rdrand();
|
||||||
if (rnd == 0)
|
if (rnd == 0)
|
||||||
return;
|
return 1;
|
||||||
MD_Update(ctx, (unsigned char *)&rnd, sizeof(size_t));
|
if (!MD_Update(ctx, (unsigned char *)&rnd, sizeof(size_t)))
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XOR an existing buffer with random data */
|
/* XOR an existing buffer with random data */
|
||||||
|
@ -35,17 +35,20 @@ static BIGNUM *srp_Calc_k(const BIGNUM *N, const BIGNUM *g)
|
|||||||
goto err;
|
goto err;
|
||||||
BN_bn2bin(N, tmp);
|
BN_bn2bin(N, tmp);
|
||||||
|
|
||||||
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
|
if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
|
||||||
EVP_DigestUpdate(ctxt, tmp, longN);
|
|| !EVP_DigestUpdate(ctxt, tmp, longN))
|
||||||
|
goto err;
|
||||||
|
|
||||||
memset(tmp, 0, longN);
|
memset(tmp, 0, longN);
|
||||||
longg = BN_bn2bin(g, tmp);
|
longg = BN_bn2bin(g, tmp);
|
||||||
/* use the zeros behind to pad on left */
|
/* use the zeros behind to pad on left */
|
||||||
EVP_DigestUpdate(ctxt, tmp + longg, longN - longg);
|
if (!EVP_DigestUpdate(ctxt, tmp + longg, longN - longg)
|
||||||
EVP_DigestUpdate(ctxt, tmp, longg);
|
|| !EVP_DigestUpdate(ctxt, tmp, longg))
|
||||||
|
goto err;
|
||||||
OPENSSL_free(tmp);
|
OPENSSL_free(tmp);
|
||||||
|
|
||||||
EVP_DigestFinal_ex(ctxt, digest, NULL);
|
if (!EVP_DigestFinal_ex(ctxt, digest, NULL))
|
||||||
|
goto err;
|
||||||
res = BN_bin2bn(digest, sizeof(digest), NULL);
|
res = BN_bin2bn(digest, sizeof(digest), NULL);
|
||||||
err:
|
err:
|
||||||
EVP_MD_CTX_free(ctxt);
|
EVP_MD_CTX_free(ctxt);
|
||||||
@ -77,11 +80,13 @@ BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N)
|
|||||||
|
|
||||||
memset(cAB, 0, longN);
|
memset(cAB, 0, longN);
|
||||||
|
|
||||||
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
|
if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
|
||||||
EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(A, cAB + longN), longN);
|
|| !EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(A, cAB + longN), longN)
|
||||||
EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(B, cAB + longN), longN);
|
|| !EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(B, cAB + longN), longN))
|
||||||
|
goto err;
|
||||||
OPENSSL_free(cAB);
|
OPENSSL_free(cAB);
|
||||||
EVP_DigestFinal_ex(ctxt, cu, NULL);
|
if (!EVP_DigestFinal_ex(ctxt, cu, NULL))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if ((u = BN_bin2bn(cu, sizeof(cu), NULL)) == NULL)
|
if ((u = BN_bin2bn(cu, sizeof(cu), NULL)) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
@ -173,18 +178,20 @@ BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass)
|
|||||||
if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
|
if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
|
if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
|
||||||
EVP_DigestUpdate(ctxt, user, strlen(user));
|
|| !EVP_DigestUpdate(ctxt, user, strlen(user))
|
||||||
EVP_DigestUpdate(ctxt, ":", 1);
|
|| !EVP_DigestUpdate(ctxt, ":", 1)
|
||||||
EVP_DigestUpdate(ctxt, pass, strlen(pass));
|
|| !EVP_DigestUpdate(ctxt, pass, strlen(pass))
|
||||||
EVP_DigestFinal_ex(ctxt, dig, NULL);
|
|| !EVP_DigestFinal_ex(ctxt, dig, NULL)
|
||||||
|
|| !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL))
|
||||||
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
|
goto err;
|
||||||
BN_bn2bin(s, cs);
|
BN_bn2bin(s, cs);
|
||||||
EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s));
|
if (!EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s)))
|
||||||
|
goto err;
|
||||||
OPENSSL_free(cs);
|
OPENSSL_free(cs);
|
||||||
EVP_DigestUpdate(ctxt, dig, sizeof(dig));
|
if (!EVP_DigestUpdate(ctxt, dig, sizeof(dig))
|
||||||
EVP_DigestFinal_ex(ctxt, dig, NULL);
|
|| !EVP_DigestFinal_ex(ctxt, dig, NULL))
|
||||||
|
goto err;
|
||||||
|
|
||||||
res = BN_bin2bn(dig, sizeof(dig), NULL);
|
res = BN_bin2bn(dig, sizeof(dig), NULL);
|
||||||
err:
|
err:
|
||||||
|
@ -500,10 +500,12 @@ SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username)
|
|||||||
if (RAND_bytes(digv, SHA_DIGEST_LENGTH) <= 0)
|
if (RAND_bytes(digv, SHA_DIGEST_LENGTH) <= 0)
|
||||||
goto err;
|
goto err;
|
||||||
ctxt = EVP_MD_CTX_new();
|
ctxt = EVP_MD_CTX_new();
|
||||||
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
|
if (ctxt == NULL
|
||||||
EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key));
|
|| !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
|
||||||
EVP_DigestUpdate(ctxt, username, strlen(username));
|
|| !EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key))
|
||||||
EVP_DigestFinal_ex(ctxt, digs, NULL);
|
|| !EVP_DigestUpdate(ctxt, username, strlen(username))
|
||||||
|
|| !EVP_DigestFinal_ex(ctxt, digs, NULL))
|
||||||
|
goto err;
|
||||||
EVP_MD_CTX_free(ctxt);
|
EVP_MD_CTX_free(ctxt);
|
||||||
ctxt = NULL;
|
ctxt = NULL;
|
||||||
if (SRP_user_pwd_set_sv_BN(user,
|
if (SRP_user_pwd_set_sv_BN(user,
|
||||||
|
@ -500,22 +500,22 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
|
|||||||
# define EVP_MD_CTX_create() EVP_MD_CTX_new()
|
# define EVP_MD_CTX_create() EVP_MD_CTX_new()
|
||||||
# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
|
# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
|
||||||
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
|
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
|
||||||
/*__owur*/ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
|
__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
|
||||||
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
|
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
|
||||||
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
|
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
|
||||||
int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
|
int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
|
||||||
/*__owur*/ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
|
__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
|
||||||
ENGINE *impl);
|
ENGINE *impl);
|
||||||
/*__owur*/ int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,
|
__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,
|
||||||
size_t cnt);
|
size_t cnt);
|
||||||
/*__owur*/ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
|
__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
|
||||||
unsigned int *s);
|
unsigned int *s);
|
||||||
/*__owur*/ int EVP_Digest(const void *data, size_t count,
|
__owur int EVP_Digest(const void *data, size_t count,
|
||||||
unsigned char *md, unsigned int *size,
|
unsigned char *md, unsigned int *size,
|
||||||
const EVP_MD *type, ENGINE *impl);
|
const EVP_MD *type, ENGINE *impl);
|
||||||
|
|
||||||
/*__owur*/ int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
|
__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
|
||||||
/*__owur*/ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
|
__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
|
||||||
__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
|
__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
|
||||||
unsigned int *s);
|
unsigned int *s);
|
||||||
|
|
||||||
|
@ -1015,9 +1015,12 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!send && !SSL_USE_ETM(ssl) && FIPS_mode())
|
if (!send && !SSL_USE_ETM(ssl) && FIPS_mode())
|
||||||
tls_fips_digest_extra(ssl->enc_read_ctx,
|
if (!tls_fips_digest_extra(ssl->enc_read_ctx,
|
||||||
mac_ctx, rec->input,
|
mac_ctx, rec->input,
|
||||||
rec->length, rec->orig_len);
|
rec->length, rec->orig_len)) {
|
||||||
|
EVP_MD_CTX_free(hmac);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EVP_MD_CTX_free(hmac);
|
EVP_MD_CTX_free(hmac);
|
||||||
|
@ -490,13 +490,13 @@ err:
|
|||||||
* digesting additional data.
|
* digesting additional data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
|
int tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
|
||||||
EVP_MD_CTX *mac_ctx, const unsigned char *data,
|
EVP_MD_CTX *mac_ctx, const unsigned char *data,
|
||||||
size_t data_len, size_t orig_len)
|
size_t data_len, size_t orig_len)
|
||||||
{
|
{
|
||||||
size_t block_size, digest_pad, blocks_data, blocks_orig;
|
size_t block_size, digest_pad, blocks_data, blocks_orig;
|
||||||
if (EVP_CIPHER_CTX_mode(cipher_ctx) != EVP_CIPH_CBC_MODE)
|
if (EVP_CIPHER_CTX_mode(cipher_ctx) != EVP_CIPH_CBC_MODE)
|
||||||
return;
|
return 1;
|
||||||
block_size = EVP_MD_CTX_block_size(mac_ctx);
|
block_size = EVP_MD_CTX_block_size(mac_ctx);
|
||||||
/*-
|
/*-
|
||||||
* We are in FIPS mode if we get this far so we know we have only SHA*
|
* We are in FIPS mode if we get this far so we know we have only SHA*
|
||||||
@ -526,6 +526,6 @@ void tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
|
|||||||
* The "data" pointer should always have enough space to perform this
|
* The "data" pointer should always have enough space to perform this
|
||||||
* operation as it is large enough for a maximum length TLS buffer.
|
* operation as it is large enough for a maximum length TLS buffer.
|
||||||
*/
|
*/
|
||||||
EVP_DigestSignUpdate(mac_ctx, data,
|
return EVP_DigestSignUpdate(mac_ctx, data,
|
||||||
(blocks_orig - blocks_data + 1) * block_size);
|
(blocks_orig - blocks_data + 1) * block_size);
|
||||||
}
|
}
|
||||||
|
40
ssl/s3_enc.c
40
ssl/s3_enc.c
@ -70,23 +70,26 @@ static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
|
|||||||
for (j = 0; j < k; j++)
|
for (j = 0; j < k; j++)
|
||||||
buf[j] = c;
|
buf[j] = c;
|
||||||
c++;
|
c++;
|
||||||
EVP_DigestInit_ex(s1, EVP_sha1(), NULL);
|
if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)
|
||||||
EVP_DigestUpdate(s1, buf, k);
|
|| !EVP_DigestUpdate(s1, buf, k)
|
||||||
EVP_DigestUpdate(s1, s->session->master_key,
|
|| !EVP_DigestUpdate(s1, s->session->master_key,
|
||||||
s->session->master_key_length);
|
s->session->master_key_length)
|
||||||
EVP_DigestUpdate(s1, s->s3->server_random, SSL3_RANDOM_SIZE);
|
|| !EVP_DigestUpdate(s1, s->s3->server_random, SSL3_RANDOM_SIZE)
|
||||||
EVP_DigestUpdate(s1, s->s3->client_random, SSL3_RANDOM_SIZE);
|
|| !EVP_DigestUpdate(s1, s->s3->client_random, SSL3_RANDOM_SIZE)
|
||||||
EVP_DigestFinal_ex(s1, smd, NULL);
|
|| !EVP_DigestFinal_ex(s1, smd, NULL)
|
||||||
|
|| !EVP_DigestInit_ex(m5, EVP_md5(), NULL)
|
||||||
EVP_DigestInit_ex(m5, EVP_md5(), NULL);
|
|| !EVP_DigestUpdate(m5, s->session->master_key,
|
||||||
EVP_DigestUpdate(m5, s->session->master_key,
|
s->session->master_key_length)
|
||||||
s->session->master_key_length);
|
|| !EVP_DigestUpdate(m5, smd, SHA_DIGEST_LENGTH))
|
||||||
EVP_DigestUpdate(m5, smd, SHA_DIGEST_LENGTH);
|
goto err;
|
||||||
if ((int)(i + MD5_DIGEST_LENGTH) > num) {
|
if ((int)(i + MD5_DIGEST_LENGTH) > num) {
|
||||||
EVP_DigestFinal_ex(m5, smd, NULL);
|
if (!EVP_DigestFinal_ex(m5, smd, NULL))
|
||||||
|
goto err;
|
||||||
memcpy(km, smd, (num - i));
|
memcpy(km, smd, (num - i));
|
||||||
} else
|
} else {
|
||||||
EVP_DigestFinal_ex(m5, km, NULL);
|
if (!EVP_DigestFinal_ex(m5, km, NULL))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
km += MD5_DIGEST_LENGTH;
|
km += MD5_DIGEST_LENGTH;
|
||||||
}
|
}
|
||||||
@ -353,12 +356,13 @@ void ssl3_free_digest_list(SSL *s)
|
|||||||
s->s3->handshake_dgst = NULL;
|
s->s3->handshake_dgst = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len)
|
int ssl3_finish_mac(SSL *s, const unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
if (s->s3->handshake_dgst == NULL)
|
if (s->s3->handshake_dgst == NULL)
|
||||||
BIO_write(s->s3->handshake_buffer, (void *)buf, len);
|
/* Note: this writes to a memory BIO so a failure is a fatal error */
|
||||||
|
return BIO_write(s->s3->handshake_buffer, (void *)buf, len) == len;
|
||||||
else
|
else
|
||||||
EVP_DigestUpdate(s->s3->handshake_dgst, buf, len);
|
return EVP_DigestUpdate(s->s3->handshake_dgst, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssl3_digest_cached_records(SSL *s, int keep)
|
int ssl3_digest_cached_records(SSL *s, int keep)
|
||||||
|
@ -1875,7 +1875,7 @@ int ssl3_renegotiate_check(SSL *ssl);
|
|||||||
__owur int ssl3_dispatch_alert(SSL *s);
|
__owur int ssl3_dispatch_alert(SSL *s);
|
||||||
__owur int ssl3_final_finish_mac(SSL *s, const char *sender, int slen,
|
__owur int ssl3_final_finish_mac(SSL *s, const char *sender, int slen,
|
||||||
unsigned char *p);
|
unsigned char *p);
|
||||||
void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
|
__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
|
||||||
void ssl3_free_digest_list(SSL *s);
|
void ssl3_free_digest_list(SSL *s);
|
||||||
__owur unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk);
|
__owur unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk);
|
||||||
__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
|
__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
|
||||||
@ -2085,7 +2085,7 @@ __owur int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx,
|
|||||||
const unsigned char *mac_secret,
|
const unsigned char *mac_secret,
|
||||||
unsigned mac_secret_length, char is_sslv3);
|
unsigned mac_secret_length, char is_sslv3);
|
||||||
|
|
||||||
void tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
|
__owur int tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx,
|
||||||
EVP_MD_CTX *mac_ctx, const unsigned char *data,
|
EVP_MD_CTX *mac_ctx, const unsigned char *data,
|
||||||
size_t data_len, size_t orig_len);
|
size_t data_len, size_t orig_len);
|
||||||
|
|
||||||
|
@ -1890,9 +1890,12 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
|||||||
* elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is
|
* elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is
|
||||||
* SHA256 is disabled) hash of the ticket.
|
* SHA256 is disabled) hash of the ticket.
|
||||||
*/
|
*/
|
||||||
EVP_Digest(s->session->tlsext_tick, ticklen,
|
if (!EVP_Digest(s->session->tlsext_tick, ticklen,
|
||||||
s->session->session_id, &s->session->session_id_length,
|
s->session->session_id, &s->session->session_id_length,
|
||||||
EVP_sha256(), NULL);
|
EVP_sha256(), NULL)) {
|
||||||
|
SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_EVP_LIB);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
return MSG_PROCESS_CONTINUE_READING;
|
return MSG_PROCESS_CONTINUE_READING;
|
||||||
f_err:
|
f_err:
|
||||||
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
ssl3_send_alert(s, SSL3_AL_FATAL, al);
|
||||||
|
@ -294,7 +294,8 @@ int dtls1_do_write(SSL *s, int type)
|
|||||||
xlen = ret - DTLS1_HM_HEADER_LENGTH;
|
xlen = ret - DTLS1_HM_HEADER_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl3_finish_mac(s, p, xlen);
|
if (!ssl3_finish_mac(s, p, xlen))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == s->init_num) {
|
if (ret == s->init_num) {
|
||||||
@ -375,7 +376,8 @@ int dtls_get_message(SSL *s, int *mt, unsigned long *len)
|
|||||||
msg_len += DTLS1_HM_HEADER_LENGTH;
|
msg_len += DTLS1_HM_HEADER_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl3_finish_mac(s, p, msg_len);
|
if (!ssl3_finish_mac(s, p, msg_len))
|
||||||
|
return 0;
|
||||||
if (s->msg_callback)
|
if (s->msg_callback)
|
||||||
s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,
|
s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,
|
||||||
p, msg_len, s, s->msg_callback_arg);
|
p, msg_len, s, s->msg_callback_arg);
|
||||||
|
@ -40,8 +40,10 @@ int ssl3_do_write(SSL *s, int type)
|
|||||||
* should not be done for 'Hello Request's, but in that case we'll
|
* should not be done for 'Hello Request's, but in that case we'll
|
||||||
* ignore the result anyway
|
* ignore the result anyway
|
||||||
*/
|
*/
|
||||||
ssl3_finish_mac(s, (unsigned char *)&s->init_buf->data[s->init_off],
|
if (!ssl3_finish_mac(s,
|
||||||
ret);
|
(unsigned char *)&s->init_buf->data[s->init_off],
|
||||||
|
ret))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (ret == s->init_num) {
|
if (ret == s->init_num) {
|
||||||
if (s->msg_callback)
|
if (s->msg_callback)
|
||||||
@ -481,13 +483,24 @@ int tls_get_message_body(SSL *s, unsigned long *len)
|
|||||||
|
|
||||||
/* Feed this message into MAC computation. */
|
/* Feed this message into MAC computation. */
|
||||||
if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) {
|
if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) {
|
||||||
ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num);
|
if (!ssl3_finish_mac(s, (unsigned char *)s->init_buf->data,
|
||||||
|
s->init_num)) {
|
||||||
|
SSLerr(SSL_F_TLS_GET_MESSAGE_BODY, ERR_R_EVP_LIB);
|
||||||
|
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
||||||
|
*len = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (s->msg_callback)
|
if (s->msg_callback)
|
||||||
s->msg_callback(0, SSL2_VERSION, 0, s->init_buf->data,
|
s->msg_callback(0, SSL2_VERSION, 0, s->init_buf->data,
|
||||||
(size_t)s->init_num, s, s->msg_callback_arg);
|
(size_t)s->init_num, s, s->msg_callback_arg);
|
||||||
} else {
|
} else {
|
||||||
ssl3_finish_mac(s, (unsigned char *)s->init_buf->data,
|
if (!ssl3_finish_mac(s, (unsigned char *)s->init_buf->data,
|
||||||
s->init_num + SSL3_HM_HEADER_LENGTH);
|
s->init_num + SSL3_HM_HEADER_LENGTH)) {
|
||||||
|
SSLerr(SSL_F_TLS_GET_MESSAGE_BODY, ERR_R_EVP_LIB);
|
||||||
|
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
||||||
|
*len = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (s->msg_callback)
|
if (s->msg_callback)
|
||||||
s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data,
|
s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data,
|
||||||
(size_t)s->init_num + SSL3_HM_HEADER_LENGTH, s,
|
(size_t)s->init_num + SSL3_HM_HEADER_LENGTH, s,
|
||||||
|
@ -60,8 +60,11 @@ int main(int argc, char *argv[])
|
|||||||
R = ret;
|
R = ret;
|
||||||
i = 1;
|
i = 1;
|
||||||
while (*P != NULL) {
|
while (*P != NULL) {
|
||||||
EVP_Digest((unsigned char *)*P, strlen(*P), md, NULL, EVP_md2(),
|
if (!EVP_Digest((unsigned char *)*P, strlen(*P), md, NULL, EVP_md2(),
|
||||||
NULL);
|
NULL)) {
|
||||||
|
printf("EVP Digest error.\n");
|
||||||
|
EXIT(1);
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
if (strcmp(p, *R) != 0) {
|
if (strcmp(p, *R) != 0) {
|
||||||
printf("error calculating MD2 on '%s'\n", *P);
|
printf("error calculating MD2 on '%s'\n", *P);
|
||||||
|
@ -56,7 +56,11 @@ int main(int argc, char *argv[])
|
|||||||
R = ret;
|
R = ret;
|
||||||
i = 1;
|
i = 1;
|
||||||
while (*P != NULL) {
|
while (*P != NULL) {
|
||||||
EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_md4(), NULL);
|
if (!EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_md4(),
|
||||||
|
NULL)) {
|
||||||
|
printf("EVP Digest error.\n");
|
||||||
|
EXIT(1);
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
if (strcmp(p, (char *)*R) != 0) {
|
if (strcmp(p, (char *)*R) != 0) {
|
||||||
printf("error calculating MD4 on '%s'\n", *P);
|
printf("error calculating MD4 on '%s'\n", *P);
|
||||||
|
@ -56,7 +56,11 @@ int main(int argc, char *argv[])
|
|||||||
R = ret;
|
R = ret;
|
||||||
i = 1;
|
i = 1;
|
||||||
while (*P != NULL) {
|
while (*P != NULL) {
|
||||||
EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_md5(), NULL);
|
if (!EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_md5(),
|
||||||
|
NULL)) {
|
||||||
|
printf("EVP Digest error.\n");
|
||||||
|
EXIT(1);
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
if (strcmp(p, (char *)*R) != 0) {
|
if (strcmp(p, (char *)*R) != 0) {
|
||||||
printf("error calculating MD5 on '%s'\n", *P);
|
printf("error calculating MD5 on '%s'\n", *P);
|
||||||
|
@ -43,7 +43,7 @@ static unsigned char pad2[16] = {
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 1;
|
||||||
unsigned char md[MDC2_DIGEST_LENGTH];
|
unsigned char md[MDC2_DIGEST_LENGTH];
|
||||||
int i;
|
int i;
|
||||||
EVP_MD_CTX *c;
|
EVP_MD_CTX *c;
|
||||||
@ -54,9 +54,11 @@ int main(int argc, char *argv[])
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
c = EVP_MD_CTX_new();
|
c = EVP_MD_CTX_new();
|
||||||
EVP_DigestInit_ex(c, EVP_mdc2(), NULL);
|
if (c == NULL
|
||||||
EVP_DigestUpdate(c, (unsigned char *)text, strlen(text));
|
|| !EVP_DigestInit_ex(c, EVP_mdc2(), NULL)
|
||||||
EVP_DigestFinal_ex(c, &(md[0]), NULL);
|
|| !EVP_DigestUpdate(c, (unsigned char *)text, strlen(text))
|
||||||
|
|| !EVP_DigestFinal_ex(c, &(md[0]), NULL))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (memcmp(md, pad1, MDC2_DIGEST_LENGTH) != 0) {
|
if (memcmp(md, pad1, MDC2_DIGEST_LENGTH) != 0) {
|
||||||
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
||||||
@ -65,15 +67,18 @@ int main(int argc, char *argv[])
|
|||||||
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
||||||
printf("%02X", pad1[i]);
|
printf("%02X", pad1[i]);
|
||||||
printf(" <- correct\n");
|
printf(" <- correct\n");
|
||||||
ret = 1;
|
goto err;
|
||||||
} else
|
} else {
|
||||||
printf("pad1 - ok\n");
|
printf("pad1 - ok\n");
|
||||||
|
}
|
||||||
|
|
||||||
EVP_DigestInit_ex(c, EVP_mdc2(), NULL);
|
if (!EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
|
||||||
|
goto err;
|
||||||
/* FIXME: use a ctl function? */
|
/* FIXME: use a ctl function? */
|
||||||
((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
|
((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
|
||||||
EVP_DigestUpdate(c, (unsigned char *)text, strlen(text));
|
if (!EVP_DigestUpdate(c, (unsigned char *)text, strlen(text))
|
||||||
EVP_DigestFinal_ex(c, &(md[0]), NULL);
|
|| !EVP_DigestFinal_ex(c, &(md[0]), NULL))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (memcmp(md, pad2, MDC2_DIGEST_LENGTH) != 0) {
|
if (memcmp(md, pad2, MDC2_DIGEST_LENGTH) != 0) {
|
||||||
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
||||||
@ -82,10 +87,12 @@ int main(int argc, char *argv[])
|
|||||||
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
|
||||||
printf("%02X", pad2[i]);
|
printf("%02X", pad2[i]);
|
||||||
printf(" <- correct\n");
|
printf(" <- correct\n");
|
||||||
ret = 1;
|
} else {
|
||||||
} else
|
|
||||||
printf("pad2 - ok\n");
|
printf("pad2 - ok\n");
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
EVP_MD_CTX_free(c);
|
EVP_MD_CTX_free(c);
|
||||||
EXIT(ret);
|
EXIT(ret);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,11 @@ int main(int argc, char *argv[])
|
|||||||
# ifdef CHARSET_EBCDIC
|
# ifdef CHARSET_EBCDIC
|
||||||
ebcdic2ascii(test[i], test[i], strlen(test[i]));
|
ebcdic2ascii(test[i], test[i], strlen(test[i]));
|
||||||
# endif
|
# endif
|
||||||
EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_ripemd160(),
|
if (!EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_ripemd160(),
|
||||||
NULL);
|
NULL)) {
|
||||||
|
printf("EVP Digest error.\n");
|
||||||
|
EXIT(1);
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
if (strcmp(p, (char *)*R) != 0) {
|
if (strcmp(p, (char *)*R) != 0) {
|
||||||
printf("error calculating RIPEMD160 on '%s'\n", test[i]);
|
printf("error calculating RIPEMD160 on '%s'\n", test[i]);
|
||||||
|
@ -48,7 +48,12 @@ int main(int argc, char *argv[])
|
|||||||
# ifdef CHARSET_EBCDIC
|
# ifdef CHARSET_EBCDIC
|
||||||
ebcdic2ascii(test[i], test[i], strlen(test[i]));
|
ebcdic2ascii(test[i], test[i], strlen(test[i]));
|
||||||
# endif
|
# endif
|
||||||
EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_sha1(), NULL);
|
if (!EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_sha1(),
|
||||||
|
NULL)) {
|
||||||
|
printf("EVP_Digest() error\n");
|
||||||
|
err++;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
if (strcmp(p, (char *)*R) != 0) {
|
if (strcmp(p, (char *)*R) != 0) {
|
||||||
printf("error calculating SHA1 on '%s'\n", test[i]);
|
printf("error calculating SHA1 on '%s'\n", test[i]);
|
||||||
@ -63,10 +68,23 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef CHARSET_EBCDIC
|
#ifdef CHARSET_EBCDIC
|
||||||
ebcdic2ascii(buf, buf, 1000);
|
ebcdic2ascii(buf, buf, 1000);
|
||||||
#endif /* CHARSET_EBCDIC */
|
#endif /* CHARSET_EBCDIC */
|
||||||
EVP_DigestInit_ex(c, EVP_sha1(), NULL);
|
if (!EVP_DigestInit_ex(c, EVP_sha1(), NULL)) {
|
||||||
for (i = 0; i < 1000; i++)
|
printf("EVP_DigestInit_ex() error\n");
|
||||||
EVP_DigestUpdate(c, buf, 1000);
|
err++;
|
||||||
EVP_DigestFinal_ex(c, md, NULL);
|
goto err;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if (!EVP_DigestUpdate(c, buf, 1000)) {
|
||||||
|
printf("EVP_DigestUpdate() error\n");
|
||||||
|
err++;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!EVP_DigestFinal_ex(c, md, NULL)) {
|
||||||
|
printf("EVP_DigestFinal() error\n");
|
||||||
|
err++;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
p = pt(md);
|
p = pt(md);
|
||||||
|
|
||||||
r = bigret;
|
r = bigret;
|
||||||
@ -76,7 +94,7 @@ int main(int argc, char *argv[])
|
|||||||
err++;
|
err++;
|
||||||
} else
|
} else
|
||||||
printf("test 3 ok\n");
|
printf("test 3 ok\n");
|
||||||
|
err:
|
||||||
EVP_MD_CTX_free(c);
|
EVP_MD_CTX_free(c);
|
||||||
EXIT(err);
|
EXIT(err);
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -64,7 +64,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
fprintf(stdout, "Testing SHA-256 ");
|
fprintf(stdout, "Testing SHA-256 ");
|
||||||
|
|
||||||
EVP_Digest("abc", 3, md, NULL, EVP_sha256(), NULL);
|
if (!EVP_Digest("abc", 3, md, NULL, EVP_sha256(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_b1, sizeof(app_b1))) {
|
if (memcmp(md, app_b1, sizeof(app_b1))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
||||||
@ -73,9 +74,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
|
if (!EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
|
||||||
"ijkljklm" "klmnlmno" "mnopnopq", 56, md, NULL, EVP_sha256(),
|
"ijkljklm" "klmnlmno" "mnopnopq", 56, md,
|
||||||
NULL);
|
NULL, EVP_sha256(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_b2, sizeof(app_b2))) {
|
if (memcmp(md, app_b2, sizeof(app_b2))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
||||||
@ -90,9 +92,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
|
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
EVP_DigestInit_ex(evp, EVP_sha256(), NULL);
|
if (!EVP_DigestInit_ex(evp, EVP_sha256(), NULL))
|
||||||
for (i = 0; i < 1000000; i += 288)
|
goto err;
|
||||||
EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
for (i = 0; i < 1000000; i += 288) {
|
||||||
|
if (!EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
@ -101,8 +104,11 @@ int main(int argc, char **argv)
|
|||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
||||||
(1000000 - i) < 288 ? 1000000 - i : 288);
|
(1000000 - i) < 288 ? 1000000 - i : 288))
|
||||||
EVP_DigestFinal_ex(evp, md, NULL);
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestFinal_ex(evp, md, NULL))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (memcmp(md, app_b3, sizeof(app_b3))) {
|
if (memcmp(md, app_b3, sizeof(app_b3))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -117,7 +123,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
fprintf(stdout, "Testing SHA-224 ");
|
fprintf(stdout, "Testing SHA-224 ");
|
||||||
|
|
||||||
EVP_Digest("abc", 3, md, NULL, EVP_sha224(), NULL);
|
if (!EVP_Digest("abc", 3, md, NULL, EVP_sha224(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, addenum_1, sizeof(addenum_1))) {
|
if (memcmp(md, addenum_1, sizeof(addenum_1))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
||||||
@ -126,9 +133,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
|
if (!EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
|
||||||
"ijkljklm" "klmnlmno" "mnopnopq", 56, md, NULL, EVP_sha224(),
|
"ijkljklm" "klmnlmno" "mnopnopq", 56, md,
|
||||||
NULL);
|
NULL, EVP_sha224(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, addenum_2, sizeof(addenum_2))) {
|
if (memcmp(md, addenum_2, sizeof(addenum_2))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
||||||
@ -138,12 +146,16 @@ int main(int argc, char **argv)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_MD_CTX_reset(evp);
|
EVP_MD_CTX_reset(evp);
|
||||||
EVP_DigestInit_ex(evp, EVP_sha224(), NULL);
|
if (!EVP_DigestInit_ex(evp, EVP_sha224(), NULL))
|
||||||
for (i = 0; i < 1000000; i += 64)
|
goto err;
|
||||||
EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
for (i = 0; i < 1000000; i += 64) {
|
||||||
|
if (!EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
||||||
(1000000 - i) < 64 ? 1000000 - i : 64);
|
(1000000 - i) < 64 ? 1000000 - i : 64))
|
||||||
EVP_DigestFinal_ex(evp, md, NULL);
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestFinal_ex(evp, md, NULL))
|
||||||
|
goto err;
|
||||||
EVP_MD_CTX_free(evp);
|
EVP_MD_CTX_free(evp);
|
||||||
|
|
||||||
if (memcmp(md, addenum_3, sizeof(addenum_3))) {
|
if (memcmp(md, addenum_3, sizeof(addenum_3))) {
|
||||||
@ -158,4 +170,8 @@ int main(int argc, char **argv)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
fprintf(stderr, "Fatal EVP error!\n");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
fprintf(stdout, "Testing SHA-512 ");
|
fprintf(stdout, "Testing SHA-512 ");
|
||||||
|
|
||||||
EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL);
|
if (!EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_c1, sizeof(app_c1))) {
|
if (memcmp(md, app_c1, sizeof(app_c1))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
||||||
@ -92,10 +93,11 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
|
if (!EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
|
||||||
"efghijkl" "fghijklm" "ghijklmn" "hijklmno"
|
"efghijkl" "fghijklm" "ghijklmn" "hijklmno"
|
||||||
"ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
|
"ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
|
||||||
"mnopqrst" "nopqrstu", 112, md, NULL, EVP_sha512(), NULL);
|
"mnopqrst" "nopqrstu", 112, md, NULL, EVP_sha512(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_c2, sizeof(app_c2))) {
|
if (memcmp(md, app_c2, sizeof(app_c2))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
||||||
@ -110,9 +112,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
|
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
EVP_DigestInit_ex(evp, EVP_sha512(), NULL);
|
if (!EVP_DigestInit_ex(evp, EVP_sha512(), NULL))
|
||||||
for (i = 0; i < 1000000; i += 288)
|
goto err;
|
||||||
EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
for (i = 0; i < 1000000; i += 288) {
|
||||||
|
if (!EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
@ -121,8 +124,11 @@ int main(int argc, char **argv)
|
|||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
||||||
(1000000 - i) < 288 ? 1000000 - i : 288);
|
(1000000 - i) < 288 ? 1000000 - i : 288))
|
||||||
EVP_DigestFinal_ex(evp, md, NULL);
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestFinal_ex(evp, md, NULL))
|
||||||
|
goto err;
|
||||||
EVP_MD_CTX_reset(evp);
|
EVP_MD_CTX_reset(evp);
|
||||||
|
|
||||||
if (memcmp(md, app_c3, sizeof(app_c3))) {
|
if (memcmp(md, app_c3, sizeof(app_c3))) {
|
||||||
@ -138,7 +144,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
fprintf(stdout, "Testing SHA-384 ");
|
fprintf(stdout, "Testing SHA-384 ");
|
||||||
|
|
||||||
EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL);
|
if (!EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_d1, sizeof(app_d1))) {
|
if (memcmp(md, app_d1, sizeof(app_d1))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 1 of 3 failed.\n");
|
||||||
@ -147,10 +154,11 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
|
if (!EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
|
||||||
"efghijkl" "fghijklm" "ghijklmn" "hijklmno"
|
"efghijkl" "fghijklm" "ghijklmn" "hijklmno"
|
||||||
"ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
|
"ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
|
||||||
"mnopqrst" "nopqrstu", 112, md, NULL, EVP_sha384(), NULL);
|
"mnopqrst" "nopqrstu", 112, md, NULL, EVP_sha384(), NULL))
|
||||||
|
goto err;
|
||||||
if (memcmp(md, app_d2, sizeof(app_d2))) {
|
if (memcmp(md, app_d2, sizeof(app_d2))) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
fprintf(stderr, "\nTEST 2 of 3 failed.\n");
|
||||||
@ -159,12 +167,16 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
EVP_DigestInit_ex(evp, EVP_sha384(), NULL);
|
if (!EVP_DigestInit_ex(evp, EVP_sha384(), NULL))
|
||||||
for (i = 0; i < 1000000; i += 64)
|
goto err;
|
||||||
EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
for (i = 0; i < 1000000; i += 64) {
|
||||||
|
if (!EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
|
||||||
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
|
||||||
(1000000 - i) < 64 ? 1000000 - i : 64);
|
(1000000 - i) < 64 ? 1000000 - i : 64))
|
||||||
EVP_DigestFinal_ex(evp, md, NULL);
|
goto err;
|
||||||
|
}
|
||||||
|
if (!EVP_DigestFinal_ex(evp, md, NULL))
|
||||||
|
goto err;
|
||||||
EVP_MD_CTX_free(evp);
|
EVP_MD_CTX_free(evp);
|
||||||
|
|
||||||
if (memcmp(md, app_d3, sizeof(app_d3))) {
|
if (memcmp(md, app_d3, sizeof(app_d3))) {
|
||||||
@ -179,4 +191,9 @@ int main(int argc, char **argv)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
fflush(stdout);
|
||||||
|
fprintf(stderr, "\nFatal EVP error!\n");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user