X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fasn1%2Fa_digest.c;h=4931e222a05e30c0f47e530f18b05bbe29657049;hb=d5492d9b47d4d55052f24c8a04c70a0516ac934d;hp=692d4d9f1d6cbca073dc87c07fcf153d36a723f3;hpb=f66c3032015e13071069be276edb50dc79d5f2a4;p=openssl.git diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 692d4d9f1d..4931e222a0 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -58,29 +58,49 @@ #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + #include #include +#include + +#ifndef NO_ASN1_OLD -int ASN1_digest(int (*i2d)(), EVP_MD *type, char *data, unsigned char *md, - unsigned int *len) +int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data, + unsigned char *md, unsigned int *len) { - EVP_MD_CTX ctx; int i; unsigned char *str,*p; i=i2d(data,NULL); - if ((str=(unsigned char *)Malloc(i)) == NULL) return(0); + if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL) return(0); p=str; i2d(data,&p); - EVP_DigestInit(&ctx,type); - EVP_DigestUpdate(&ctx,str,i); - EVP_DigestFinal(&ctx,md,len); - Free(str); + EVP_Digest(str, i, md, len, type, NULL); + OPENSSL_free(str); + return(1); + } + +#endif + + +int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, + unsigned char *md, unsigned int *len) + { + int i; + unsigned char *str = NULL; + + i=ASN1_item_i2d(asn,&str, it); + if (!str) return(0); + + EVP_Digest(str, i, md, len, type, NULL); + OPENSSL_free(str); return(1); }