X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fasn1%2Fa_digest.c;h=d00d9e22b188708dbad146c02c1955ee5842279d;hp=20cde71f03b0ebdff565e75346def05e08c8cc9a;hb=d326582cabe290fff22678af0270667b2b2761d9;hpb=6b691a5c85ddc4e407e32781841fee5c029506cd diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 20cde71f03..d00d9e22b1 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -58,30 +58,54 @@ #include #include -#include -#include #include "cryptlib.h" -#include "evp.h" -#include "x509.h" -#include "buffer.h" -int ASN1_digest(int (*i2d)(), EVP_MD *type, char *data, unsigned char *md, - unsigned int *len) +#ifndef NO_SYS_TYPES_H +# include +#endif + +#include +#include +#include +#include + +#ifndef NO_ASN1_OLD + +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); }