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 kUtcTime
= 0x17;
34 const Tag kGeneralizedTime
= 0x18;
36 // Universal class constructed types
37 const Tag kSequence
= 0x30;
38 const Tag kSet
= 0x31;
40 // Primitive/constructed bits
41 const uint8_t kTagPrimitive
= 0x00;
42 const uint8_t kTagConstructed
= 0x20;
45 const uint8_t kTagUniversal
= 0x00;
46 const uint8_t kTagApplication
= 0x40;
47 const uint8_t kTagContextSpecific
= 0x80;
48 const uint8_t kTagPrivate
= 0xC0;
50 // Masks for the 3 components of a tag (class, primitive/constructed, number)
51 const uint8_t kTagNumberMask
= 0x1F;
52 const uint8_t kTagConstructionMask
= 0x20;
53 const uint8_t kTagClassMask
= 0xC0;
55 // Creates the value for the outter tag of an explicitly tagged type.
57 // The ASN.1 keyword for this is:
58 // [class_number] EXPLICIT
60 // (Note, the EXPLICIT may be omitted if the entire schema is in
61 // EXPLICIT mode, the default)
62 NET_EXPORT Tag
ContextSpecificConstructed(uint8_t class_number
);
64 NET_EXPORT Tag
ContextSpecificPrimitive(uint8_t base
);
65 NET_EXPORT
bool IsConstructed(Tag tag
);
71 #endif // NET_DER_TAG_H_