1 @subheading asn1_write_value
2 @anchor{asn1_write_value}
3 @deftypefun {asn1_retCode} {asn1_write_value} (ASN1_TYPE @var{node_root}, const char * @var{name}, const void * @var{ivalue}, int @var{len})
4 @var{node_root}: pointer to a structure
6 @var{name}: the name of the element inside the structure that you want to set.
8 @var{ivalue}: vector used to specify the value to set. If len is >0,
9 VALUE must be a two's complement form integer. if len=0 *VALUE
10 must be a null terminated string with an integer value.
12 @var{len}: number of bytes of *value to use to set the value:
13 value[0]..value[len-1] or 0 if value is a null terminated string
15 Set the value of one element inside a structure.
17 If an element is OPTIONAL and you want to delete it, you must use
18 the value=NULL and len=0. Using "pkix.asn":
20 result=asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
23 @strong{Description for each type:}
24 @strong{INTEGER:} VALUE must contain a two's complement form integer.
26 value[0]=0xFF , len=1 -> integer=-1.
27 value[0]=0xFF value[1]=0xFF , len=2 -> integer=-1.
28 value[0]=0x01 , len=1 -> integer= 1.
29 value[0]=0x00 value[1]=0x01 , len=2 -> integer= 1.
30 value="123" , len=0 -> integer= 123.
32 @strong{ENUMERATED:} As INTEGER (but only with not negative numbers).
34 @strong{BOOLEAN:} VALUE must be the null terminated string "TRUE" or
37 value="TRUE" , len=1 -> boolean=TRUE.
38 value="FALSE" , len=1 -> boolean=FALSE.
40 @strong{OBJECT IDENTIFIER:} VALUE must be a null terminated string with
41 each number separated by a dot (e.g. "1.2.3.543.1"). LEN != 0.
43 value="1 2 840 10040 4 3" , len=1 -> OID=dsa-with-sha.
45 @strong{UTCTime:} VALUE must be a null terminated string in one of these
46 formats: "YYMMDDhhmmssZ", "YYMMDDhhmmssZ",
47 "YYMMDDhhmmss+hh'mm'", "YYMMDDhhmmss-hh'mm'",
48 "YYMMDDhhmm+hh'mm'", or "YYMMDDhhmm-hh'mm'". LEN != 0.
50 value="9801011200Z" , len=1 -> time=Jannuary 1st, 1998
51 at 12h 00m Greenwich Mean Time
53 @strong{GeneralizedTime:} VALUE must be in one of this format:
54 "YYYYMMDDhhmmss.sZ", "YYYYMMDDhhmmss.sZ",
55 "YYYYMMDDhhmmss.s+hh'mm'", "YYYYMMDDhhmmss.s-hh'mm'",
56 "YYYYMMDDhhmm+hh'mm'", or "YYYYMMDDhhmm-hh'mm'" where ss.s
57 indicates the seconds with any precision like "10.1" or "01.02".
60 value="2001010112001.12-0700" , len=1 -> time=Jannuary
61 1st, 2001 at 12h 00m 01.12s Pacific Daylight Time
63 @strong{OCTET STRING:} VALUE contains the octet string and LEN is the
66 value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
67 len=3 -> three bytes octet string
69 @strong{GeneralString:} VALUE contains the generalstring and LEN is the
72 value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
73 len=3 -> three bytes generalstring
75 @strong{BIT STRING:} VALUE contains the bit string organized by bytes and
76 LEN is the number of bits.
78 value="$\backslash$xCF" , len=6 -> bit string="110011" (six
81 @strong{CHOICE:} if NAME indicates a choice type, VALUE must specify one of
82 the alternatives with a null terminated string. LEN != 0. Using
85 result=asn1_write_value(cert,
86 "certificate1.tbsCertificate.subject", "rdnSequence",
89 @strong{ANY:} VALUE indicates the der encoding of a structure. LEN != 0.
91 @strong{SEQUENCE OF:} VALUE must be the null terminated string "NEW" and
92 LEN != 0. With this instruction another element is appended in
93 the sequence. The name of this element will be "?1" if it's the
94 first one, "?2" for the second and so on.
98 result=asn1_write_value(cert,
99 "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
101 @strong{SET OF:} the same as SEQUENCE OF. Using "pkix.asn":
103 result=asn1_write_value(cert,
104 "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
106 @strong{Returns:} @end deftypefun