File size: 2,074 Bytes
80ce16c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { CryptoOperation } from "./CryptoOperation";
import { Key } from "./Key";
import { KeyOperation } from "./KeyOperation";

export type KeyUsage =
  | "encrypt"
  | "decrypt"
  | "sign"
  | "verify"
  | "derive"
  | "wrapKey"
  | "unwrapKey"
  | "importKey";

export type EncryptionOrVerificationAlgorithm = "RSAES-PKCS1-v1_5";
export type Ie11EncryptionAlgorithm =
  | "AES-CBC"
  | "AES-GCM"
  | "RSA-OAEP"
  | EncryptionOrVerificationAlgorithm;
export type Ie11DigestAlgorithm = "SHA-1" | "SHA-256" | "SHA-384";

export interface HashAlgorithm {
  name: Ie11DigestAlgorithm;
}

export interface HmacAlgorithm {
  name: "HMAC";
  hash: HashAlgorithm;
}

export type SigningAlgorithm = HmacAlgorithm;

/**
 * Represent ths SubtleCrypto interface as implemented in Internet Explorer 11.
 * This implementation was based on an earlier version of the WebCrypto API and
 * differs from the `window.crypto.subtle` object exposed in Chrome, Safari,
 * Firefox, and MS Edge.
 *
 * @see https://msdn.microsoft.com/en-us/library/dn302325(v=vs.85).aspx
 */
export interface MsSubtleCrypto {
  decrypt(
    algorithm: Ie11EncryptionAlgorithm,
    key: Key,
    buffer?: ArrayBufferView
  ): CryptoOperation;

  digest(
    algorithm: Ie11DigestAlgorithm,
    buffer?: ArrayBufferView
  ): CryptoOperation;

  encrypt(
    algorithm: Ie11EncryptionAlgorithm,
    key: Key,
    buffer?: ArrayBufferView
  ): CryptoOperation;

  exportKey(format: string, key: Key): KeyOperation;

  generateKey(
    algorithm: SigningAlgorithm | Ie11EncryptionAlgorithm,
    extractable?: boolean,
    keyUsages?: Array<KeyUsage>
  ): KeyOperation;

  importKey(
    format: string,
    keyData: ArrayBufferView,
    algorithm: any,
    extractable?: boolean,
    keyUsages?: Array<KeyUsage>
  ): KeyOperation;

  sign(
    algorithm: SigningAlgorithm,
    key: Key,
    buffer?: ArrayBufferView
  ): CryptoOperation;

  verify(
    algorithm: SigningAlgorithm | EncryptionOrVerificationAlgorithm,
    key: Key,
    signature: ArrayBufferView,
    buffer?: ArrayBufferView
  ): CryptoOperation;
}