1.\" $OpenBSD: ASN1_item_digest.3,v 1.2 2022/09/11 04:39:46 jsg Exp $ 2.\" 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: September 11 2022 $ 18.Dt ASN1_ITEM_DIGEST 3 19.Os 20.Sh NAME 21.Nm ASN1_item_digest 22.Nd DER-encode and hash an ASN.1 value 23.Sh SYNOPSIS 24.In openssl/x509.h 25.Ft int 26.Fo ASN1_item_digest 27.Fa "const ASN1_ITEM *it" 28.Fa "const EVP_MD *type" 29.Fa "void *val_in" 30.Fa "unsigned char *md" 31.Fa "unsigned int *s" 32.Fc 33.Sh DESCRIPTION 34.Fn ASN1_item_digest 35assumes that 36.Fa val_in 37is an 38.Vt ASN1_VALUE 39of the type specified by 40.Fa it , 41encodes it into DER format by calling 42.Xr ASN1_item_i2d 3 , 43hashes the resulting byte array using the digest 44.Fa type 45by calling 46.Xr EVP_Digest 3 , 47places the digest value into 48.Pf * Fa md , 49and, unless 50.Fa s 51is 52.Dv NULL , 53places the length in bytes of the digest into 54.Pf * Fa s . 55Providing a buffer 56.Pf * Fa md 57large enough to contain the digest is the responsibility of the caller; 58providing a buffer of 59.Dv EVP_MAX_MD_SIZE 60bytes is recommended. 61.Sh RETURN VALUES 62.Fn ASN1_item_digest 63returns 1 for success or 0 if encoding or hashing fails. 64.Sh SEE ALSO 65.Xr ASN1_item_i2d 3 , 66.Xr ASN1_item_sign 3 , 67.Xr EVP_Digest 3 68.Sh HISTORY 69.Fn ASN1_item_digest 70first appeared in OpenSSL 0.9.7 and has been available since 71.Ox 3.1 . 72