servo/components/script/dom/webidls/SubtleCrypto.webidl
Daniel Adams fc0d4d8157
crypto: Begin SubtleCrypto implementation (#33628)
* Update IDLs and Bindings conf

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Add AES crate

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Implement DOM interfaces

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* IDL tidy

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Remove deriveKey from inRealms for now until implemented

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Fix CryptoKey rustdoc comments

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Move string constants to top of file

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Use properly rooted CryptoKey

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Code clarity

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Rework NormalizedAlgorithm to not hold a DOMString

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Add Rustdoc for CryptoKey interface

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Move ignore mallocsizeof to rand crate, remove from crypto

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Update cargo lock

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Fix key handling, implement exportKey with JWK TODO

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Add missing spec link

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Use create_buffer_source, remove aes dep from libservo

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Fix crash when running in worker

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Update expectations

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* fmt

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Move CryptoKey and SubtleCrypto behind pref for now

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Update expectations

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Readd timeout expectation

Signed-off-by: Daniel Adams <msub2official@gmail.com>

---------

Signed-off-by: Daniel Adams <msub2official@gmail.com>
2024-10-08 03:51:08 +00:00

87 lines
3.2 KiB
Text

/* 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 https://mozilla.org/MPL/2.0/. */
// https://w3c.github.io/webcrypto/#subtlecrypto-interface
typedef (object or DOMString) AlgorithmIdentifier;
typedef AlgorithmIdentifier HashAlgorithmIdentifier;
dictionary Algorithm {
required DOMString name;
};
dictionary KeyAlgorithm {
required DOMString name;
};
enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
[SecureContext,Exposed=(Window,Worker),Pref="dom.crypto.subtle.enabled"]
interface SubtleCrypto {
// Promise<any> encrypt(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource data);
// Promise<any> decrypt(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource data);
// Promise<any> sign(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource data);
// Promise<any> verify(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource signature,
// BufferSource data);
// Promise<any> digest(AlgorithmIdentifier algorithm,
// BufferSource data);
Promise<any> generateKey(AlgorithmIdentifier algorithm,
boolean extractable,
sequence<KeyUsage> keyUsages );
// Promise<any> deriveKey(AlgorithmIdentifier algorithm,
// CryptoKey baseKey,
// AlgorithmIdentifier derivedKeyType,
// boolean extractable,
// sequence<KeyUsage> keyUsages );
// Promise<ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm,
// CryptoKey baseKey,
// optional unsigned long? length = null);
// Promise<CryptoKey> importKey(KeyFormat format,
// (BufferSource or JsonWebKey) keyData,
// AlgorithmIdentifier algorithm,
// boolean extractable,
// sequence<KeyUsage> keyUsages );
Promise<any> exportKey(KeyFormat format, CryptoKey key);
// Promise<any> wrapKey(KeyFormat format,
// CryptoKey key,
// CryptoKey wrappingKey,
// AlgorithmIdentifier wrapAlgorithm);
// Promise<CryptoKey> unwrapKey(KeyFormat format,
// BufferSource wrappedKey,
// CryptoKey unwrappingKey,
// AlgorithmIdentifier unwrapAlgorithm,
// AlgorithmIdentifier unwrappedKeyAlgorithm,
// boolean extractable,
// sequence<KeyUsage> keyUsages );
};
// AES shared
dictionary AesKeyAlgorithm : KeyAlgorithm {
required unsigned short length;
};
dictionary AesKeyGenParams : Algorithm {
required [EnforceRange] unsigned short length;
};
dictionary AesDerivedKeyParams : Algorithm {
required [EnforceRange] unsigned short length;
};
// AES_CBC
dictionary AesCbcParams : Algorithm {
required BufferSource iv;
};