1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
.\" $OpenBSD: d2i_ASN1_NULL.3,v 1.5 2023/09/26 09:36:22 tb Exp $
.\"
.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: September 26 2023 $
.Dt D2I_ASN1_NULL 3
.Os
.Sh NAME
.Nm d2i_ASN1_NULL ,
.Nm i2d_ASN1_NULL
.Nd decode and encode an ASN.1 NULL type
.Sh SYNOPSIS
.In openssl/asn1.h
.Ft ASN1_NULL *
.Fo d2i_ASN1_NULL
.Fa "ASN1_NULL **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_NULL
.Fa "ASN1_NULL *val_in"
.Fa "unsigned char **der_out"
.Fc
.Sh DESCRIPTION
These functions decode and encode the ASN.1 value NULL of type NULL.
For details about the semantics, examples, caveats, and bugs, see
.Xr ASN1_item_d2i 3 .
.Pp
.Fn d2i_ASN1_NULL
verifies that the BER-encoded value at
.Pf * Fa der_in
is NULL and of type NULL.
It fails if
.Fa length
is less than 2 or if the first two bytes of
.Pf * Fa der_in
differ from 0x05 and 0x00.
In case of success,
.Pf * Fa der_in
is advanced by two bytes and
.Pf * Fa val_out
is set to a specific invalid pointer representing the unique
.Vt ASN1_NULL
object.
.Pp
.Fn i2d_ASN1_NULL
ignores
.Fa val_in
and encodes the ASN.1 value NULL of type NULL using DER.
Specifically, it writes the identifier octet for the type NULL,
0x05, followed by the length octet 0x00, and no content or
end-of-content octets.
.Sh RETURN VALUES
.Fn d2i_ASN1_NULL
returns a specific invalid pointer representing the unique
.Vt ASN1_NULL
object or
.Dv NULL
if an error occurs.
.Pp
.Fn i2d_ASN1_NULL
returns 2 if successful or 0 if an error occurs.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr ASN1_item_new 3 ,
.Xr ASN1_NULL_new 3 ,
.Xr ASN1_TYPE_get 3
.Sh STANDARDS
ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
Information technology - ASN.1 encoding rules:
Specification of Basic Encoding Rules (BER), Canonical Encoding
Rules (CER) and Distinguished Encoding Rules (DER),
section 8.8: Encoding of a null value
.Sh HISTORY
.Fn d2i_ASN1_NULL
and
.Fn i2d_ASN1_NULL
first appeared in OpenSSL 0.9.5 and have been available since
.Ox 2.7 .
|