2014-05-15 14:20:00 +04:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* The origin of this IDL file is
|
|
|
|
* http://www.w3.org/TR/WebCryptoAPI/
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef DOMString KeyType;
|
|
|
|
typedef DOMString KeyUsage;
|
|
|
|
typedef Uint8Array BigInteger;
|
|
|
|
|
|
|
|
/***** KeyAlgorithm interfaces *****/
|
|
|
|
|
|
|
|
[NoInterfaceObject]
|
|
|
|
interface KeyAlgorithm {
|
|
|
|
readonly attribute DOMString name;
|
|
|
|
};
|
|
|
|
|
|
|
|
[NoInterfaceObject]
|
|
|
|
interface AesKeyAlgorithm : KeyAlgorithm {
|
|
|
|
readonly attribute unsigned short length;
|
|
|
|
};
|
|
|
|
|
|
|
|
[NoInterfaceObject]
|
|
|
|
interface HmacKeyAlgorithm : KeyAlgorithm {
|
|
|
|
readonly attribute KeyAlgorithm hash;
|
|
|
|
readonly attribute unsigned long length;
|
|
|
|
};
|
|
|
|
|
|
|
|
[NoInterfaceObject]
|
|
|
|
interface RsaKeyAlgorithm : KeyAlgorithm {
|
|
|
|
readonly attribute unsigned long modulusLength;
|
2014-06-12 00:26:52 +04:00
|
|
|
[Throws]
|
2014-05-15 14:20:00 +04:00
|
|
|
readonly attribute BigInteger publicExponent;
|
|
|
|
};
|
|
|
|
|
|
|
|
[NoInterfaceObject]
|
|
|
|
interface RsaHashedKeyAlgorithm : RsaKeyAlgorithm {
|
|
|
|
readonly attribute KeyAlgorithm hash;
|
|
|
|
};
|
|
|
|
|
2014-07-26 10:00:24 +04:00
|
|
|
[NoInterfaceObject]
|
|
|
|
interface EcKeyAlgorithm : KeyAlgorithm {
|
|
|
|
readonly attribute NamedCurve namedCurve;
|
|
|
|
};
|
|
|
|
|
2014-05-15 14:20:00 +04:00
|
|
|
|
|
|
|
/***** Algorithm dictionaries *****/
|
|
|
|
|
|
|
|
dictionary Algorithm {
|
|
|
|
DOMString name;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary AesCbcParams : Algorithm {
|
|
|
|
CryptoOperationData iv;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary AesCtrParams : Algorithm {
|
|
|
|
CryptoOperationData counter;
|
|
|
|
[EnforceRange] octet length;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary AesGcmParams : Algorithm {
|
|
|
|
CryptoOperationData iv;
|
|
|
|
CryptoOperationData additionalData;
|
|
|
|
[EnforceRange] octet tagLength;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary HmacImportParams : Algorithm {
|
|
|
|
AlgorithmIdentifier hash;
|
|
|
|
};
|
|
|
|
|
2014-07-12 22:06:00 +04:00
|
|
|
dictionary Pbkdf2Params : Algorithm {
|
|
|
|
CryptoOperationData salt;
|
|
|
|
[EnforceRange] unsigned long iterations;
|
|
|
|
AlgorithmIdentifier hash;
|
|
|
|
};
|
|
|
|
|
2014-05-15 14:20:00 +04:00
|
|
|
dictionary RsaHashedImportParams {
|
|
|
|
AlgorithmIdentifier hash;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary AesKeyGenParams : Algorithm {
|
|
|
|
[EnforceRange] unsigned short length;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary HmacKeyGenParams : Algorithm {
|
|
|
|
AlgorithmIdentifier hash;
|
|
|
|
[EnforceRange] unsigned long length;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary RsaKeyGenParams : Algorithm {
|
|
|
|
[EnforceRange] unsigned long modulusLength;
|
|
|
|
BigInteger publicExponent;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
|
|
|
|
AlgorithmIdentifier hash;
|
|
|
|
};
|
|
|
|
|
2014-07-15 05:33:12 +04:00
|
|
|
dictionary RsaOaepParams : Algorithm {
|
|
|
|
CryptoOperationData? label;
|
|
|
|
};
|
|
|
|
|
2014-05-15 14:20:00 +04:00
|
|
|
dictionary DhKeyGenParams : Algorithm {
|
|
|
|
BigInteger prime;
|
|
|
|
BigInteger generator;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef DOMString NamedCurve;
|
|
|
|
dictionary EcKeyGenParams : Algorithm {
|
|
|
|
NamedCurve namedCurve;
|
|
|
|
};
|
|
|
|
|
2014-07-29 13:11:26 +04:00
|
|
|
dictionary EcdhKeyDeriveParams : Algorithm {
|
|
|
|
CryptoKey public;
|
|
|
|
};
|
|
|
|
|
2014-07-19 17:25:00 +04:00
|
|
|
|
|
|
|
/***** JWK *****/
|
|
|
|
|
|
|
|
dictionary RsaOtherPrimesInfo {
|
|
|
|
// The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
|
|
|
|
DOMString r;
|
|
|
|
DOMString d;
|
|
|
|
DOMString t;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary JsonWebKey {
|
|
|
|
// The following fields are defined in Section 3.1 of JSON Web Key
|
|
|
|
DOMString kty;
|
|
|
|
DOMString use;
|
|
|
|
sequence<DOMString> key_ops;
|
|
|
|
DOMString alg;
|
|
|
|
|
|
|
|
// The following fields are defined in JSON Web Key Parameters Registration
|
|
|
|
boolean ext;
|
|
|
|
|
|
|
|
// The following fields are defined in Section 6 of JSON Web Algorithms
|
|
|
|
DOMString crv;
|
|
|
|
DOMString x;
|
|
|
|
DOMString y;
|
|
|
|
DOMString d;
|
|
|
|
DOMString n;
|
|
|
|
DOMString e;
|
|
|
|
DOMString p;
|
|
|
|
DOMString q;
|
|
|
|
DOMString dp;
|
|
|
|
DOMString dq;
|
|
|
|
DOMString qi;
|
|
|
|
sequence<RsaOtherPrimesInfo> oth;
|
|
|
|
DOMString k;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-15 14:20:00 +04:00
|
|
|
/***** The Main API *****/
|
|
|
|
|
|
|
|
[Pref="dom.webcrypto.enabled"]
|
2014-06-24 01:25:13 +04:00
|
|
|
interface CryptoKey {
|
2014-05-15 14:20:00 +04:00
|
|
|
readonly attribute KeyType type;
|
|
|
|
readonly attribute boolean extractable;
|
|
|
|
readonly attribute KeyAlgorithm algorithm;
|
|
|
|
[Cached, Constant, Frozen] readonly attribute sequence<KeyUsage> usages;
|
|
|
|
};
|
|
|
|
|
2014-05-26 14:05:00 +04:00
|
|
|
[Pref="dom.webcrypto.enabled"]
|
2014-06-24 01:25:13 +04:00
|
|
|
interface CryptoKeyPair {
|
|
|
|
readonly attribute CryptoKey publicKey;
|
|
|
|
readonly attribute CryptoKey privateKey;
|
2014-05-26 14:05:00 +04:00
|
|
|
};
|
|
|
|
|
2014-05-15 14:20:00 +04:00
|
|
|
typedef DOMString KeyFormat;
|
|
|
|
typedef (ArrayBufferView or ArrayBuffer) CryptoOperationData;
|
|
|
|
typedef (object or DOMString) AlgorithmIdentifier;
|
|
|
|
|
|
|
|
[Pref="dom.webcrypto.enabled"]
|
|
|
|
interface SubtleCrypto {
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> encrypt(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey key,
|
|
|
|
CryptoOperationData data);
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> decrypt(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey key,
|
|
|
|
CryptoOperationData data);
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> sign(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey key,
|
|
|
|
CryptoOperationData data);
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> verify(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey key,
|
|
|
|
CryptoOperationData signature,
|
|
|
|
CryptoOperationData data);
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> digest(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoOperationData data);
|
2014-05-15 14:20:00 +04:00
|
|
|
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> generateKey(AlgorithmIdentifier algorithm,
|
|
|
|
boolean extractable,
|
|
|
|
sequence<KeyUsage> keyUsages );
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> deriveKey(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey baseKey,
|
|
|
|
AlgorithmIdentifier derivedKeyType,
|
|
|
|
boolean extractable,
|
|
|
|
sequence<KeyUsage> keyUsages );
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> deriveBits(AlgorithmIdentifier algorithm,
|
|
|
|
CryptoKey baseKey,
|
|
|
|
unsigned long length);
|
2014-05-15 14:20:00 +04:00
|
|
|
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> importKey(KeyFormat format,
|
|
|
|
object keyData,
|
|
|
|
AlgorithmIdentifier algorithm,
|
|
|
|
boolean extractable,
|
|
|
|
sequence<KeyUsage> keyUsages );
|
2014-07-19 05:31:11 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> exportKey(KeyFormat format, CryptoKey key);
|
2014-07-19 17:24:00 +04:00
|
|
|
|
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> wrapKey(KeyFormat format,
|
|
|
|
CryptoKey key,
|
|
|
|
CryptoKey wrappingKey,
|
|
|
|
AlgorithmIdentifier wrapAlgorithm);
|
2014-07-19 17:24:00 +04:00
|
|
|
|
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> unwrapKey(KeyFormat format,
|
|
|
|
CryptoOperationData wrappedKey,
|
|
|
|
CryptoKey unwrappingKey,
|
|
|
|
AlgorithmIdentifier unwrapAlgorithm,
|
|
|
|
AlgorithmIdentifier unwrappedKeyAlgorithm,
|
|
|
|
boolean extractable,
|
|
|
|
sequence<KeyUsage> keyUsages );
|
2014-05-15 14:20:00 +04:00
|
|
|
};
|
|
|
|
|