CryptoBindings.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2023, stelar7 <dudedbz@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/WebIDL/Buffers.h>
  8. // FIXME: Generate these from IDL
  9. namespace Web::Bindings {
  10. // https://w3c.github.io/webcrypto/#JsonWebKey-dictionary
  11. struct RsaOtherPrimesInfo {
  12. Optional<String> r;
  13. Optional<String> d;
  14. Optional<String> t;
  15. };
  16. // https://w3c.github.io/webcrypto/#JsonWebKey-dictionary
  17. struct JsonWebKey {
  18. Optional<String> kty;
  19. Optional<String> use;
  20. Optional<Vector<String>> key_ops;
  21. Optional<String> alg;
  22. Optional<bool> ext;
  23. Optional<String> crv;
  24. Optional<String> x;
  25. Optional<String> y;
  26. Optional<String> d;
  27. Optional<String> n;
  28. Optional<String> e;
  29. Optional<String> p;
  30. Optional<String> q;
  31. Optional<String> dp;
  32. Optional<String> dq;
  33. Optional<String> qi;
  34. Optional<Vector<RsaOtherPrimesInfo>> oth;
  35. Optional<String> k;
  36. };
  37. // https://w3c.github.io/webcrypto/#dfn-Algorithm
  38. struct Algorithm {
  39. String name;
  40. };
  41. // https://w3c.github.io/webcrypto/#key-algorithm-dictionary
  42. class KeyAlgorithm : public JS::Object {
  43. JS_OBJECT(KeyAlgorithm, Object);
  44. JS_DECLARE_ALLOCATOR(KeyAlgorithm);
  45. public:
  46. static JS::NonnullGCPtr<KeyAlgorithm> create(JS::Realm&);
  47. virtual ~KeyAlgorithm() override = default;
  48. String const& name() const { return m_name; }
  49. void set_name(String name) { m_name = move(name); }
  50. private:
  51. KeyAlgorithm(JS::Realm&);
  52. virtual void initialize(JS::Realm&) override;
  53. JS_DECLARE_NATIVE_FUNCTION(name_getter);
  54. String m_name;
  55. };
  56. // https://w3c.github.io/webcrypto/#pbkdf2-params
  57. struct Pbkdf2Params {
  58. JS::Handle<WebIDL::BufferSource> salt;
  59. u32 iterations;
  60. Variant<JS::Handle<JS::Object>, String> hash;
  61. };
  62. };