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;
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;
93 dictionary RsaOtherPrimesInfo {
94 // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
100 dictionary JsonWebKey {
101 // The following fields are defined in Section 3.1 of JSON Web Key
102 required DOMString kty;
104 sequence<DOMString> key_ops;
107 // The following fields are defined in JSON Web Key Parameters Registration
110 // The following fields are defined in Section 6 of JSON Web Algorithms
122 sequence<RsaOtherPrimesInfo> oth;
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 {
149 Promise<any> encrypt(AlgorithmIdentifier algorithm,
151 CryptoOperationData data);
153 Promise<any> decrypt(AlgorithmIdentifier algorithm,
155 CryptoOperationData data);
157 Promise<any> sign(AlgorithmIdentifier algorithm,
159 CryptoOperationData data);
161 Promise<any> verify(AlgorithmIdentifier algorithm,
163 CryptoOperationData signature,
164 CryptoOperationData data);
166 Promise<any> digest(AlgorithmIdentifier algorithm,
167 CryptoOperationData data);
170 Promise<any> generateKey(AlgorithmIdentifier algorithm,
172 sequence<KeyUsage> keyUsages );
174 Promise<any> deriveKey(AlgorithmIdentifier algorithm,
176 AlgorithmIdentifier derivedKeyType,
178 sequence<KeyUsage> keyUsages );
180 Promise<any> deriveBits(AlgorithmIdentifier algorithm,
182 unsigned long length);
185 Promise<any> importKey(KeyFormat format,
187 AlgorithmIdentifier algorithm,
189 sequence<KeyUsage> keyUsages );
191 Promise<any> exportKey(KeyFormat format, CryptoKey key);
194 Promise<any> wrapKey(KeyFormat format,
196 CryptoKey wrappingKey,
197 AlgorithmIdentifier wrapAlgorithm);
200 Promise<any> unwrapKey(KeyFormat format,
201 CryptoOperationData wrappedKey,
202 CryptoKey unwrappingKey,
203 AlgorithmIdentifier unwrapAlgorithm,
204 AlgorithmIdentifier unwrappedKeyAlgorithm,
206 sequence<KeyUsage> keyUsages );