X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fasn1%2Fa_digest.c;h=d00d9e22b188708dbad146c02c1955ee5842279d;hp=692d4d9f1d6cbca073dc87c07fcf153d36a723f3;hb=d326582cabe290fff22678af0270667b2b2761d9;hpb=f66c3032015e13071069be276edb50dc79d5f2a4 diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 692d4d9f1d..d00d9e22b1 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -58,29 +58,54 @@ #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + +#include #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(i2d_of_void *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) + { + ASN1err(ASN1_F_ASN1_DIGEST,ERR_R_MALLOC_FAILURE); + 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); }