aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/asn1/TagClass.java
blob: 2693512727c5126432329fd0d8d2963580090df0 (plain)
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
package model.asn1;

/**
 * Represents the class (UNIVERSAL, APPLICATION, PRIVATE, CONTEXT-SPECIFIC) of an ASN.1 tag. See X.680$8.1.
 * The purpose of UNIVERSAL, APPLICATION, PRIVATE, and CONTEXT_SPECIFIC can be found in X.680 spec.
 * For example, UNIVERSAL means tags specified in the core ASN.1 spec.
 * This class also represents the value to the two highest bits of DER-encoded tag values.
 */
public enum TagClass {
    // 0b00000000
    UNIVERSAL((byte) 0x0),
    // 0b01000000
    APPLICATION((byte) 0x40),
    // 0b11000000
    PRIVATE((byte) -64),
    // 0b10000000
    CONTEXT_SPECIFIC((byte) -128);

    private final Byte val;

    /**
     * EFFECT: Constructs the tag class with the given DER tag byte value.
     * REQUIRES: The Byte value must have low 6bits cleared.
     */
    TagClass(Byte val) {
        this.val = val;
    }

    public Byte getVal() {
        return val;
    }
}