2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 #include "internal/cryptlib.h"
15 #ifndef NO_SYS_TYPES_H
16 # include <sys/types.h>
19 #include <openssl/err.h>
20 #include <openssl/evp.h>
21 #include <openssl/buffer.h>
22 #include <openssl/x509.h>
26 int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
27 unsigned char *md, unsigned int *len)
30 unsigned char *str, *p;
33 if ((str = OPENSSL_malloc(i)) == NULL) {
34 ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE);
40 if (!EVP_Digest(str, i, md, len, type, NULL))
48 int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
49 unsigned char *md, unsigned int *len)
52 unsigned char *str = NULL;
54 i = ASN1_item_i2d(asn, &str, it);
58 if (!EVP_Digest(str, i, md, len, type, NULL))