1// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Package asn1 contains supporting types for parsing and building ASN.1
6// messages with the cryptobyte package.
7package asn1 // import "golang.org/x/crypto/cryptobyte/asn1"
8
9// Tag represents an ASN.1 identifier octet, consisting of a tag number
10// (indicating a type) and class (such as context-specific or constructed).
11//
12// Methods in the cryptobyte package only support the low-tag-number form, i.e.
13// a single identifier octet with bits 7-8 encoding the class and bits 1-6
14// encoding the tag number.
15type Tag uint8
16
17const (
18	classConstructed     = 0x20
19	classContextSpecific = 0x80
20)
21
22// Constructed returns t with the constructed class bit set.
23func (t Tag) Constructed() Tag { return t | classConstructed }
24
25// ContextSpecific returns t with the context-specific class bit set.
26func (t Tag) ContextSpecific() Tag { return t | classContextSpecific }
27
28// The following is a list of standard tag and class combinations.
29const (
30	BOOLEAN           = Tag(1)
31	INTEGER           = Tag(2)
32	BIT_STRING        = Tag(3)
33	OCTET_STRING      = Tag(4)
34	NULL              = Tag(5)
35	OBJECT_IDENTIFIER = Tag(6)
36	ENUM              = Tag(10)
37	UTF8String        = Tag(12)
38	SEQUENCE          = Tag(16 | classConstructed)
39	SET               = Tag(17 | classConstructed)
40	PrintableString   = Tag(19)
41	T61String         = Tag(20)
42	IA5String         = Tag(22)
43	UTCTime           = Tag(23)
44	GeneralizedTime   = Tag(24)
45	GeneralString     = Tag(27)
46)
47