Use EVP_MD_CTX_create()/EVP_MD_CTX_destroy().
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23136 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -274,7 +274,7 @@ static int
|
|||||||
hash_test (struct hash_foo *hash, struct test *tests)
|
hash_test (struct hash_foo *hash, struct test *tests)
|
||||||
{
|
{
|
||||||
struct test *t;
|
struct test *t;
|
||||||
EVP_MD_CTX ectx;
|
EVP_MD_CTX *ectx;
|
||||||
unsigned int esize;
|
unsigned int esize;
|
||||||
void *ctx = malloc(hash->psize);
|
void *ctx = malloc(hash->psize);
|
||||||
unsigned char *res = malloc(hash->hsize);
|
unsigned char *res = malloc(hash->hsize);
|
||||||
@@ -283,8 +283,8 @@ hash_test (struct hash_foo *hash, struct test *tests)
|
|||||||
for (t = tests; t->str; ++t) {
|
for (t = tests; t->str; ++t) {
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
|
|
||||||
EVP_MD_CTX_init(&ectx);
|
ectx = EVP_MD_CTX_create();
|
||||||
EVP_DigestInit_ex(&ectx, hash->evp(), NULL);
|
EVP_DigestInit_ex(ectx, hash->evp(), NULL);
|
||||||
|
|
||||||
(*hash->init)(ctx);
|
(*hash->init)(ctx);
|
||||||
if(strcmp(t->str, ONE_MILLION_A) == 0) {
|
if(strcmp(t->str, ONE_MILLION_A) == 0) {
|
||||||
@@ -292,11 +292,11 @@ hash_test (struct hash_foo *hash, struct test *tests)
|
|||||||
memset(buf, 'a', sizeof(buf));
|
memset(buf, 'a', sizeof(buf));
|
||||||
for(i = 0; i < 1000; i++) {
|
for(i = 0; i < 1000; i++) {
|
||||||
(*hash->update)(ctx, buf, sizeof(buf));
|
(*hash->update)(ctx, buf, sizeof(buf));
|
||||||
EVP_DigestUpdate(&ectx, buf, sizeof(buf));
|
EVP_DigestUpdate(ectx, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(*hash->update)(ctx, (unsigned char *)t->str, strlen(t->str));
|
(*hash->update)(ctx, (unsigned char *)t->str, strlen(t->str));
|
||||||
EVP_DigestUpdate(&ectx, t->str, strlen(t->str));
|
EVP_DigestUpdate(ectx, t->str, strlen(t->str));
|
||||||
}
|
}
|
||||||
|
|
||||||
(*hash->final) (res, ctx);
|
(*hash->final) (res, ctx);
|
||||||
@@ -320,8 +320,8 @@ hash_test (struct hash_foo *hash, struct test *tests)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVP_DigestFinal_ex(&ectx, res, &esize);
|
EVP_DigestFinal_ex(ectx, res, &esize);
|
||||||
EVP_MD_CTX_cleanup(&ectx);
|
EVP_MD_CTX_destroy(ectx);
|
||||||
|
|
||||||
if (hash->hsize != esize) {
|
if (hash->hsize != esize) {
|
||||||
printf("EVP %s returned wrong hash size\n", hash->name);
|
printf("EVP %s returned wrong hash size\n", hash->name);
|
||||||
|
Reference in New Issue
Block a user