1asn1_write_value(3)                libtasn1                asn1_write_value(3)
2
3
4

NAME

6       asn1_write_value - API function
7

SYNOPSIS

9       #include <libtasn1.h>
10
11       int asn1_write_value(asn1_node node_root, const char * name, const void
12       * ivalue, int len);
13

ARGUMENTS

15       asn1_node node_root
16                   pointer to a structure
17
18       const char * name
19                   the name of the element inside the structure that you  want
20                   to set.
21
22       const void * ivalue
23                   vector  used  to  specify  the  value to set. If len is >0,
24                   VALUE must be a two's complement form  integer.   if  len=0
25                   *VALUE  must  be  a  null terminated string with an integer
26                   value.
27
28       int len     number of  bytes  of  *value  to  use  to  set  the  value:
29                   value[0]..value[len-1]  or  0 if value is a null terminated
30                   string
31

DESCRIPTION

33       Set the value of one element inside a structure.
34
35       If an element is OPTIONAL and you want to delete it, you must  use  the
36       value=NULL and len=0.  Using "pkix.asn":
37
38       result=asn1_write_value(cert,   "tbsCertificate.issuerUniqueID",  NULL,
39       0);
40
41       Description for each type:
42

INTEGER

44       VALUE must contain a two's complement form integer.
45
46       value[0]=0xFF  ,                len=1  ->  integer=-1.    value[0]=0xFF
47       value[1]=0xFF    ,    len=2    ->    integer=-1.     value[0]=0x01    ,
48       len=1 -> integer= 1.  value[0]=0x00 value[1]=0x01 , len=2  ->  integer=
49       1.  value="123"                 , len=0 -> integer= 123.
50

ENUMERATED

52       As INTEGER (but only with not negative numbers).
53

BOOLEAN

55       VALUE  must  be the null terminated string "TRUE" or "FALSE" and LEN !=
56       0.
57
58       value="TRUE" , len=1 -> boolean=TRUE.  value="FALSE" , len=1  ->  bool‐
59       ean=FALSE.
60
61       OBJECT  IDENTIFIER:  VALUE  must  be a null terminated string with each
62       number separated by a dot (e.g. "1.2.3.543.1").  LEN != 0.
63
64       value="1 2 840 10040 4 3" , len=1 -> OID=dsa-with-sha.
65

UTCTIME

67       VALUE must be a null terminated string in one of these formats: "YYMMD‐
68       DhhmmssZ",     "YYMMDDhhmmssZ",    "YYMMDDhhmmss+hh'mm'",    "YYMMDDhh‐
69       mmss-hh'mm'", "YYMMDDhhmm+hh'mm'", or "YYMMDDhhmm-hh'mm'".  LEN != 0.
70
71       value="9801011200Z" , len=1 ->  time=Jannuary  1st,  1998  at  12h  00m
72       Greenwich Mean Time
73

GENERALIZEDTIME

75       VALUE  must be in one of this format: "YYYYMMDDhhmmss.sZ", "YYYYMMDDhh‐
76       mmss.sZ", "YYYYMMDDhhmmss.s+hh'mm'", "YYYYMMDDhhmmss.s-hh'mm'", "YYYYM‐
77       MDDhhmm+hh'mm'", or "YYYYMMDDhhmm-hh'mm'" where ss.s indicates the sec‐
78       onds with any precision like "10.1" or "01.02".  LEN != 0
79
80       value="2001010112001.12-0700" , len=1 -> time=Jannuary 1st, 2001 at 12h
81       00m 01.12s Pacific Daylight Time
82
83       OCTET  STRING: VALUE contains the octet string and LEN is the number of
84       octets. c       c       c
85               k       k       k
86       value="$ssh$x01$ssh$x02$ssh$x03" , len=3 -> three bytes octet string
87               l       l       l

GENERALSTRING

89       VALUE conctains thce generaclstring and LEN is the number of octets.
90               k       k       k
91       value="$ssh$x01$ssh$x02$ssh$x03" , len=3 -> three bytes generalstring
92               l       l       l
93       BIT STRING: VALUE contains the bit string organized by bytes and LEN is
94       the numbecr of bits.
95               k
96       value="$ssh$xCF" , len=6 -> bit string="110011" (six bits)
97               l

CHOICE

99       if NAME indicates a choice type, VALUE must specify one of the alterna‐
100       tives with a null terminated string. LEN != 0. Using "pkix.asn"
101
102       result=asn1_write_value(cert,    "certificate1.tbsCertificate.subject",
103       "rdnSequence", 1);
104

ANY

106       VALUE indicates the der encoding of a structure.  LEN != 0.
107
108       SEQUENCE  OF: VALUE must be the null terminated string "NEW" and LEN !=
109       0. With this instruction another element is appended in  the  sequence.
110       The  name  of this element will be "?1" if it's the first one, "?2" for
111       the second and so on.
112
113       Using "pkix.asn"
114
115       result=asn1_write_value(cert,         "certificate1.tbsCertificate.sub‐
116       ject.rdnSequence", "NEW", 1);
117
118       SET OF: the same as SEQUENCE OF.  Using "pkix.asn":
119
120       result=asn1_write_value(cert,            "tbsCertificate.subject.rdnSe‐
121       quence.?LAST", "NEW", 1);
122

RETURNS

124       ASN1_SUCCESS if the value was set, ASN1_ELEMENT_NOT_FOUND if   name  is
125       not  a  valid  element, and ASN1_VALUE_NOT_VALID if  ivalue has a wrong
126       format.
127
129       Copyright © 2006-2022 Free Software Foundation, Inc..
130       Copying and distribution of this file, with  or  without  modification,
131       are  permitted in any medium without royalty provided the copyright no‐
132       tice and this notice are preserved.
133

SEE ALSO

135       The full documentation for libtasn1 is maintained as a Texinfo  manual.
136       If  the info and libtasn1 programs are properly installed at your site,
137       the command
138
139              info libtasn1
140
141       should give you access to the complete manual.  As an  alternative  you
142       may obtain the manual from:
143
144              https://www.gnu.org/software/libtasn1/manual/
145
146libtasn1                            4.19.0                 asn1_write_value(3)
Impressum