1// GENERATED CONTENT - DO NOT EDIT
2// Content was automatically extracted by Reffy into webref
3// (https://github.com/w3c/webref)
4// Source: Web Cryptography API (https://w3c.github.io/webcrypto/)
5
6partial interface mixin WindowOrWorkerGlobalScope {
7  [SameObject] readonly attribute Crypto crypto;
8};
9
10[Exposed=(Window,Worker)]
11interface Crypto {
12  [SecureContext] readonly attribute SubtleCrypto subtle;
13  ArrayBufferView getRandomValues(ArrayBufferView array);
14};
15
16typedef (object or DOMString) AlgorithmIdentifier;
17
18typedef AlgorithmIdentifier HashAlgorithmIdentifier;
19
20dictionary Algorithm {
21  required DOMString name;
22};
23
24dictionary KeyAlgorithm {
25  required DOMString name;
26};
27
28enum KeyType { "public", "private", "secret" };
29
30enum KeyUsage { "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", "unwrapKey" };
31
32[SecureContext,Exposed=(Window,Worker)]
33interface CryptoKey {
34  readonly attribute KeyType type;
35  readonly attribute boolean extractable;
36  readonly attribute object algorithm;
37  readonly attribute object usages;
38};
39
40enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
41
42[SecureContext,Exposed=(Window,Worker)]
43interface SubtleCrypto {
44  Promise<any> encrypt(AlgorithmIdentifier algorithm,
45                       CryptoKey key,
46                       BufferSource data);
47  Promise<any> decrypt(AlgorithmIdentifier algorithm,
48                       CryptoKey key,
49                       BufferSource data);
50  Promise<any> sign(AlgorithmIdentifier algorithm,
51                    CryptoKey key,
52                    BufferSource data);
53  Promise<any> verify(AlgorithmIdentifier algorithm,
54                      CryptoKey key,
55                      BufferSource signature,
56                      BufferSource data);
57  Promise<any> digest(AlgorithmIdentifier algorithm,
58                      BufferSource data);
59
60  Promise<any> generateKey(AlgorithmIdentifier algorithm,
61                          boolean extractable,
62                          sequence<KeyUsage> keyUsages );
63  Promise<any> deriveKey(AlgorithmIdentifier algorithm,
64                         CryptoKey baseKey,
65                         AlgorithmIdentifier derivedKeyType,
66                         boolean extractable,
67                         sequence<KeyUsage> keyUsages );
68  Promise<ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm,
69                          CryptoKey baseKey,
70                          unsigned long length);
71
72  Promise<CryptoKey> importKey(KeyFormat format,
73                         (BufferSource or JsonWebKey) keyData,
74                         AlgorithmIdentifier algorithm,
75                         boolean extractable,
76                         sequence<KeyUsage> keyUsages );
77  Promise<any> exportKey(KeyFormat format, CryptoKey key);
78
79  Promise<any> wrapKey(KeyFormat format,
80                       CryptoKey key,
81                       CryptoKey wrappingKey,
82                       AlgorithmIdentifier wrapAlgorithm);
83  Promise<CryptoKey> unwrapKey(KeyFormat format,
84                         BufferSource wrappedKey,
85                         CryptoKey unwrappingKey,
86                         AlgorithmIdentifier unwrapAlgorithm,
87                         AlgorithmIdentifier unwrappedKeyAlgorithm,
88                         boolean extractable,
89                         sequence<KeyUsage> keyUsages );
90};
91
92dictionary RsaOtherPrimesInfo {
93  // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
94  DOMString r;
95  DOMString d;
96  DOMString t;
97};
98
99dictionary JsonWebKey {
100  // The following fields are defined in Section 3.1 of JSON Web Key
101  DOMString kty;
102  DOMString use;
103  sequence<DOMString> key_ops;
104  DOMString alg;
105
106  // The following fields are defined in JSON Web Key Parameters Registration
107  boolean ext;
108
109  // The following fields are defined in Section 6 of JSON Web Algorithms
110  DOMString crv;
111  DOMString x;
112  DOMString y;
113  DOMString d;
114  DOMString n;
115  DOMString e;
116  DOMString p;
117  DOMString q;
118  DOMString dp;
119  DOMString dq;
120  DOMString qi;
121  sequence<RsaOtherPrimesInfo> oth;
122  DOMString k;
123};
124
125typedef Uint8Array BigInteger;
126
127dictionary CryptoKeyPair {
128  CryptoKey publicKey;
129  CryptoKey privateKey;
130};
131
132dictionary RsaKeyGenParams : Algorithm {
133  required [EnforceRange] unsigned long modulusLength;
134  required BigInteger publicExponent;
135};
136
137dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
138  required HashAlgorithmIdentifier hash;
139};
140
141dictionary RsaKeyAlgorithm : KeyAlgorithm {
142  required unsigned long modulusLength;
143  required BigInteger publicExponent;
144};
145
146dictionary RsaHashedKeyAlgorithm : RsaKeyAlgorithm {
147  required KeyAlgorithm hash;
148};
149
150dictionary RsaHashedImportParams : Algorithm {
151  required HashAlgorithmIdentifier hash;
152};
153
154dictionary RsaPssParams : Algorithm {
155  required [EnforceRange] unsigned long saltLength;
156};
157
158dictionary RsaOaepParams : Algorithm {
159  BufferSource label;
160};
161
162dictionary EcdsaParams : Algorithm {
163  required HashAlgorithmIdentifier hash;
164};
165
166typedef DOMString NamedCurve;
167
168dictionary EcKeyGenParams : Algorithm {
169  required NamedCurve namedCurve;
170};
171
172dictionary EcKeyAlgorithm : KeyAlgorithm {
173  required NamedCurve namedCurve;
174};
175
176dictionary EcKeyImportParams : Algorithm {
177  required NamedCurve namedCurve;
178};
179
180dictionary EcdhKeyDeriveParams : Algorithm {
181  required CryptoKey public;
182};
183
184dictionary AesCtrParams : Algorithm {
185  required BufferSource counter;
186  required [EnforceRange] octet length;
187};
188
189dictionary AesKeyAlgorithm : KeyAlgorithm {
190  required unsigned short length;
191};
192
193dictionary AesKeyGenParams : Algorithm {
194  required [EnforceRange] unsigned short length;
195};
196
197dictionary AesDerivedKeyParams : Algorithm {
198  required [EnforceRange] unsigned short length;
199};
200
201dictionary AesCbcParams : Algorithm {
202  required BufferSource iv;
203};
204
205dictionary AesGcmParams : Algorithm {
206  required BufferSource iv;
207  BufferSource additionalData;
208  [EnforceRange] octet tagLength;
209};
210
211dictionary HmacImportParams : Algorithm {
212  required HashAlgorithmIdentifier hash;
213  [EnforceRange] unsigned long length;
214};
215
216dictionary HmacKeyAlgorithm : KeyAlgorithm {
217  required KeyAlgorithm hash;
218  required unsigned long length;
219};
220
221dictionary HmacKeyGenParams : Algorithm {
222  required HashAlgorithmIdentifier hash;
223  [EnforceRange] unsigned long length;
224};
225
226dictionary HkdfParams : Algorithm {
227  required HashAlgorithmIdentifier hash;
228  required BufferSource salt;
229  required BufferSource info;
230};
231
232dictionary Pbkdf2Params : Algorithm {
233  required BufferSource salt;
234  required [EnforceRange] unsigned long iterations;
235  required HashAlgorithmIdentifier hash;
236};
237