1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
10 #include "net/base/net_export.h"
16 // This Tag type represents the identifier for an ASN.1 tag as encoded with DER.
17 // It follows the same bit-for-bit representation (including the class, tag
18 // number, and primitive/constructed bit) as DER. Constants are provided for
19 // universal class types, and functions are provided for building context
20 // specific tags. Tags can also be built from the provided constants and
24 // Universal class primitive types
25 const Tag kBool
= 0x01;
26 const Tag kInteger
= 0x02;
27 const Tag kBitString
= 0x03;
28 const Tag kOctetString
= 0x04;
29 const Tag kNull
= 0x05;
30 const Tag kOid
= 0x06;
31 const Tag kUtf8String
= 0x0C;
32 const Tag kPrintableString
= 0x13;
33 const Tag kIA5String
= 0x16;
34 const Tag kUtcTime
= 0x17;
35 const Tag kGeneralizedTime
= 0x18;
36 const Tag kUniversalString
= 0x1C;
37 const Tag kBmpString
= 0x1E;
39 // Universal class constructed types
40 const Tag kSequence
= 0x30;
41 const Tag kSet
= 0x31;
43 // Primitive/constructed bits
44 const uint8_t kTagPrimitive
= 0x00;
45 const uint8_t kTagConstructed
= 0x20;
48 const uint8_t kTagUniversal
= 0x00;
49 const uint8_t kTagApplication
= 0x40;
50 const uint8_t kTagContextSpecific
= 0x80;
51 const uint8_t kTagPrivate
= 0xC0;
53 // Masks for the 3 components of a tag (class, primitive/constructed, number)
54 const uint8_t kTagNumberMask
= 0x1F;
55 const uint8_t kTagConstructionMask
= 0x20;
56 const uint8_t kTagClassMask
= 0xC0;
58 // Creates the value for the outter tag of an explicitly tagged type.
60 // The ASN.1 keyword for this is:
61 // [class_number] EXPLICIT
63 // (Note, the EXPLICIT may be omitted if the entire schema is in
64 // EXPLICIT mode, the default)
65 NET_EXPORT Tag
ContextSpecificConstructed(uint8_t class_number
);
67 NET_EXPORT Tag
ContextSpecificPrimitive(uint8_t base
);
68 NET_EXPORT
bool IsConstructed(Tag tag
);
74 #endif // NET_DER_TAG_H_