summaryrefslogtreecommitdiffstats
path: root/comm/third_party/asn1js/src/types.ts
blob: 60b5ee414ae597ec6ca42c7ae6ba26f3c6781be3 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
export interface IBerConvertible {

  /**
   * Base function for converting block from BER encoded array of bytes
   * @param inputBuffer ASN.1 BER encoded array
   * @param inputOffset Offset in ASN.1 BER encoded array where decoding should be started
   * @param inputLength Maximum length of array of bytes which can be using in this function
   * @returns Offset after least decoded byte
   */
  fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number;
  /**
   * Encoding of current ASN.1 block into ASN.1 encoded array (BER rules)
   * @param sizeOnly Flag that we need only a size of encoding, not a real array of bytes
   * @returns ASN.1 BER encoded array
   */
  toBER(sizeOnly?: boolean): ArrayBuffer;
}

export interface IDerConvertible {
  /**
   * Base function for converting block from DER encoded array of bytes
   * @param inputBuffer ASN.1 DER encoded array
   * @param inputOffset Offset in ASN.1 DER encoded array where decoding should be started
   * @param inputLength Maximum length of array of bytes which can be using in this function
   * @param expectedLength Expected length of converted VALUE_HEX buffer
   * @returns Offset after least decoded byte
   */
  fromDER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number, expectedLength?: number): number;
  /**
   * Encoding of current ASN.1 block into ASN.1 encoded array (DER rules)
   * @param sizeOnly Flag that we need only a size of encoding, not a real array of bytes
   * @returns ASN.1 DER encoded array
   */
  toDER(sizeOnly?: boolean): ArrayBuffer;
}

export interface IStringConvertible {
  /**
   * Returns a string representation of an object
   * @returns String representation of the class object
   */
  toString(): string;
  /**
   * Creates a class object from the string
   * @param data Input string to convert from
   */
  fromString(data: string): void;
}

export interface IDateConvertible {
  /**
   * Converts a class object into the JavaScrip Date Object
   * @returns Date object
   */
  toDate(): Date;
  /**
   * Creates a class object from the JavaScript Date object
   * @param date Date object
   */
  fromDate(date: Date): void;
}