| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "ASN1_TYPE_GET 3SSL" |
| 58 |
.TH ASN1_TYPE_GET 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp, ASN1_TYPE_unpack_sequence, ASN1_TYPE_pack_sequence \- ASN1_TYPE utility |
| 65 |
functions |
| 66 |
.SH SYNOPSIS |
| 67 |
.IX Header "SYNOPSIS" |
| 68 |
.Vb 1 |
| 69 |
\& #include <openssl/asn1.h> |
| 70 |
\& |
| 71 |
\& int ASN1_TYPE_get(const ASN1_TYPE *a); |
| 72 |
\& void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); |
| 73 |
\& int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); |
| 74 |
\& int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); |
| 75 |
\& |
| 76 |
\& void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); |
| 77 |
\& ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, |
| 78 |
\& ASN1_TYPE **t); |
| 79 |
.Ve |
| 80 |
.SH DESCRIPTION |
| 81 |
.IX Header "DESCRIPTION" |
| 82 |
These functions allow an \fBASN1_TYPE\fR structure to be manipulated. The |
| 83 |
\&\fBASN1_TYPE\fR structure can contain any ASN.1 type or constructed type |
| 84 |
such as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type. |
| 85 |
.PP |
| 86 |
\&\fBASN1_TYPE_get()\fR returns the type of \fIa\fR or 0 if it fails. |
| 87 |
.PP |
| 88 |
\&\fBASN1_TYPE_set()\fR sets the value of \fIa\fR to \fItype\fR and \fIvalue\fR. This |
| 89 |
function uses the pointer \fIvalue\fR internally so it must \fBnot\fR be freed |
| 90 |
up after the call. |
| 91 |
.PP |
| 92 |
\&\fBASN1_TYPE_set1()\fR sets the value of \fIa\fR to \fItype\fR a copy of \fIvalue\fR. |
| 93 |
.PP |
| 94 |
\&\fBASN1_TYPE_cmp()\fR compares ASN.1 types \fIa\fR and \fIb\fR and returns 0 if |
| 95 |
they are identical and nonzero otherwise. |
| 96 |
.PP |
| 97 |
\&\fBASN1_TYPE_unpack_sequence()\fR attempts to parse the SEQUENCE present in |
| 98 |
\&\fIt\fR using the ASN.1 structure \fIit\fR. If successful it returns a pointer |
| 99 |
to the ASN.1 structure corresponding to \fIit\fR which must be freed by the |
| 100 |
caller. If it fails it return NULL. |
| 101 |
.PP |
| 102 |
\&\fBASN1_TYPE_pack_sequence()\fR attempts to encode the ASN.1 structure \fIs\fR |
| 103 |
corresponding to \fIit\fR into an \fBASN1_TYPE\fR. If successful the encoded |
| 104 |
\&\fBASN1_TYPE\fR is returned. If \fIt\fR and \fI*t\fR are not NULL the encoded type |
| 105 |
is written to \fIt\fR overwriting any existing data. If \fIt\fR is not NULL |
| 106 |
but \fI*t\fR is NULL the returned \fBASN1_TYPE\fR is written to \fI*t\fR. |
| 107 |
.SH NOTES |
| 108 |
.IX Header "NOTES" |
| 109 |
The type and meaning of the \fIvalue\fR parameter for \fBASN1_TYPE_set()\fR and |
| 110 |
\&\fBASN1_TYPE_set1()\fR is determined by the \fItype\fR parameter. |
| 111 |
If \fItype\fR is \fBV_ASN1_NULL\fR \fIvalue\fR is ignored. If \fItype\fR is |
| 112 |
\&\fBV_ASN1_BOOLEAN\fR |
| 113 |
then the boolean is set to TRUE if \fIvalue\fR is not NULL. If \fItype\fR is |
| 114 |
\&\fBV_ASN1_OBJECT\fR then value is an \fBASN1_OBJECT\fR structure. Otherwise \fItype\fR |
| 115 |
is and \fBASN1_STRING\fR structure. If \fItype\fR corresponds to a primitive type |
| 116 |
(or a string type) then the contents of the \fBASN1_STRING\fR contain the content |
| 117 |
octets of the type. If \fItype\fR corresponds to a constructed type or |
| 118 |
a tagged type (\fBV_ASN1_SEQUENCE\fR, \fBV_ASN1_SET\fR or \fBV_ASN1_OTHER\fR) then the |
| 119 |
\&\fBASN1_STRING\fR contains the entire ASN.1 encoding verbatim (including tag and |
| 120 |
length octets). |
| 121 |
.PP |
| 122 |
\&\fBASN1_TYPE_cmp()\fR may not return zero if two types are equivalent but have |
| 123 |
different encodings. For example the single content octet of the boolean TRUE |
| 124 |
value under BER can have any nonzero encoding but \fBASN1_TYPE_cmp()\fR will |
| 125 |
only return zero if the values are the same. |
| 126 |
.PP |
| 127 |
If either or both of the parameters passed to \fBASN1_TYPE_cmp()\fR is NULL the |
| 128 |
return value is nonzero. Technically if both parameters are NULL the two |
| 129 |
types could be absent OPTIONAL fields and so should match, however, passing |
| 130 |
NULL values could also indicate a programming error (for example an |
| 131 |
unparsable type which returns NULL) for types which do \fBnot\fR match. So |
| 132 |
applications should handle the case of two absent values separately. |
| 133 |
.SH "RETURN VALUES" |
| 134 |
.IX Header "RETURN VALUES" |
| 135 |
\&\fBASN1_TYPE_get()\fR returns the type of the \fBASN1_TYPE\fR argument. |
| 136 |
.PP |
| 137 |
\&\fBASN1_TYPE_set()\fR does not return a value. |
| 138 |
.PP |
| 139 |
\&\fBASN1_TYPE_set1()\fR returns 1 for success and 0 for failure. |
| 140 |
.PP |
| 141 |
\&\fBASN1_TYPE_cmp()\fR returns 0 if the types are identical and nonzero otherwise. |
| 142 |
.PP |
| 143 |
\&\fBASN1_TYPE_unpack_sequence()\fR returns a pointer to an ASN.1 structure or |
| 144 |
NULL on failure. |
| 145 |
.PP |
| 146 |
\&\fBASN1_TYPE_pack_sequence()\fR return an \fBASN1_TYPE\fR structure if it succeeds or |
| 147 |
NULL on failure. |
| 148 |
.SH COPYRIGHT |
| 149 |
.IX Header "COPYRIGHT" |
| 150 |
Copyright 2015\-2020 The OpenSSL Project Authors. All Rights Reserved. |
| 151 |
.PP |
| 152 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 153 |
this file except in compliance with the License. You can obtain a copy |
| 154 |
in the file LICENSE in the source distribution or at |
| 155 |
<https://www.openssl.org/source/license.html>. |