ASN1_ITEM versions of sign, verify, pack and unpack.
[openssl.git] / crypto / asn1 / a_digest.c
index 8257b86..fb4686f 100644 (file)
@@ -88,3 +88,21 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
        return(1);
        }
 
+
+int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
+               unsigned char *md, unsigned int *len)
+       {
+       EVP_MD_CTX ctx;
+       int i;
+       unsigned char *str = NULL;
+
+       i=ASN1_item_i2d(asn,&str, it);
+       if (!str) return(0);
+
+       EVP_DigestInit(&ctx,type);
+       EVP_DigestUpdate(&ctx,str,i);
+       EVP_DigestFinal(&ctx,md,len);
+       OPENSSL_free(str);
+       return(1);
+       }
+