1.\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.2 2021/10/21 16:26:34 schwarze 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: October 21 2021 $ 18.Dt X509_ATTRIBUTE_GET0_OBJECT 3 19.Os 20.Sh NAME 21.Nm X509_ATTRIBUTE_get0_object , 22.Nm X509_ATTRIBUTE_count , 23.Nm X509_ATTRIBUTE_get0_type , 24.Nm X509_ATTRIBUTE_get0_data 25.\" In the following line, "X.501" and "Attribute" are not typos. 26.\" The "Attribute" type is defined in X.501, not in X.509. 27.\" The type is called "Attribute" with capital "A", not "attribute". 28.Nd X.501 Attribute read accessors 29.Sh SYNOPSIS 30.In openssl/x509.h 31.Ft ASN1_OBJECT * 32.Fo X509_ATTRIBUTE_get0_object 33.Fa "X509_ATTRIBUTE *attr" 34.Fc 35.Ft int 36.Fo X509_ATTRIBUTE_count 37.Fa "const X509_ATTRIBUTE *attr" 38.Fc 39.Ft ASN1_TYPE * 40.Fo X509_ATTRIBUTE_get0_type 41.Fa "X509_ATTRIBUTE *attr" 42.Fa "int index" 43.Fc 44.Ft void * 45.Fo X509_ATTRIBUTE_get0_data 46.Fa "X509_ATTRIBUTE *attr" 47.Fa "int index" 48.Fa "int type" 49.Fa "void *data" 50.Fc 51.Sh DESCRIPTION 52These functions provide read access to the X.501 Attribute object 53.Fa attr . 54.Pp 55For 56.Fn X509_ATTRIBUTE_get0_data , 57the 58.Fa type 59argument usually is one of the 60.Dv V_ASN1_* 61constants defined in 62.In openssl/asn1.h . 63For example, if a return value of the type 64.Vt ASN1_OCTET_STRING 65is expected, pass 66.Dv V_ASN1_OCTET_STRING 67as the 68.Fa type 69argument. 70The 71.Fa data 72argument is ignored; passing 73.Dv NULL 74is recommended. 75.Sh RETURN VALUES 76.Fn X509_ATTRIBUTE_get0_object 77returns an internal pointer to the type of 78.Fa attr 79or 80.Dv NULL 81if 82.Fa attr 83is 84.Dv NULL 85or if its type is not set. 86.Pp 87.Fn X509_ATTRIBUTE_count 88returns the number of values stored in 89.Fa attr 90or 0 if no value or values are set. 91.Pp 92.Fn X509_ATTRIBUTE_get0_type 93returns an internal pointer to the ASN.1 ANY object 94representing the value with the given zero-based 95.Fa index 96or 97.Dv NULL 98if 99.Fa attr 100is 101.Dv NULL , 102if the 103.Fa index 104is larger than or equal to the number of values stored in 105.Fa attr , 106or if no value or values are set. 107.Pp 108.Fn X509_ATTRIBUTE_get0_data 109returns an internal pointer to the data 110contained in the value with the given zero-based 111.Fa index 112or 113.Dv NULL 114if 115.Fa attr 116is 117.Dv NULL , 118if the 119.Fa index 120is larger than or equal to the number of values stored in 121.Fa attr , 122if no value or values are set, 123or if the ASN.1 ANY object representing the value with the given 124.Fa index 125is not of the requested 126.Fa type . 127.Sh SEE ALSO 128.Xr ASN1_OBJECT_new 3 , 129.Xr ASN1_TYPE_new 3 , 130.Xr OPENSSL_sk_new 3 , 131.Xr X509_ATTRIBUTE_new 3 , 132.Xr X509_ATTRIBUTE_set1_object 3 133.Sh HISTORY 134These functions first appeared in OpenSSL 0.9.5 135and have been available since 136.Ox 2.7 . 137