1.\" $OpenBSD: PKCS7_set_type.3,v 1.2 2020/05/20 11:40:26 schwarze Exp $ 2.\" 3.\" Copyright (c) 2020 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: May 20 2020 $ 18.Dt PKCS7_SET_TYPE 3 19.Os 20.Sh NAME 21.Nm PKCS7_set_type , 22.Nm PKCS7_set0_type_other 23.Nd initialize type of PKCS#7 ContentInfo 24.Sh SYNOPSIS 25.In openssl/pkcs7.h 26.Ft int 27.Fo PKCS7_set_type 28.Fa "PKCS7 *p7" 29.Fa "int type" 30.Fc 31.Ft int 32.Fo PKCS7_set0_type_other 33.Fa "PKCS7 *p7" 34.Fa "int type" 35.Fa "ASN1_TYPE *content" 36.Fc 37.Sh DESCRIPTION 38These functions set the 39.Fa type 40of an unused 41.Vt ContentInfo 42structure 43.Fa p7 . 44.Pp 45The function 46.Fn PKCS7_set_type 47also allocates and initializes an empty child object in 48.Fa p7 . 49The 50.Fa type 51argument can be any of these NIDs, 52creating a child object of the indicated data type: 53.Pp 54.Bl -column NID_pkcs7_signedAndEnveloped PKCS7_SIGN_ENVELOPE n.a. -compact 55.It Fa type No argument Ta data type of child Ta version 56.It Dv NID_pkcs7_data Ta Vt ASN1_OCTET_STRING Ta n.a. 57.It Dv NID_pkcs7_digest Ta Vt PKCS7_DIGEST Ta 0 58.It Dv NID_pkcs7_encrypted Ta Vt PKCS7_ENCRYPT Ta 0 59.It Dv NID_pkcs7_enveloped Ta Vt PKCS7_ENVELOPE Ta 0 60.It Dv NID_pkcs7_signed Ta Vt PKCS7_SIGNED Ta 1 61.It Dv NID_pkcs7_signedAndEnveloped Ta Vt PKCS7_SIGN_ENVELOPE Ta 1 62.El 63.Pp 64If the provided 65.Fa type 66is invalid, 67.Fa p7 68remains unchanged and 69.Fn PKCS7_set_type 70fails. 71.Pp 72If memory allocation fails, 73.Fn PKCS7_set_type 74fails and 75.Fa p7 76may remain in an inconsistent state. 77.Pp 78The function 79.Fn PKCS7_set0_type_other 80accepts an arbitrary NID as the 81.Fa type 82and also sets the 83.Fa content , 84neither checking it in any way nor copying it. 85.Pp 86For both functions, the rest of the internal state of 87.Fa p7 88remains unchanged. 89.Sh RETURN VALUES 90The function 91.Fn PKCS7_set_type 92returns 1 on success or 0 on failure. 93.Pp 94The function 95.Fn PKCS7_set0_type_other 96does no error handling at all and always returns 1. 97.Sh SEE ALSO 98.Xr ASN1_OCTET_STRING_new 3 , 99.Xr ASN1_TYPE_new 3 , 100.Xr PKCS7_encrypt 3 , 101.Xr PKCS7_new 3 , 102.Xr PKCS7_set_content 3 , 103.Xr PKCS7_sign 3 104.Sh HISTORY 105The function 106.Fn PKCS7_set_type 107first appeared in SSLeay 0.8.1 and 108.Fn PKCS7_set0_type_other 109in OpenSSL 0.9.8. 110Both have been available since 111.Ox 2.4 . 112.Sh CAVEATS 113If 114.Fa p7 115has already been in use before being passed to one of these functions, 116it will report success even though it leaks memory. 117Later on, if other functions try to use 118.Fa p7 119in its former role, they are likely to misbehave. 120