Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/x509/a_digest.c

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #include <openssl/x509.h>
5
6 #include <openssl/asn1.h>
7 #include <openssl/digest.h>
8 #include <openssl/err.h>
9 #include <openssl/mem.h>
10
11 int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
12 unsigned char *md, unsigned int *len) {
13 int i, ret;
14 unsigned char *str, *p;
15
16 i = i2d(data, NULL);
17 if ((str = (unsigned char *)OPENSSL_malloc(i)) == NULL) {
18 return 0;
19 }
20 p = str;
21 i2d(data, &p);
22
23 ret = EVP_Digest(str, i, md, len, type, NULL);
24 OPENSSL_free(str);
25 return ret;
26 }
27
28 int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
29 unsigned char *md, unsigned int *len) {
30 int i, ret;
31 unsigned char *str = NULL;
32
33 i = ASN1_item_i2d(asn, &str, it);
34 if (!str) {
35 return 0;
36 }
37
38 ret = EVP_Digest(str, i, md, len, type, NULL);
39 OPENSSL_free(str);
40 return ret;
41 }