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/.
6 * The origin of this IDL file is
7 * http://www.w3.org/TR/WebCryptoAPI/
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;
22 dictionary AesCbcParams : Algorithm {
23 required BufferSource iv;
27 dictionary AesCtrParams : Algorithm {
28 required BufferSource counter;
29 required [EnforceRange] octet length;
33 dictionary AesGcmParams : Algorithm {
34 required BufferSource iv;
35 BufferSource additionalData;
36 [EnforceRange] octet tagLength;
39 dictionary HmacImportParams : Algorithm {
40 required AlgorithmIdentifier hash;
44 dictionary Pbkdf2Params : Algorithm {
45 required BufferSource salt;
46 required [EnforceRange] unsigned long iterations;
47 required AlgorithmIdentifier hash;
51 dictionary RsaHashedImportParams {
52 required AlgorithmIdentifier hash;
55 dictionary AesKeyGenParams : Algorithm {
56 required [EnforceRange] unsigned short length;
60 dictionary HmacKeyGenParams : Algorithm {
61 required AlgorithmIdentifier hash;
62 [EnforceRange] unsigned long length;
66 dictionary RsaHashedKeyGenParams : Algorithm {
67 required [EnforceRange] unsigned long modulusLength;
68 required BigInteger publicExponent;
69 required AlgorithmIdentifier hash;
73 dictionary RsaOaepParams : Algorithm {
78 dictionary RsaPssParams : Algorithm {
79 required [EnforceRange] unsigned long saltLength;
83 dictionary EcKeyGenParams : Algorithm {
84 required NamedCurve namedCurve;
88 dictionary AesDerivedKeyParams : Algorithm {
89 required [EnforceRange] unsigned long length;
93 dictionary HmacDerivedKeyParams : HmacImportParams {
94 [EnforceRange] unsigned long length;
98 dictionary EcdhKeyDeriveParams : Algorithm {
99 required CryptoKey public;
103 dictionary DhImportKeyParams : Algorithm {
104 required BigInteger prime;
105 required BigInteger generator;
109 dictionary EcdsaParams : Algorithm {
110 required AlgorithmIdentifier hash;
114 dictionary EcKeyImportParams : Algorithm {
115 NamedCurve namedCurve;
119 dictionary HkdfParams : Algorithm {
120 required AlgorithmIdentifier hash;
121 required BufferSource salt;
122 required BufferSource info;
127 dictionary RsaOtherPrimesInfo {
128 // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
129 required DOMString r;
130 required DOMString d;
131 required DOMString t;
134 [GenerateInitFromJSON, GenerateToJSON]
135 dictionary JsonWebKey {
136 // The following fields are defined in Section 3.1 of JSON Web Key
137 required DOMString kty;
139 sequence<DOMString> key_ops;
142 // The following fields are defined in JSON Web Key Parameters Registration
145 // The following fields are defined in Section 6 of JSON Web Algorithms
157 sequence<RsaOtherPrimesInfo> oth;
162 /***** The Main API *****/
166 Exposed=(Window,Worker)]
167 interface CryptoKey {
168 readonly attribute KeyType type;
169 readonly attribute boolean extractable;
170 [Cached, Constant, Throws] readonly attribute object algorithm;
171 [Cached, Constant, Frozen] readonly attribute sequence<KeyUsage> usages;
174 [GenerateConversionToJS]
175 dictionary CryptoKeyPair {
176 required CryptoKey publicKey;
177 required CryptoKey privateKey;
180 typedef DOMString KeyFormat;
181 typedef (object or DOMString) AlgorithmIdentifier;
183 [Exposed=(Window,Worker),
185 interface SubtleCrypto {
187 Promise<any> encrypt(AlgorithmIdentifier algorithm,
191 Promise<any> decrypt(AlgorithmIdentifier algorithm,
195 Promise<any> sign(AlgorithmIdentifier algorithm,
199 Promise<any> verify(AlgorithmIdentifier algorithm,
201 BufferSource signature,
204 Promise<any> digest(AlgorithmIdentifier algorithm,
208 Promise<any> generateKey(AlgorithmIdentifier algorithm,
210 sequence<KeyUsage> keyUsages );
212 Promise<any> deriveKey(AlgorithmIdentifier algorithm,
214 AlgorithmIdentifier derivedKeyType,
216 sequence<KeyUsage> keyUsages );
218 Promise<any> deriveBits(AlgorithmIdentifier algorithm,
220 unsigned long length);
223 Promise<any> importKey(KeyFormat format,
225 AlgorithmIdentifier algorithm,
227 sequence<KeyUsage> keyUsages );
229 Promise<any> exportKey(KeyFormat format, CryptoKey key);
232 Promise<any> wrapKey(KeyFormat format,
234 CryptoKey wrappingKey,
235 AlgorithmIdentifier wrapAlgorithm);
238 Promise<any> unwrapKey(KeyFormat format,
239 BufferSource wrappedKey,
240 CryptoKey unwrappingKey,
241 AlgorithmIdentifier unwrapAlgorithm,
242 AlgorithmIdentifier unwrappedKeyAlgorithm,
244 sequence<KeyUsage> keyUsages );