]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/asn1/a_digest.c
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
12 #include <sys/types.h>
14 #include "internal/cryptlib.h"
16 #include <openssl/err.h>
17 #include <openssl/evp.h>
18 #include <openssl/buffer.h>
19 #include <openssl/x509.h>
23 int ASN1_digest(i2d_of_void
*i2d
, const EVP_MD
*type
, char *data
,
24 unsigned char *md
, unsigned int *len
)
27 unsigned char *str
, *p
;
30 if ((str
= OPENSSL_malloc(i
)) == NULL
) {
31 ASN1err(ASN1_F_ASN1_DIGEST
, ERR_R_MALLOC_FAILURE
);
37 if (!EVP_Digest(str
, i
, md
, len
, type
, NULL
)) {
47 int ASN1_item_digest(const ASN1_ITEM
*it
, const EVP_MD
*type
, void *asn
,
48 unsigned char *md
, unsigned int *len
)
51 unsigned char *str
= NULL
;
53 i
= ASN1_item_i2d(asn
, &str
, it
);
57 if (!EVP_Digest(str
, i
, md
, len
, type
, NULL
)) {