/work/obj-fuzz/dist/include/mozilla/dom/SubtleCrypto.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_SubtleCrypto_h |
8 | | #define mozilla_dom_SubtleCrypto_h |
9 | | |
10 | | #include "nsCycleCollectionParticipant.h" |
11 | | #include "nsWrapperCache.h" |
12 | | #include "nsIGlobalObject.h" |
13 | | #include "mozilla/dom/CryptoKey.h" |
14 | | #include "js/TypeDecls.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | class ObjectOrString; |
20 | | class Promise; |
21 | | |
22 | | typedef ArrayBufferViewOrArrayBuffer CryptoOperationData; |
23 | | |
24 | | class SubtleCrypto final : public nsISupports, |
25 | | public nsWrapperCache |
26 | | { |
27 | 0 | ~SubtleCrypto() {} |
28 | | |
29 | | public: |
30 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
31 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SubtleCrypto) |
32 | | |
33 | | public: |
34 | | explicit SubtleCrypto(nsIGlobalObject* aParent); |
35 | | |
36 | | nsIGlobalObject* GetParentObject() const |
37 | 0 | { |
38 | 0 | return mParent; |
39 | 0 | } |
40 | | |
41 | | virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
42 | | |
43 | | already_AddRefed<Promise> Encrypt(JSContext* cx, |
44 | | const ObjectOrString& algorithm, |
45 | | CryptoKey& key, |
46 | | const CryptoOperationData& data, |
47 | | ErrorResult& aRv); |
48 | | |
49 | | already_AddRefed<Promise> Decrypt(JSContext* cx, |
50 | | const ObjectOrString& algorithm, |
51 | | CryptoKey& key, |
52 | | const CryptoOperationData& data, |
53 | | ErrorResult& aRv); |
54 | | |
55 | | already_AddRefed<Promise> Sign(JSContext* cx, |
56 | | const ObjectOrString& algorithm, |
57 | | CryptoKey& key, |
58 | | const CryptoOperationData& data, |
59 | | ErrorResult& aRv); |
60 | | |
61 | | already_AddRefed<Promise> Verify(JSContext* cx, |
62 | | const ObjectOrString& algorithm, |
63 | | CryptoKey& key, |
64 | | const CryptoOperationData& signature, |
65 | | const CryptoOperationData& data, |
66 | | ErrorResult& aRv); |
67 | | |
68 | | already_AddRefed<Promise> Digest(JSContext* cx, |
69 | | const ObjectOrString& aAlgorithm, |
70 | | const CryptoOperationData& aData, |
71 | | ErrorResult& aRv); |
72 | | |
73 | | already_AddRefed<Promise> ImportKey(JSContext* cx, |
74 | | const nsAString& format, |
75 | | JS::Handle<JSObject*> keyData, |
76 | | const ObjectOrString& algorithm, |
77 | | bool extractable, |
78 | | const Sequence<nsString>& keyUsages, |
79 | | ErrorResult& aRv); |
80 | | |
81 | | already_AddRefed<Promise> ExportKey(const nsAString& format, CryptoKey& key, |
82 | | ErrorResult& aRv); |
83 | | |
84 | | already_AddRefed<Promise> GenerateKey(JSContext* cx, |
85 | | const ObjectOrString& algorithm, |
86 | | bool extractable, |
87 | | const Sequence<nsString>& keyUsages, |
88 | | ErrorResult& aRv); |
89 | | |
90 | | already_AddRefed<Promise> DeriveKey(JSContext* cx, |
91 | | const ObjectOrString& algorithm, |
92 | | CryptoKey& baseKey, |
93 | | const ObjectOrString& derivedKeyType, |
94 | | bool extractable, |
95 | | const Sequence<nsString>& keyUsages, |
96 | | ErrorResult& aRv); |
97 | | |
98 | | already_AddRefed<Promise> DeriveBits(JSContext* cx, |
99 | | const ObjectOrString& algorithm, |
100 | | CryptoKey& baseKey, |
101 | | uint32_t length, |
102 | | ErrorResult& aRv); |
103 | | |
104 | | already_AddRefed<Promise> WrapKey(JSContext* cx, |
105 | | const nsAString& format, |
106 | | CryptoKey& key, |
107 | | CryptoKey& wrappingKey, |
108 | | const ObjectOrString& wrapAlgorithm, |
109 | | ErrorResult& aRv); |
110 | | |
111 | | already_AddRefed<Promise> UnwrapKey(JSContext* cx, |
112 | | const nsAString& format, |
113 | | const ArrayBufferViewOrArrayBuffer& wrappedKey, |
114 | | CryptoKey& unwrappingKey, |
115 | | const ObjectOrString& unwrapAlgorithm, |
116 | | const ObjectOrString& unwrappedKeyAlgorithm, |
117 | | bool extractable, |
118 | | const Sequence<nsString>& keyUsages, |
119 | | ErrorResult& aRv); |
120 | | |
121 | | private: |
122 | | nsCOMPtr<nsIGlobalObject> mParent; |
123 | | }; |
124 | | |
125 | | } // namespace dom |
126 | | } // namespace mozilla |
127 | | |
128 | | #endif // mozilla_dom_SubtleCrypto_h |