Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / webidl / SubtleCrypto.webidl
bloba4e1b07950cbaff1695b711d76ae50d42ce94ad7
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * http://www.w3.org/TR/WebCryptoAPI/
8  */
10 typedef DOMString KeyType;
11 typedef DOMString KeyUsage;
12 typedef DOMString NamedCurve;
13 typedef Uint8Array BigInteger;
15 /***** Algorithm dictionaries *****/
17 dictionary Algorithm {
18   required DOMString name;
21 dictionary AesCbcParams : Algorithm {
22   required CryptoOperationData iv;
25 dictionary AesCtrParams : Algorithm {
26   required CryptoOperationData counter;
27   [EnforceRange] required octet length;
30 dictionary AesGcmParams : Algorithm {
31   required CryptoOperationData iv;
32   CryptoOperationData additionalData;
33   [EnforceRange] octet tagLength;
36 dictionary HmacImportParams : Algorithm {
37   required AlgorithmIdentifier hash;
40 dictionary Pbkdf2Params : Algorithm {
41   required CryptoOperationData salt;
42   [EnforceRange] required unsigned long iterations;
43   required AlgorithmIdentifier hash;
46 dictionary RsaHashedImportParams {
47   required AlgorithmIdentifier hash;
50 dictionary AesKeyGenParams : Algorithm {
51   [EnforceRange] required unsigned short length;
54 dictionary HmacKeyGenParams : Algorithm {
55   required AlgorithmIdentifier hash;
56   [EnforceRange] unsigned long length;
59 dictionary RsaHashedKeyGenParams : Algorithm {
60   [EnforceRange] required unsigned long modulusLength;
61   required BigInteger publicExponent;
62   required AlgorithmIdentifier hash;
65 dictionary RsaOaepParams : Algorithm {
66   CryptoOperationData label;
69 dictionary DhKeyGenParams : Algorithm {
70   required BigInteger prime;
71   required BigInteger generator;
74 dictionary EcKeyGenParams : Algorithm {
75   required NamedCurve namedCurve;
78 dictionary AesDerivedKeyParams : Algorithm {
79   [EnforceRange] required unsigned long length;
82 dictionary HmacDerivedKeyParams : HmacImportParams {
83   [EnforceRange] unsigned long length;
86 dictionary EcdhKeyDeriveParams : Algorithm {
87   required CryptoKey public;
91 /***** JWK *****/
93 dictionary RsaOtherPrimesInfo {
94   // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
95   required DOMString r;
96   required DOMString d;
97   required DOMString t;
100 dictionary JsonWebKey {
101   // The following fields are defined in Section 3.1 of JSON Web Key
102   required DOMString kty;
103   DOMString use;
104   sequence<DOMString> key_ops;
105   DOMString alg;
107   // The following fields are defined in JSON Web Key Parameters Registration
108   boolean ext;
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;
127 /***** The Main API *****/
129 [Pref="dom.webcrypto.enabled"]
130 interface CryptoKey {
131   readonly attribute KeyType type;
132   readonly attribute boolean extractable;
133   [Cached, Constant, Throws] readonly attribute object algorithm;
134   [Cached, Constant, Frozen] readonly attribute sequence<KeyUsage> usages;
137 dictionary CryptoKeyPair {
138   required CryptoKey publicKey;
139   required CryptoKey privateKey;
142 typedef DOMString KeyFormat;
143 typedef (ArrayBufferView or ArrayBuffer) CryptoOperationData;
144 typedef (object or DOMString) AlgorithmIdentifier;
146 [Pref="dom.webcrypto.enabled"]
147 interface SubtleCrypto {
148   [Throws]
149   Promise<any> encrypt(AlgorithmIdentifier algorithm,
150                        CryptoKey key,
151                        CryptoOperationData data);
152   [Throws]
153   Promise<any> decrypt(AlgorithmIdentifier algorithm,
154                        CryptoKey key,
155                        CryptoOperationData data);
156   [Throws]
157   Promise<any> sign(AlgorithmIdentifier algorithm,
158                      CryptoKey key,
159                      CryptoOperationData data);
160   [Throws]
161   Promise<any> verify(AlgorithmIdentifier algorithm,
162                       CryptoKey key,
163                       CryptoOperationData signature,
164                       CryptoOperationData data);
165   [Throws]
166   Promise<any> digest(AlgorithmIdentifier algorithm,
167                       CryptoOperationData data);
169   [Throws]
170   Promise<any> generateKey(AlgorithmIdentifier algorithm,
171                            boolean extractable,
172                            sequence<KeyUsage> keyUsages );
173   [Throws]
174   Promise<any> deriveKey(AlgorithmIdentifier algorithm,
175                          CryptoKey baseKey,
176                          AlgorithmIdentifier derivedKeyType,
177                          boolean extractable,
178                          sequence<KeyUsage> keyUsages );
179   [Throws]
180   Promise<any> deriveBits(AlgorithmIdentifier algorithm,
181                           CryptoKey baseKey,
182                           unsigned long length);
184   [Throws]
185   Promise<any> importKey(KeyFormat format,
186                          object keyData,
187                          AlgorithmIdentifier algorithm,
188                          boolean extractable,
189                          sequence<KeyUsage> keyUsages );
190   [Throws]
191   Promise<any> exportKey(KeyFormat format, CryptoKey key);
193   [Throws]
194   Promise<any> wrapKey(KeyFormat format,
195                        CryptoKey key,
196                        CryptoKey wrappingKey,
197                        AlgorithmIdentifier wrapAlgorithm);
199   [Throws]
200   Promise<any> unwrapKey(KeyFormat format,
201                          CryptoOperationData wrappedKey,
202                          CryptoKey unwrappingKey,
203                          AlgorithmIdentifier unwrapAlgorithm,
204                          AlgorithmIdentifier unwrappedKeyAlgorithm,
205                          boolean extractable,
206                          sequence<KeyUsage> keyUsages );