SubtleCrypto.idl 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #import <Crypto/CryptoKey.idl>
  2. typedef (object or DOMString) AlgorithmIdentifier;
  3. dictionary Algorithm {
  4. required DOMString name;
  5. };
  6. enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
  7. dictionary RsaOtherPrimesInfo {
  8. // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
  9. DOMString r;
  10. DOMString d;
  11. DOMString t;
  12. };
  13. dictionary JsonWebKey
  14. {
  15. // The following fields are defined in Section 3.1 of JSON Web Key
  16. DOMString kty;
  17. DOMString use;
  18. sequence<DOMString> key_ops;
  19. DOMString alg;
  20. // The following fields are defined in JSON Web Key Parameters Registration
  21. boolean ext;
  22. // The following fields are defined in Section 6 of JSON Web Algorithms
  23. DOMString crv;
  24. DOMString x;
  25. DOMString y;
  26. DOMString d;
  27. DOMString n;
  28. DOMString e;
  29. DOMString p;
  30. DOMString q;
  31. DOMString dp;
  32. DOMString dq;
  33. DOMString qi;
  34. sequence<RsaOtherPrimesInfo> oth;
  35. DOMString k;
  36. };
  37. // https://w3c.github.io/webcrypto/#subtlecrypto-interface
  38. [SecureContext,Exposed=(Window,Worker)]
  39. interface SubtleCrypto {
  40. // FIXME: Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
  41. // FIXME: Promise<any> decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
  42. // FIXME: Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
  43. // FIXME: Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data);
  44. Promise<any> digest(AlgorithmIdentifier algorithm, BufferSource data);
  45. Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<KeyUsage> keyUsages);
  46. // FIXME: Promise<any> deriveKey(AlgorithmIdentifier algorithm, CryptoKey baseKey, AlgorithmIdentifier derivedKeyType, boolean extractable, sequence<KeyUsage> keyUsages );
  47. // FIXME: Promise<ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, unsigned long length);
  48. Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolean extractable, sequence<KeyUsage> keyUsages);
  49. Promise<any> exportKey(KeyFormat format, CryptoKey key);
  50. // FIXME: Promise<any> wrapKey(KeyFormat format, CryptoKey key, CryptoKey wrappingKey, AlgorithmIdentifier wrapAlgorithm);
  51. // FIXME: Promise<CryptoKey> unwrapKey(KeyFormat format, BufferSource wrappedKey, CryptoKey unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier unwrappedKeyAlgorithm, boolean extractable, sequence<KeyUsage> keyUsages);
  52. };