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