Fix grammar in certificates.txt
[openssl.git] / include / internal / der.h
1 /*
2  * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <openssl/bn.h>
11 #include "internal/packet.h"
12
13 /*
14  * NOTE: X.690 numbers the identifier octet bits 1 to 8.
15  * We use the same numbering in comments here.
16  */
17
18 /* Well known primitive tags */
19
20 /*
21  * DER UNIVERSAL tags, occupying bits 1-5 in the DER identifier byte
22  * These are only valid for the UNIVERSAL class.  With the other classes,
23  * these bits have a different meaning.
24  */
25 #define DER_P_EOC                       0 /* BER End Of Contents tag */
26 #define DER_P_BOOLEAN                   1
27 #define DER_P_INTEGER                   2
28 #define DER_P_BIT_STRING                3
29 #define DER_P_OCTET_STRING              4
30 #define DER_P_NULL                      5
31 #define DER_P_OBJECT                    6
32 #define DER_P_OBJECT_DESCRIPTOR         7
33 #define DER_P_EXTERNAL                  8
34 #define DER_P_REAL                      9
35 #define DER_P_ENUMERATED               10
36 #define DER_P_UTF8STRING               12
37 #define DER_P_SEQUENCE                 16
38 #define DER_P_SET                      17
39 #define DER_P_NUMERICSTRING            18
40 #define DER_P_PRINTABLESTRING          19
41 #define DER_P_T61STRING                20
42 #define DER_P_VIDEOTEXSTRING           21
43 #define DER_P_IA5STRING                22
44 #define DER_P_UTCTIME                  23
45 #define DER_P_GENERALIZEDTIME          24
46 #define DER_P_GRAPHICSTRING            25
47 #define DER_P_ISO64STRING              26
48 #define DER_P_GENERALSTRING            27
49 #define DER_P_UNIVERSALSTRING          28
50 #define DER_P_BMPSTRING                30
51
52 /* DER Flags, occupying bit 6 in the DER identifier byte */
53 #define DER_F_PRIMITIVE              0x00
54 #define DER_F_CONSTRUCTED            0x20
55
56 /* DER classes tags, occupying bits 7-8 in the DER identifier byte */
57 #define DER_C_UNIVERSAL              0x00
58 #define DER_C_APPLICATION            0x40
59 #define DER_C_CONTEXT                0x80
60 #define DER_C_PRIVATE                0xC0
61
62 /*
63  * Run-time constructors.
64  *
65  * They all construct DER backwards, so care should be taken to use them
66  * that way.
67  */
68
69 /* This can be used for all items that don't have a context */
70 #define DER_NO_CONTEXT  -1
71
72 int DER_w_precompiled(WPACKET *pkt, int tag,
73                       const unsigned char *precompiled, size_t precompiled_n);
74
75 int DER_w_boolean(WPACKET *pkt, int tag, int b);
76 int DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
77 int DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
78 int DER_w_null(WPACKET *pkt, int tag);
79
80 /*
81  * All constructors for constructed elements have a begin and a end function
82  */
83 int DER_w_begin_sequence(WPACKET *pkt, int tag);
84 int DER_w_end_sequence(WPACKET *pkt, int tag);