blob: 9045e14bdc551f720231dbd417bb8adaa0fd7d78 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package model.asn1;
import model.asn1.exceptions.ParseException;
import model.asn1.parsing.BytesReader;
/**
* Represents the ASN.1 NULL type. It always has zero length. With the default assigned tag, it always encodes
* into 0x05 0x00.
*/
public class Null extends ASN1Object {
/**
* The X.680 universal class tag assignment.
*/
public static final Tag TAG = new Tag(TagClass.UNIVERSAL, false, 0x5);
/**
* EFFECTS: Initiate the NULL with the given tag and an optional context-specific tag number for explicit
* encoding. For more information, consult {@link ASN1Object}. NULL does not take any other arguments.
* REQUIRES: Consult {@link ASN1Object}.
*/
public Null(Tag tag, Tag parentTag) {
super(tag, parentTag);
}
/**
* EFFECTS: Parse input bytes. For more information on tags parsing, consult {@link ASN1Object}.
* Throws {@link ParseException} if the input data is invalid:
* - The length is not 0
* - Other cases as denoted in {@link ASN1Object}
*/
public Null(BytesReader encoded, boolean hasParentTag) throws ParseException {
super(encoded, hasParentTag);
if (getLength() != 0) {
throw new ParseException("NULL must have zero length!");
}
}
/**
* EFFECTS: Always produce an empty array.
*/
@Override
public Byte[] encodeValueDER() {
return new Byte[0];
}
}
|