/work/obj-fuzz/dist/include/mozilla/dom/SubtleCryptoBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SubtleCrypto.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_SubtleCryptoBinding_h |
4 | | #define mozilla_dom_SubtleCryptoBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "SubtleCryptoBinding.h" |
8 | | #include "js/RootingAPI.h" |
9 | | #include "jspubtd.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/BindingUtils.h" |
13 | | #include "mozilla/dom/CryptoKey.h" |
14 | | #include "mozilla/dom/FakeString.h" |
15 | | #include "mozilla/dom/Nullable.h" |
16 | | #include "mozilla/dom/PrototypeList.h" |
17 | | #include "mozilla/dom/TypedArray.h" |
18 | | #include "mozilla/dom/UnionMember.h" |
19 | | #include "mozilla/dom/UnionTypes.h" |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | struct AesCbcParamsAtoms; |
25 | | struct AesCtrParamsAtoms; |
26 | | struct AesDerivedKeyParamsAtoms; |
27 | | struct AesGcmParamsAtoms; |
28 | | struct AesKeyGenParamsAtoms; |
29 | | struct AlgorithmAtoms; |
30 | | class ArrayBufferViewOrArrayBuffer; |
31 | | class CryptoKey; |
32 | | struct CryptoKeyAtoms; |
33 | | struct CryptoKeyPairAtoms; |
34 | | struct DhImportKeyParamsAtoms; |
35 | | struct DhKeyDeriveParamsAtoms; |
36 | | struct DhKeyGenParamsAtoms; |
37 | | struct EcKeyGenParamsAtoms; |
38 | | struct EcKeyImportParamsAtoms; |
39 | | struct EcdhKeyDeriveParamsAtoms; |
40 | | struct EcdsaParamsAtoms; |
41 | | struct HkdfParamsAtoms; |
42 | | struct HmacDerivedKeyParamsAtoms; |
43 | | struct HmacImportParamsAtoms; |
44 | | struct HmacKeyGenParamsAtoms; |
45 | | struct JsonWebKeyAtoms; |
46 | | struct NativePropertyHooks; |
47 | | class ObjectOrString; |
48 | | class OwningArrayBufferViewOrArrayBuffer; |
49 | | class OwningObjectOrString; |
50 | | struct Pbkdf2ParamsAtoms; |
51 | | class ProtoAndIfaceCache; |
52 | | struct RsaHashedImportParamsAtoms; |
53 | | struct RsaHashedKeyGenParamsAtoms; |
54 | | struct RsaOaepParamsAtoms; |
55 | | struct RsaOtherPrimesInfo; |
56 | | struct RsaOtherPrimesInfoAtoms; |
57 | | struct RsaPssParamsAtoms; |
58 | | class SubtleCrypto; |
59 | | struct SubtleCryptoAtoms; |
60 | | |
61 | | } // namespace dom |
62 | | } // namespace mozilla |
63 | | |
64 | | namespace mozilla { |
65 | | namespace dom { |
66 | | |
67 | | struct Algorithm : public DictionaryBase |
68 | | { |
69 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
70 | | |
71 | | Algorithm(); |
72 | | |
73 | | explicit inline Algorithm(const FastDictionaryInitializer& ) |
74 | 0 | { |
75 | 0 | // Do nothing here; this is used by our "Fast" subclass |
76 | 0 | } |
77 | | |
78 | | explicit inline Algorithm(const Algorithm& aOther) |
79 | 0 | { |
80 | 0 | *this = aOther; |
81 | 0 | } |
82 | | |
83 | | bool |
84 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
85 | | |
86 | | bool |
87 | | Init(const nsAString& aJSON); |
88 | | |
89 | | bool |
90 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
91 | | |
92 | | bool |
93 | | ToJSON(nsAString& aJSON) const; |
94 | | |
95 | | void |
96 | | TraceDictionary(JSTracer* trc); |
97 | | |
98 | | Algorithm& |
99 | | operator=(const Algorithm& aOther); |
100 | | |
101 | | private: |
102 | | static bool |
103 | | InitIds(JSContext* cx, AlgorithmAtoms* atomsCache); |
104 | | }; |
105 | | |
106 | | namespace binding_detail { |
107 | | struct FastAlgorithm : public Algorithm |
108 | | { |
109 | | inline FastAlgorithm() |
110 | | : Algorithm(FastDictionaryInitializer()) |
111 | 0 | { |
112 | 0 | // Doesn't matter what int we pass to the parent constructor |
113 | 0 | } |
114 | | }; |
115 | | } // namespace binding_detail |
116 | | |
117 | | |
118 | | struct CryptoKeyPair : public DictionaryBase |
119 | | { |
120 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::CryptoKey> mPrivateKey; |
121 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::CryptoKey> mPublicKey; |
122 | | |
123 | | CryptoKeyPair(); |
124 | | |
125 | | explicit inline CryptoKeyPair(const FastDictionaryInitializer& ) |
126 | 0 | { |
127 | 0 | // Do nothing here; this is used by our "Fast" subclass |
128 | 0 | } |
129 | | |
130 | | explicit inline CryptoKeyPair(const CryptoKeyPair& aOther) |
131 | 0 | { |
132 | 0 | *this = aOther; |
133 | 0 | } |
134 | | |
135 | | bool |
136 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
137 | | |
138 | | bool |
139 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
140 | | |
141 | | void |
142 | | TraceDictionary(JSTracer* trc); |
143 | | |
144 | | inline void |
145 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
146 | 0 | { |
147 | 0 | ImplCycleCollectionTraverse(aCallback, mPrivateKey, "mPrivateKey", aFlags); |
148 | 0 | ImplCycleCollectionTraverse(aCallback, mPublicKey, "mPublicKey", aFlags); |
149 | 0 | } |
150 | | |
151 | | inline void |
152 | | UnlinkForCC() |
153 | 0 | { |
154 | 0 | ImplCycleCollectionUnlink(mPrivateKey); |
155 | 0 | ImplCycleCollectionUnlink(mPublicKey); |
156 | 0 | } |
157 | | |
158 | | CryptoKeyPair& |
159 | | operator=(const CryptoKeyPair& aOther); |
160 | | |
161 | | private: |
162 | | static bool |
163 | | InitIds(JSContext* cx, CryptoKeyPairAtoms* atomsCache); |
164 | | }; |
165 | | |
166 | | namespace binding_detail { |
167 | | struct FastCryptoKeyPair : public CryptoKeyPair |
168 | | { |
169 | | inline FastCryptoKeyPair() |
170 | | : CryptoKeyPair(FastDictionaryInitializer()) |
171 | 0 | { |
172 | 0 | // Doesn't matter what int we pass to the parent constructor |
173 | 0 | } |
174 | | }; |
175 | | } // namespace binding_detail |
176 | | |
177 | | |
178 | | class ObjectOrString |
179 | | { |
180 | | friend class ObjectOrStringArgument; |
181 | | enum Type |
182 | | { |
183 | | eUninitialized, |
184 | | eObject, |
185 | | eString |
186 | | }; |
187 | | |
188 | | union Value |
189 | | { |
190 | | UnionMember<JS::Rooted<JSObject*> > mObject; |
191 | | UnionMember<binding_detail::FakeString > mString; |
192 | | |
193 | | }; |
194 | | |
195 | | Type mType; |
196 | | Value mValue; |
197 | | |
198 | | ObjectOrString(const ObjectOrString&) = delete; |
199 | | ObjectOrString& operator=(const ObjectOrString&) = delete; |
200 | | public: |
201 | | explicit inline ObjectOrString() |
202 | | : mType(eUninitialized) |
203 | 0 | { |
204 | 0 | } |
205 | | |
206 | | inline ~ObjectOrString() |
207 | 0 | { |
208 | 0 | Uninit(); |
209 | 0 | } |
210 | | |
211 | | inline bool |
212 | | IsObject() const |
213 | 0 | { |
214 | 0 | return mType == eObject; |
215 | 0 | } |
216 | | |
217 | | inline JS::Rooted<JSObject*>& |
218 | | GetAsObject() |
219 | 0 | { |
220 | 0 | MOZ_ASSERT(IsObject(), "Wrong type!"); |
221 | 0 | return mValue.mObject.Value(); |
222 | 0 | } |
223 | | |
224 | | inline JSObject* |
225 | | GetAsObject() const |
226 | 0 | { |
227 | 0 | MOZ_ASSERT(IsObject(), "Wrong type!"); |
228 | 0 | return mValue.mObject.Value(); |
229 | 0 | } |
230 | | |
231 | | inline binding_detail::FakeString& |
232 | | RawSetAsString() |
233 | 0 | { |
234 | 0 | if (mType == eString) { |
235 | 0 | return mValue.mString.Value(); |
236 | 0 | } |
237 | 0 | MOZ_ASSERT(mType == eUninitialized); |
238 | 0 | mType = eString; |
239 | 0 | return mValue.mString.SetValue(); |
240 | 0 | } |
241 | | |
242 | | inline binding_detail::FakeString& |
243 | | SetAsString() |
244 | 0 | { |
245 | 0 | if (mType == eString) { |
246 | 0 | return mValue.mString.Value(); |
247 | 0 | } |
248 | 0 | MOZ_ASSERT(mType != eObject, "This will not play well with Rooted"); |
249 | 0 | Uninit(); |
250 | 0 | mType = eString; |
251 | 0 | return mValue.mString.SetValue(); |
252 | 0 | } |
253 | | |
254 | | inline bool |
255 | | IsString() const |
256 | 0 | { |
257 | 0 | return mType == eString; |
258 | 0 | } |
259 | | |
260 | | inline binding_detail::FakeString& |
261 | | GetAsString() |
262 | 0 | { |
263 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
264 | 0 | return mValue.mString.Value(); |
265 | 0 | } |
266 | | |
267 | | inline const nsAString& |
268 | | GetAsString() const |
269 | 0 | { |
270 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
271 | 0 | return mValue.mString.Value(); |
272 | 0 | } |
273 | | |
274 | | inline void |
275 | | Uninit() |
276 | | { |
277 | | switch (mType) { |
278 | | case eUninitialized: { |
279 | | break; |
280 | | } |
281 | | case eObject: { |
282 | | DestroyObject(); |
283 | | break; |
284 | | } |
285 | | case eString: { |
286 | | DestroyString(); |
287 | | break; |
288 | | } |
289 | | } |
290 | | } |
291 | | |
292 | | bool |
293 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
294 | | |
295 | | private: |
296 | | inline void |
297 | | DestroyObject() |
298 | 0 | { |
299 | 0 | MOZ_ASSERT(IsObject(), "Wrong type!"); |
300 | 0 | mValue.mObject.Destroy(); |
301 | 0 | mType = eUninitialized; |
302 | 0 | } |
303 | | |
304 | | inline void |
305 | | DestroyString() |
306 | 0 | { |
307 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
308 | 0 | mValue.mString.Destroy(); |
309 | 0 | mType = eUninitialized; |
310 | 0 | } |
311 | | }; |
312 | | |
313 | | |
314 | | class OwningObjectOrString : public AllOwningUnionBase |
315 | | { |
316 | | friend void ImplCycleCollectionUnlink(OwningObjectOrString& aUnion); |
317 | | enum Type |
318 | | { |
319 | | eUninitialized, |
320 | | eObject, |
321 | | eString |
322 | | }; |
323 | | |
324 | | union Value |
325 | | { |
326 | | UnionMember<JSObject* > mObject; |
327 | | UnionMember<nsString > mString; |
328 | | |
329 | | }; |
330 | | |
331 | | Type mType; |
332 | | Value mValue; |
333 | | |
334 | | OwningObjectOrString(const OwningObjectOrString&) = delete; |
335 | | OwningObjectOrString& operator=(const OwningObjectOrString&) = delete; |
336 | | public: |
337 | | explicit inline OwningObjectOrString() |
338 | | : mType(eUninitialized) |
339 | 0 | { |
340 | 0 | } |
341 | | |
342 | | inline ~OwningObjectOrString() |
343 | 0 | { |
344 | 0 | Uninit(); |
345 | 0 | } |
346 | | |
347 | | JSObject*& |
348 | | RawSetAsObject(); |
349 | | |
350 | | JSObject*& |
351 | | SetAsObject(); |
352 | | |
353 | | inline bool |
354 | | SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false) |
355 | 0 | { |
356 | 0 | MOZ_ASSERT(mType == eUninitialized); |
357 | 0 | mValue.mObject.SetValue(obj); |
358 | 0 | mType = eObject; |
359 | 0 | if (passedToJSImpl && !CallerSubsumes(obj)) { |
360 | 0 | ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s"); |
361 | 0 | return false; |
362 | 0 | } |
363 | 0 | return true; |
364 | 0 | } |
365 | | |
366 | | inline bool |
367 | | IsObject() const |
368 | 0 | { |
369 | 0 | return mType == eObject; |
370 | 0 | } |
371 | | |
372 | | inline JSObject*& |
373 | | GetAsObject() |
374 | 0 | { |
375 | 0 | MOZ_ASSERT(IsObject(), "Wrong type!"); |
376 | 0 | return mValue.mObject.Value(); |
377 | 0 | } |
378 | | |
379 | | inline JSObject* const & |
380 | | GetAsObject() const |
381 | 0 | { |
382 | 0 | MOZ_ASSERT(IsObject(), "Wrong type!"); |
383 | 0 | return mValue.mObject.Value(); |
384 | 0 | } |
385 | | |
386 | | nsString& |
387 | | RawSetAsString(); |
388 | | |
389 | | nsString& |
390 | | SetAsString(); |
391 | | |
392 | | bool |
393 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
394 | | |
395 | | inline void |
396 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
397 | 0 | { |
398 | 0 | RawSetAsString().Assign(aData, aLength); |
399 | 0 | } |
400 | | |
401 | | inline bool |
402 | | IsString() const |
403 | 0 | { |
404 | 0 | return mType == eString; |
405 | 0 | } |
406 | | |
407 | | inline nsString& |
408 | | GetAsString() |
409 | 0 | { |
410 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
411 | 0 | return mValue.mString.Value(); |
412 | 0 | } |
413 | | |
414 | | inline nsString const & |
415 | | GetAsString() const |
416 | 0 | { |
417 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
418 | 0 | return mValue.mString.Value(); |
419 | 0 | } |
420 | | |
421 | | void |
422 | | Uninit(); |
423 | | |
424 | | bool |
425 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
426 | | |
427 | | void |
428 | | TraceUnion(JSTracer* trc); |
429 | | |
430 | | private: |
431 | | void |
432 | | DestroyObject(); |
433 | | |
434 | | void |
435 | | DestroyString(); |
436 | | }; |
437 | | |
438 | | |
439 | | struct RsaOtherPrimesInfo : public DictionaryBase |
440 | | { |
441 | | MOZ_INIT_OUTSIDE_CTOR nsString mD; |
442 | | MOZ_INIT_OUTSIDE_CTOR nsString mR; |
443 | | MOZ_INIT_OUTSIDE_CTOR nsString mT; |
444 | | |
445 | | RsaOtherPrimesInfo(); |
446 | | |
447 | | explicit inline RsaOtherPrimesInfo(const FastDictionaryInitializer& ) |
448 | 0 | { |
449 | 0 | // Do nothing here; this is used by our "Fast" subclass |
450 | 0 | } |
451 | | |
452 | | explicit inline RsaOtherPrimesInfo(const RsaOtherPrimesInfo& aOther) |
453 | 0 | { |
454 | 0 | *this = aOther; |
455 | 0 | } |
456 | | |
457 | | bool |
458 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
459 | | |
460 | | bool |
461 | | Init(const nsAString& aJSON); |
462 | | |
463 | | bool |
464 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
465 | | |
466 | | bool |
467 | | ToJSON(nsAString& aJSON) const; |
468 | | |
469 | | void |
470 | | TraceDictionary(JSTracer* trc); |
471 | | |
472 | | RsaOtherPrimesInfo& |
473 | | operator=(const RsaOtherPrimesInfo& aOther); |
474 | | |
475 | | private: |
476 | | static bool |
477 | | InitIds(JSContext* cx, RsaOtherPrimesInfoAtoms* atomsCache); |
478 | | }; |
479 | | |
480 | | namespace binding_detail { |
481 | | struct FastRsaOtherPrimesInfo : public RsaOtherPrimesInfo |
482 | | { |
483 | | inline FastRsaOtherPrimesInfo() |
484 | | : RsaOtherPrimesInfo(FastDictionaryInitializer()) |
485 | 0 | { |
486 | 0 | // Doesn't matter what int we pass to the parent constructor |
487 | 0 | } |
488 | | }; |
489 | | } // namespace binding_detail |
490 | | |
491 | | |
492 | | struct AesCbcParams : public Algorithm |
493 | | { |
494 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mIv; |
495 | | |
496 | | AesCbcParams(); |
497 | | |
498 | | explicit inline AesCbcParams(const FastDictionaryInitializer& ) |
499 | | : Algorithm(FastDictionaryInitializer()) |
500 | 0 | { |
501 | 0 | // Do nothing here; this is used by our "Fast" subclass |
502 | 0 | } |
503 | | |
504 | | private: |
505 | | AesCbcParams(const AesCbcParams&) = delete; |
506 | | AesCbcParams& operator=(const AesCbcParams&) = delete; |
507 | | |
508 | | static bool |
509 | | InitIds(JSContext* cx, AesCbcParamsAtoms* atomsCache); |
510 | | |
511 | | public: |
512 | | bool |
513 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
514 | | |
515 | | bool |
516 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
517 | | |
518 | | void |
519 | | TraceDictionary(JSTracer* trc); |
520 | | }; |
521 | | |
522 | | namespace binding_detail { |
523 | | struct FastAesCbcParams : public AesCbcParams |
524 | | { |
525 | | inline FastAesCbcParams() |
526 | | : AesCbcParams(FastDictionaryInitializer()) |
527 | 0 | { |
528 | 0 | // Doesn't matter what int we pass to the parent constructor |
529 | 0 | } |
530 | | }; |
531 | | } // namespace binding_detail |
532 | | |
533 | | |
534 | | struct AesCtrParams : public Algorithm |
535 | | { |
536 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mCounter; |
537 | | MOZ_INIT_OUTSIDE_CTOR uint8_t mLength; |
538 | | |
539 | | AesCtrParams(); |
540 | | |
541 | | explicit inline AesCtrParams(const FastDictionaryInitializer& ) |
542 | | : Algorithm(FastDictionaryInitializer()) |
543 | 0 | { |
544 | 0 | // Do nothing here; this is used by our "Fast" subclass |
545 | 0 | } |
546 | | |
547 | | private: |
548 | | AesCtrParams(const AesCtrParams&) = delete; |
549 | | AesCtrParams& operator=(const AesCtrParams&) = delete; |
550 | | |
551 | | static bool |
552 | | InitIds(JSContext* cx, AesCtrParamsAtoms* atomsCache); |
553 | | |
554 | | public: |
555 | | bool |
556 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
557 | | |
558 | | bool |
559 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
560 | | |
561 | | void |
562 | | TraceDictionary(JSTracer* trc); |
563 | | }; |
564 | | |
565 | | namespace binding_detail { |
566 | | struct FastAesCtrParams : public AesCtrParams |
567 | | { |
568 | | inline FastAesCtrParams() |
569 | | : AesCtrParams(FastDictionaryInitializer()) |
570 | 0 | { |
571 | 0 | // Doesn't matter what int we pass to the parent constructor |
572 | 0 | } |
573 | | }; |
574 | | } // namespace binding_detail |
575 | | |
576 | | |
577 | | struct AesDerivedKeyParams : public Algorithm |
578 | | { |
579 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mLength; |
580 | | |
581 | | AesDerivedKeyParams(); |
582 | | |
583 | | explicit inline AesDerivedKeyParams(const FastDictionaryInitializer& ) |
584 | | : Algorithm(FastDictionaryInitializer()) |
585 | 0 | { |
586 | 0 | // Do nothing here; this is used by our "Fast" subclass |
587 | 0 | } |
588 | | |
589 | | explicit inline AesDerivedKeyParams(const AesDerivedKeyParams& aOther) |
590 | 0 | { |
591 | 0 | *this = aOther; |
592 | 0 | } |
593 | | |
594 | | bool |
595 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
596 | | |
597 | | bool |
598 | | Init(const nsAString& aJSON); |
599 | | |
600 | | bool |
601 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
602 | | |
603 | | bool |
604 | | ToJSON(nsAString& aJSON) const; |
605 | | |
606 | | void |
607 | | TraceDictionary(JSTracer* trc); |
608 | | |
609 | | AesDerivedKeyParams& |
610 | | operator=(const AesDerivedKeyParams& aOther); |
611 | | |
612 | | private: |
613 | | static bool |
614 | | InitIds(JSContext* cx, AesDerivedKeyParamsAtoms* atomsCache); |
615 | | }; |
616 | | |
617 | | namespace binding_detail { |
618 | | struct FastAesDerivedKeyParams : public AesDerivedKeyParams |
619 | | { |
620 | | inline FastAesDerivedKeyParams() |
621 | | : AesDerivedKeyParams(FastDictionaryInitializer()) |
622 | 0 | { |
623 | 0 | // Doesn't matter what int we pass to the parent constructor |
624 | 0 | } |
625 | | }; |
626 | | } // namespace binding_detail |
627 | | |
628 | | |
629 | | struct AesGcmParams : public Algorithm |
630 | | { |
631 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningArrayBufferViewOrArrayBuffer> mAdditionalData; |
632 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mIv; |
633 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint8_t> mTagLength; |
634 | | |
635 | | AesGcmParams(); |
636 | | |
637 | | explicit inline AesGcmParams(const FastDictionaryInitializer& ) |
638 | | : Algorithm(FastDictionaryInitializer()) |
639 | 0 | { |
640 | 0 | // Do nothing here; this is used by our "Fast" subclass |
641 | 0 | } |
642 | | |
643 | | private: |
644 | | AesGcmParams(const AesGcmParams&) = delete; |
645 | | AesGcmParams& operator=(const AesGcmParams&) = delete; |
646 | | |
647 | | static bool |
648 | | InitIds(JSContext* cx, AesGcmParamsAtoms* atomsCache); |
649 | | |
650 | | public: |
651 | | bool |
652 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
653 | | |
654 | | bool |
655 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
656 | | |
657 | | void |
658 | | TraceDictionary(JSTracer* trc); |
659 | | }; |
660 | | |
661 | | namespace binding_detail { |
662 | | struct FastAesGcmParams : public AesGcmParams |
663 | | { |
664 | | inline FastAesGcmParams() |
665 | | : AesGcmParams(FastDictionaryInitializer()) |
666 | 0 | { |
667 | 0 | // Doesn't matter what int we pass to the parent constructor |
668 | 0 | } |
669 | | }; |
670 | | } // namespace binding_detail |
671 | | |
672 | | |
673 | | struct AesKeyGenParams : public Algorithm |
674 | | { |
675 | | MOZ_INIT_OUTSIDE_CTOR uint16_t mLength; |
676 | | |
677 | | AesKeyGenParams(); |
678 | | |
679 | | explicit inline AesKeyGenParams(const FastDictionaryInitializer& ) |
680 | | : Algorithm(FastDictionaryInitializer()) |
681 | 0 | { |
682 | 0 | // Do nothing here; this is used by our "Fast" subclass |
683 | 0 | } |
684 | | |
685 | | explicit inline AesKeyGenParams(const AesKeyGenParams& aOther) |
686 | 0 | { |
687 | 0 | *this = aOther; |
688 | 0 | } |
689 | | |
690 | | bool |
691 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
692 | | |
693 | | bool |
694 | | Init(const nsAString& aJSON); |
695 | | |
696 | | bool |
697 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
698 | | |
699 | | bool |
700 | | ToJSON(nsAString& aJSON) const; |
701 | | |
702 | | void |
703 | | TraceDictionary(JSTracer* trc); |
704 | | |
705 | | AesKeyGenParams& |
706 | | operator=(const AesKeyGenParams& aOther); |
707 | | |
708 | | private: |
709 | | static bool |
710 | | InitIds(JSContext* cx, AesKeyGenParamsAtoms* atomsCache); |
711 | | }; |
712 | | |
713 | | namespace binding_detail { |
714 | | struct FastAesKeyGenParams : public AesKeyGenParams |
715 | | { |
716 | | inline FastAesKeyGenParams() |
717 | | : AesKeyGenParams(FastDictionaryInitializer()) |
718 | 0 | { |
719 | 0 | // Doesn't matter what int we pass to the parent constructor |
720 | 0 | } |
721 | | }; |
722 | | } // namespace binding_detail |
723 | | |
724 | | |
725 | | struct DhImportKeyParams : public Algorithm |
726 | | { |
727 | | MOZ_INIT_OUTSIDE_CTOR Uint8Array mGenerator; |
728 | | MOZ_INIT_OUTSIDE_CTOR Uint8Array mPrime; |
729 | | |
730 | | DhImportKeyParams(); |
731 | | |
732 | | explicit inline DhImportKeyParams(const FastDictionaryInitializer& ) |
733 | | : Algorithm(FastDictionaryInitializer()) |
734 | 0 | { |
735 | 0 | // Do nothing here; this is used by our "Fast" subclass |
736 | 0 | } |
737 | | |
738 | | private: |
739 | | DhImportKeyParams(const DhImportKeyParams&) = delete; |
740 | | DhImportKeyParams& operator=(const DhImportKeyParams&) = delete; |
741 | | |
742 | | static bool |
743 | | InitIds(JSContext* cx, DhImportKeyParamsAtoms* atomsCache); |
744 | | |
745 | | public: |
746 | | bool |
747 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
748 | | |
749 | | bool |
750 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
751 | | |
752 | | void |
753 | | TraceDictionary(JSTracer* trc); |
754 | | }; |
755 | | |
756 | | namespace binding_detail { |
757 | | struct FastDhImportKeyParams : public DhImportKeyParams |
758 | | { |
759 | | inline FastDhImportKeyParams() |
760 | | : DhImportKeyParams(FastDictionaryInitializer()) |
761 | 0 | { |
762 | 0 | // Doesn't matter what int we pass to the parent constructor |
763 | 0 | } |
764 | | }; |
765 | | } // namespace binding_detail |
766 | | |
767 | | |
768 | | struct DhKeyDeriveParams : public Algorithm |
769 | | { |
770 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::CryptoKey> mPublic; |
771 | | |
772 | | DhKeyDeriveParams(); |
773 | | |
774 | | explicit inline DhKeyDeriveParams(const FastDictionaryInitializer& ) |
775 | | : Algorithm(FastDictionaryInitializer()) |
776 | 0 | { |
777 | 0 | // Do nothing here; this is used by our "Fast" subclass |
778 | 0 | } |
779 | | |
780 | | explicit inline DhKeyDeriveParams(const DhKeyDeriveParams& aOther) |
781 | 0 | { |
782 | 0 | *this = aOther; |
783 | 0 | } |
784 | | |
785 | | bool |
786 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
787 | | |
788 | | bool |
789 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
790 | | |
791 | | void |
792 | | TraceDictionary(JSTracer* trc); |
793 | | |
794 | | inline void |
795 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
796 | 0 | { |
797 | 0 | ImplCycleCollectionTraverse(aCallback, mPublic, "mPublic", aFlags); |
798 | 0 | } |
799 | | |
800 | | inline void |
801 | | UnlinkForCC() |
802 | 0 | { |
803 | 0 | ImplCycleCollectionUnlink(mPublic); |
804 | 0 | } |
805 | | |
806 | | DhKeyDeriveParams& |
807 | | operator=(const DhKeyDeriveParams& aOther); |
808 | | |
809 | | private: |
810 | | static bool |
811 | | InitIds(JSContext* cx, DhKeyDeriveParamsAtoms* atomsCache); |
812 | | }; |
813 | | |
814 | | namespace binding_detail { |
815 | | struct FastDhKeyDeriveParams : public DhKeyDeriveParams |
816 | | { |
817 | | inline FastDhKeyDeriveParams() |
818 | | : DhKeyDeriveParams(FastDictionaryInitializer()) |
819 | 0 | { |
820 | 0 | // Doesn't matter what int we pass to the parent constructor |
821 | 0 | } |
822 | | }; |
823 | | } // namespace binding_detail |
824 | | |
825 | | |
826 | | struct DhKeyGenParams : public Algorithm |
827 | | { |
828 | | MOZ_INIT_OUTSIDE_CTOR Uint8Array mGenerator; |
829 | | MOZ_INIT_OUTSIDE_CTOR Uint8Array mPrime; |
830 | | |
831 | | DhKeyGenParams(); |
832 | | |
833 | | explicit inline DhKeyGenParams(const FastDictionaryInitializer& ) |
834 | | : Algorithm(FastDictionaryInitializer()) |
835 | 0 | { |
836 | 0 | // Do nothing here; this is used by our "Fast" subclass |
837 | 0 | } |
838 | | |
839 | | private: |
840 | | DhKeyGenParams(const DhKeyGenParams&) = delete; |
841 | | DhKeyGenParams& operator=(const DhKeyGenParams&) = delete; |
842 | | |
843 | | static bool |
844 | | InitIds(JSContext* cx, DhKeyGenParamsAtoms* atomsCache); |
845 | | |
846 | | public: |
847 | | bool |
848 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
849 | | |
850 | | bool |
851 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
852 | | |
853 | | void |
854 | | TraceDictionary(JSTracer* trc); |
855 | | }; |
856 | | |
857 | | namespace binding_detail { |
858 | | struct FastDhKeyGenParams : public DhKeyGenParams |
859 | | { |
860 | | inline FastDhKeyGenParams() |
861 | | : DhKeyGenParams(FastDictionaryInitializer()) |
862 | 0 | { |
863 | 0 | // Doesn't matter what int we pass to the parent constructor |
864 | 0 | } |
865 | | }; |
866 | | } // namespace binding_detail |
867 | | |
868 | | |
869 | | struct EcKeyGenParams : public Algorithm |
870 | | { |
871 | | MOZ_INIT_OUTSIDE_CTOR nsString mNamedCurve; |
872 | | |
873 | | EcKeyGenParams(); |
874 | | |
875 | | explicit inline EcKeyGenParams(const FastDictionaryInitializer& ) |
876 | | : Algorithm(FastDictionaryInitializer()) |
877 | 0 | { |
878 | 0 | // Do nothing here; this is used by our "Fast" subclass |
879 | 0 | } |
880 | | |
881 | | explicit inline EcKeyGenParams(const EcKeyGenParams& aOther) |
882 | 0 | { |
883 | 0 | *this = aOther; |
884 | 0 | } |
885 | | |
886 | | bool |
887 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
888 | | |
889 | | bool |
890 | | Init(const nsAString& aJSON); |
891 | | |
892 | | bool |
893 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
894 | | |
895 | | bool |
896 | | ToJSON(nsAString& aJSON) const; |
897 | | |
898 | | void |
899 | | TraceDictionary(JSTracer* trc); |
900 | | |
901 | | EcKeyGenParams& |
902 | | operator=(const EcKeyGenParams& aOther); |
903 | | |
904 | | private: |
905 | | static bool |
906 | | InitIds(JSContext* cx, EcKeyGenParamsAtoms* atomsCache); |
907 | | }; |
908 | | |
909 | | namespace binding_detail { |
910 | | struct FastEcKeyGenParams : public EcKeyGenParams |
911 | | { |
912 | | inline FastEcKeyGenParams() |
913 | | : EcKeyGenParams(FastDictionaryInitializer()) |
914 | 0 | { |
915 | 0 | // Doesn't matter what int we pass to the parent constructor |
916 | 0 | } |
917 | | }; |
918 | | } // namespace binding_detail |
919 | | |
920 | | |
921 | | struct EcKeyImportParams : public Algorithm |
922 | | { |
923 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mNamedCurve; |
924 | | |
925 | | EcKeyImportParams(); |
926 | | |
927 | | explicit inline EcKeyImportParams(const FastDictionaryInitializer& ) |
928 | | : Algorithm(FastDictionaryInitializer()) |
929 | 0 | { |
930 | 0 | // Do nothing here; this is used by our "Fast" subclass |
931 | 0 | } |
932 | | |
933 | | explicit inline EcKeyImportParams(const EcKeyImportParams& aOther) |
934 | 0 | { |
935 | 0 | *this = aOther; |
936 | 0 | } |
937 | | |
938 | | bool |
939 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
940 | | |
941 | | bool |
942 | | Init(const nsAString& aJSON); |
943 | | |
944 | | bool |
945 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
946 | | |
947 | | bool |
948 | | ToJSON(nsAString& aJSON) const; |
949 | | |
950 | | void |
951 | | TraceDictionary(JSTracer* trc); |
952 | | |
953 | | EcKeyImportParams& |
954 | | operator=(const EcKeyImportParams& aOther); |
955 | | |
956 | | private: |
957 | | static bool |
958 | | InitIds(JSContext* cx, EcKeyImportParamsAtoms* atomsCache); |
959 | | }; |
960 | | |
961 | | namespace binding_detail { |
962 | | struct FastEcKeyImportParams : public EcKeyImportParams |
963 | | { |
964 | | inline FastEcKeyImportParams() |
965 | | : EcKeyImportParams(FastDictionaryInitializer()) |
966 | 0 | { |
967 | 0 | // Doesn't matter what int we pass to the parent constructor |
968 | 0 | } |
969 | | }; |
970 | | } // namespace binding_detail |
971 | | |
972 | | |
973 | | struct EcdhKeyDeriveParams : public Algorithm |
974 | | { |
975 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::CryptoKey> mPublic; |
976 | | |
977 | | EcdhKeyDeriveParams(); |
978 | | |
979 | | explicit inline EcdhKeyDeriveParams(const FastDictionaryInitializer& ) |
980 | | : Algorithm(FastDictionaryInitializer()) |
981 | 0 | { |
982 | 0 | // Do nothing here; this is used by our "Fast" subclass |
983 | 0 | } |
984 | | |
985 | | explicit inline EcdhKeyDeriveParams(const EcdhKeyDeriveParams& aOther) |
986 | 0 | { |
987 | 0 | *this = aOther; |
988 | 0 | } |
989 | | |
990 | | bool |
991 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
992 | | |
993 | | bool |
994 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
995 | | |
996 | | void |
997 | | TraceDictionary(JSTracer* trc); |
998 | | |
999 | | inline void |
1000 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
1001 | 0 | { |
1002 | 0 | ImplCycleCollectionTraverse(aCallback, mPublic, "mPublic", aFlags); |
1003 | 0 | } |
1004 | | |
1005 | | inline void |
1006 | | UnlinkForCC() |
1007 | 0 | { |
1008 | 0 | ImplCycleCollectionUnlink(mPublic); |
1009 | 0 | } |
1010 | | |
1011 | | EcdhKeyDeriveParams& |
1012 | | operator=(const EcdhKeyDeriveParams& aOther); |
1013 | | |
1014 | | private: |
1015 | | static bool |
1016 | | InitIds(JSContext* cx, EcdhKeyDeriveParamsAtoms* atomsCache); |
1017 | | }; |
1018 | | |
1019 | | namespace binding_detail { |
1020 | | struct FastEcdhKeyDeriveParams : public EcdhKeyDeriveParams |
1021 | | { |
1022 | | inline FastEcdhKeyDeriveParams() |
1023 | | : EcdhKeyDeriveParams(FastDictionaryInitializer()) |
1024 | 0 | { |
1025 | 0 | // Doesn't matter what int we pass to the parent constructor |
1026 | 0 | } |
1027 | | }; |
1028 | | } // namespace binding_detail |
1029 | | |
1030 | | |
1031 | | struct EcdsaParams : public Algorithm |
1032 | | { |
1033 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1034 | | |
1035 | | EcdsaParams(); |
1036 | | |
1037 | | explicit inline EcdsaParams(const FastDictionaryInitializer& ) |
1038 | | : Algorithm(FastDictionaryInitializer()) |
1039 | 0 | { |
1040 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1041 | 0 | } |
1042 | | |
1043 | | private: |
1044 | | EcdsaParams(const EcdsaParams&) = delete; |
1045 | | EcdsaParams& operator=(const EcdsaParams&) = delete; |
1046 | | |
1047 | | static bool |
1048 | | InitIds(JSContext* cx, EcdsaParamsAtoms* atomsCache); |
1049 | | |
1050 | | public: |
1051 | | bool |
1052 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1053 | | |
1054 | | bool |
1055 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1056 | | |
1057 | | void |
1058 | | TraceDictionary(JSTracer* trc); |
1059 | | }; |
1060 | | |
1061 | | namespace binding_detail { |
1062 | | struct FastEcdsaParams : public EcdsaParams |
1063 | | { |
1064 | | inline FastEcdsaParams() |
1065 | | : EcdsaParams(FastDictionaryInitializer()) |
1066 | 0 | { |
1067 | 0 | // Doesn't matter what int we pass to the parent constructor |
1068 | 0 | } |
1069 | | }; |
1070 | | } // namespace binding_detail |
1071 | | |
1072 | | |
1073 | | struct HkdfParams : public Algorithm |
1074 | | { |
1075 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1076 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mInfo; |
1077 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mSalt; |
1078 | | |
1079 | | HkdfParams(); |
1080 | | |
1081 | | explicit inline HkdfParams(const FastDictionaryInitializer& ) |
1082 | | : Algorithm(FastDictionaryInitializer()) |
1083 | 0 | { |
1084 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1085 | 0 | } |
1086 | | |
1087 | | private: |
1088 | | HkdfParams(const HkdfParams&) = delete; |
1089 | | HkdfParams& operator=(const HkdfParams&) = delete; |
1090 | | |
1091 | | static bool |
1092 | | InitIds(JSContext* cx, HkdfParamsAtoms* atomsCache); |
1093 | | |
1094 | | public: |
1095 | | bool |
1096 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1097 | | |
1098 | | bool |
1099 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1100 | | |
1101 | | void |
1102 | | TraceDictionary(JSTracer* trc); |
1103 | | }; |
1104 | | |
1105 | | namespace binding_detail { |
1106 | | struct FastHkdfParams : public HkdfParams |
1107 | | { |
1108 | | inline FastHkdfParams() |
1109 | | : HkdfParams(FastDictionaryInitializer()) |
1110 | 0 | { |
1111 | 0 | // Doesn't matter what int we pass to the parent constructor |
1112 | 0 | } |
1113 | | }; |
1114 | | } // namespace binding_detail |
1115 | | |
1116 | | |
1117 | | struct HmacImportParams : public Algorithm |
1118 | | { |
1119 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1120 | | |
1121 | | HmacImportParams(); |
1122 | | |
1123 | | explicit inline HmacImportParams(const FastDictionaryInitializer& ) |
1124 | | : Algorithm(FastDictionaryInitializer()) |
1125 | 0 | { |
1126 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1127 | 0 | } |
1128 | | |
1129 | | private: |
1130 | | HmacImportParams(const HmacImportParams&) = delete; |
1131 | | HmacImportParams& operator=(const HmacImportParams&) = delete; |
1132 | | |
1133 | | static bool |
1134 | | InitIds(JSContext* cx, HmacImportParamsAtoms* atomsCache); |
1135 | | |
1136 | | public: |
1137 | | bool |
1138 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1139 | | |
1140 | | bool |
1141 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1142 | | |
1143 | | void |
1144 | | TraceDictionary(JSTracer* trc); |
1145 | | }; |
1146 | | |
1147 | | namespace binding_detail { |
1148 | | struct FastHmacImportParams : public HmacImportParams |
1149 | | { |
1150 | | inline FastHmacImportParams() |
1151 | | : HmacImportParams(FastDictionaryInitializer()) |
1152 | 0 | { |
1153 | 0 | // Doesn't matter what int we pass to the parent constructor |
1154 | 0 | } |
1155 | | }; |
1156 | | } // namespace binding_detail |
1157 | | |
1158 | | |
1159 | | struct HmacKeyGenParams : public Algorithm |
1160 | | { |
1161 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1162 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mLength; |
1163 | | |
1164 | | HmacKeyGenParams(); |
1165 | | |
1166 | | explicit inline HmacKeyGenParams(const FastDictionaryInitializer& ) |
1167 | | : Algorithm(FastDictionaryInitializer()) |
1168 | 0 | { |
1169 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1170 | 0 | } |
1171 | | |
1172 | | private: |
1173 | | HmacKeyGenParams(const HmacKeyGenParams&) = delete; |
1174 | | HmacKeyGenParams& operator=(const HmacKeyGenParams&) = delete; |
1175 | | |
1176 | | static bool |
1177 | | InitIds(JSContext* cx, HmacKeyGenParamsAtoms* atomsCache); |
1178 | | |
1179 | | public: |
1180 | | bool |
1181 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1182 | | |
1183 | | bool |
1184 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1185 | | |
1186 | | void |
1187 | | TraceDictionary(JSTracer* trc); |
1188 | | }; |
1189 | | |
1190 | | namespace binding_detail { |
1191 | | struct FastHmacKeyGenParams : public HmacKeyGenParams |
1192 | | { |
1193 | | inline FastHmacKeyGenParams() |
1194 | | : HmacKeyGenParams(FastDictionaryInitializer()) |
1195 | 0 | { |
1196 | 0 | // Doesn't matter what int we pass to the parent constructor |
1197 | 0 | } |
1198 | | }; |
1199 | | } // namespace binding_detail |
1200 | | |
1201 | | |
1202 | | struct JsonWebKey : public DictionaryBase |
1203 | | { |
1204 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mAlg; |
1205 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mCrv; |
1206 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mD; |
1207 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mDp; |
1208 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mDq; |
1209 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mE; |
1210 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mExt; |
1211 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mK; |
1212 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<nsString>> mKey_ops; |
1213 | | MOZ_INIT_OUTSIDE_CTOR nsString mKty; |
1214 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mN; |
1215 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<RsaOtherPrimesInfo>> mOth; |
1216 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mP; |
1217 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mQ; |
1218 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mQi; |
1219 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mUse; |
1220 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mX; |
1221 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mY; |
1222 | | |
1223 | | JsonWebKey(); |
1224 | | |
1225 | | explicit inline JsonWebKey(const FastDictionaryInitializer& ) |
1226 | 0 | { |
1227 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1228 | 0 | } |
1229 | | |
1230 | | explicit inline JsonWebKey(const JsonWebKey& aOther) |
1231 | 0 | { |
1232 | 0 | *this = aOther; |
1233 | 0 | } |
1234 | | |
1235 | | bool |
1236 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1237 | | |
1238 | | bool |
1239 | | Init(const nsAString& aJSON); |
1240 | | |
1241 | | bool |
1242 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1243 | | |
1244 | | bool |
1245 | | ToJSON(nsAString& aJSON) const; |
1246 | | |
1247 | | void |
1248 | | TraceDictionary(JSTracer* trc); |
1249 | | |
1250 | | JsonWebKey& |
1251 | | operator=(const JsonWebKey& aOther); |
1252 | | |
1253 | | private: |
1254 | | static bool |
1255 | | InitIds(JSContext* cx, JsonWebKeyAtoms* atomsCache); |
1256 | | }; |
1257 | | |
1258 | | namespace binding_detail { |
1259 | | struct FastJsonWebKey : public JsonWebKey |
1260 | | { |
1261 | | inline FastJsonWebKey() |
1262 | | : JsonWebKey(FastDictionaryInitializer()) |
1263 | 0 | { |
1264 | 0 | // Doesn't matter what int we pass to the parent constructor |
1265 | 0 | } |
1266 | | }; |
1267 | | } // namespace binding_detail |
1268 | | |
1269 | | |
1270 | | struct Pbkdf2Params : public Algorithm |
1271 | | { |
1272 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1273 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mIterations; |
1274 | | MOZ_INIT_OUTSIDE_CTOR OwningArrayBufferViewOrArrayBuffer mSalt; |
1275 | | |
1276 | | Pbkdf2Params(); |
1277 | | |
1278 | | explicit inline Pbkdf2Params(const FastDictionaryInitializer& ) |
1279 | | : Algorithm(FastDictionaryInitializer()) |
1280 | 0 | { |
1281 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1282 | 0 | } |
1283 | | |
1284 | | private: |
1285 | | Pbkdf2Params(const Pbkdf2Params&) = delete; |
1286 | | Pbkdf2Params& operator=(const Pbkdf2Params&) = delete; |
1287 | | |
1288 | | static bool |
1289 | | InitIds(JSContext* cx, Pbkdf2ParamsAtoms* atomsCache); |
1290 | | |
1291 | | public: |
1292 | | bool |
1293 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1294 | | |
1295 | | bool |
1296 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1297 | | |
1298 | | void |
1299 | | TraceDictionary(JSTracer* trc); |
1300 | | }; |
1301 | | |
1302 | | namespace binding_detail { |
1303 | | struct FastPbkdf2Params : public Pbkdf2Params |
1304 | | { |
1305 | | inline FastPbkdf2Params() |
1306 | | : Pbkdf2Params(FastDictionaryInitializer()) |
1307 | 0 | { |
1308 | 0 | // Doesn't matter what int we pass to the parent constructor |
1309 | 0 | } |
1310 | | }; |
1311 | | } // namespace binding_detail |
1312 | | |
1313 | | |
1314 | | struct RsaHashedImportParams : public DictionaryBase |
1315 | | { |
1316 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1317 | | |
1318 | | RsaHashedImportParams(); |
1319 | | |
1320 | | explicit inline RsaHashedImportParams(const FastDictionaryInitializer& ) |
1321 | 0 | { |
1322 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1323 | 0 | } |
1324 | | |
1325 | | private: |
1326 | | RsaHashedImportParams(const RsaHashedImportParams&) = delete; |
1327 | | RsaHashedImportParams& operator=(const RsaHashedImportParams&) = delete; |
1328 | | |
1329 | | static bool |
1330 | | InitIds(JSContext* cx, RsaHashedImportParamsAtoms* atomsCache); |
1331 | | |
1332 | | public: |
1333 | | bool |
1334 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1335 | | |
1336 | | bool |
1337 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1338 | | |
1339 | | void |
1340 | | TraceDictionary(JSTracer* trc); |
1341 | | }; |
1342 | | |
1343 | | namespace binding_detail { |
1344 | | struct FastRsaHashedImportParams : public RsaHashedImportParams |
1345 | | { |
1346 | | inline FastRsaHashedImportParams() |
1347 | | : RsaHashedImportParams(FastDictionaryInitializer()) |
1348 | 0 | { |
1349 | 0 | // Doesn't matter what int we pass to the parent constructor |
1350 | 0 | } |
1351 | | }; |
1352 | | } // namespace binding_detail |
1353 | | |
1354 | | |
1355 | | struct RsaHashedKeyGenParams : public Algorithm |
1356 | | { |
1357 | | MOZ_INIT_OUTSIDE_CTOR OwningObjectOrString mHash; |
1358 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mModulusLength; |
1359 | | MOZ_INIT_OUTSIDE_CTOR Uint8Array mPublicExponent; |
1360 | | |
1361 | | RsaHashedKeyGenParams(); |
1362 | | |
1363 | | explicit inline RsaHashedKeyGenParams(const FastDictionaryInitializer& ) |
1364 | | : Algorithm(FastDictionaryInitializer()) |
1365 | 0 | { |
1366 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1367 | 0 | } |
1368 | | |
1369 | | private: |
1370 | | RsaHashedKeyGenParams(const RsaHashedKeyGenParams&) = delete; |
1371 | | RsaHashedKeyGenParams& operator=(const RsaHashedKeyGenParams&) = delete; |
1372 | | |
1373 | | static bool |
1374 | | InitIds(JSContext* cx, RsaHashedKeyGenParamsAtoms* atomsCache); |
1375 | | |
1376 | | public: |
1377 | | bool |
1378 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1379 | | |
1380 | | bool |
1381 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1382 | | |
1383 | | void |
1384 | | TraceDictionary(JSTracer* trc); |
1385 | | }; |
1386 | | |
1387 | | namespace binding_detail { |
1388 | | struct FastRsaHashedKeyGenParams : public RsaHashedKeyGenParams |
1389 | | { |
1390 | | inline FastRsaHashedKeyGenParams() |
1391 | | : RsaHashedKeyGenParams(FastDictionaryInitializer()) |
1392 | 0 | { |
1393 | 0 | // Doesn't matter what int we pass to the parent constructor |
1394 | 0 | } |
1395 | | }; |
1396 | | } // namespace binding_detail |
1397 | | |
1398 | | |
1399 | | struct RsaOaepParams : public Algorithm |
1400 | | { |
1401 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningArrayBufferViewOrArrayBuffer> mLabel; |
1402 | | |
1403 | | RsaOaepParams(); |
1404 | | |
1405 | | explicit inline RsaOaepParams(const FastDictionaryInitializer& ) |
1406 | | : Algorithm(FastDictionaryInitializer()) |
1407 | 0 | { |
1408 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1409 | 0 | } |
1410 | | |
1411 | | private: |
1412 | | RsaOaepParams(const RsaOaepParams&) = delete; |
1413 | | RsaOaepParams& operator=(const RsaOaepParams&) = delete; |
1414 | | |
1415 | | static bool |
1416 | | InitIds(JSContext* cx, RsaOaepParamsAtoms* atomsCache); |
1417 | | |
1418 | | public: |
1419 | | bool |
1420 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1421 | | |
1422 | | bool |
1423 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1424 | | |
1425 | | void |
1426 | | TraceDictionary(JSTracer* trc); |
1427 | | }; |
1428 | | |
1429 | | namespace binding_detail { |
1430 | | struct FastRsaOaepParams : public RsaOaepParams |
1431 | | { |
1432 | | inline FastRsaOaepParams() |
1433 | | : RsaOaepParams(FastDictionaryInitializer()) |
1434 | 0 | { |
1435 | 0 | // Doesn't matter what int we pass to the parent constructor |
1436 | 0 | } |
1437 | | }; |
1438 | | } // namespace binding_detail |
1439 | | |
1440 | | |
1441 | | struct RsaPssParams : public Algorithm |
1442 | | { |
1443 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mSaltLength; |
1444 | | |
1445 | | RsaPssParams(); |
1446 | | |
1447 | | explicit inline RsaPssParams(const FastDictionaryInitializer& ) |
1448 | | : Algorithm(FastDictionaryInitializer()) |
1449 | 0 | { |
1450 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1451 | 0 | } |
1452 | | |
1453 | | explicit inline RsaPssParams(const RsaPssParams& aOther) |
1454 | 0 | { |
1455 | 0 | *this = aOther; |
1456 | 0 | } |
1457 | | |
1458 | | bool |
1459 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1460 | | |
1461 | | bool |
1462 | | Init(const nsAString& aJSON); |
1463 | | |
1464 | | bool |
1465 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1466 | | |
1467 | | bool |
1468 | | ToJSON(nsAString& aJSON) const; |
1469 | | |
1470 | | void |
1471 | | TraceDictionary(JSTracer* trc); |
1472 | | |
1473 | | RsaPssParams& |
1474 | | operator=(const RsaPssParams& aOther); |
1475 | | |
1476 | | private: |
1477 | | static bool |
1478 | | InitIds(JSContext* cx, RsaPssParamsAtoms* atomsCache); |
1479 | | }; |
1480 | | |
1481 | | namespace binding_detail { |
1482 | | struct FastRsaPssParams : public RsaPssParams |
1483 | | { |
1484 | | inline FastRsaPssParams() |
1485 | | : RsaPssParams(FastDictionaryInitializer()) |
1486 | 0 | { |
1487 | 0 | // Doesn't matter what int we pass to the parent constructor |
1488 | 0 | } |
1489 | | }; |
1490 | | } // namespace binding_detail |
1491 | | |
1492 | | |
1493 | | struct HmacDerivedKeyParams : public HmacImportParams |
1494 | | { |
1495 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mLength; |
1496 | | |
1497 | | HmacDerivedKeyParams(); |
1498 | | |
1499 | | explicit inline HmacDerivedKeyParams(const FastDictionaryInitializer& ) |
1500 | | : HmacImportParams(FastDictionaryInitializer()) |
1501 | 0 | { |
1502 | 0 | // Do nothing here; this is used by our "Fast" subclass |
1503 | 0 | } |
1504 | | |
1505 | | private: |
1506 | | HmacDerivedKeyParams(const HmacDerivedKeyParams&) = delete; |
1507 | | HmacDerivedKeyParams& operator=(const HmacDerivedKeyParams&) = delete; |
1508 | | |
1509 | | static bool |
1510 | | InitIds(JSContext* cx, HmacDerivedKeyParamsAtoms* atomsCache); |
1511 | | |
1512 | | public: |
1513 | | bool |
1514 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
1515 | | |
1516 | | bool |
1517 | | Init(const nsAString& aJSON); |
1518 | | |
1519 | | bool |
1520 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
1521 | | |
1522 | | bool |
1523 | | ToJSON(nsAString& aJSON) const; |
1524 | | |
1525 | | void |
1526 | | TraceDictionary(JSTracer* trc); |
1527 | | }; |
1528 | | |
1529 | | namespace binding_detail { |
1530 | | struct FastHmacDerivedKeyParams : public HmacDerivedKeyParams |
1531 | | { |
1532 | | inline FastHmacDerivedKeyParams() |
1533 | | : HmacDerivedKeyParams(FastDictionaryInitializer()) |
1534 | 0 | { |
1535 | 0 | // Doesn't matter what int we pass to the parent constructor |
1536 | 0 | } |
1537 | | }; |
1538 | | } // namespace binding_detail |
1539 | | |
1540 | | |
1541 | | namespace CryptoKey_Binding { |
1542 | | |
1543 | | typedef mozilla::dom::CryptoKey NativeType; |
1544 | | |
1545 | | const JSClass* |
1546 | | GetJSClass(); |
1547 | | |
1548 | | bool |
1549 | | Wrap(JSContext* aCx, mozilla::dom::CryptoKey* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
1550 | | |
1551 | | template <class T> |
1552 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
1553 | 0 | { |
1554 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
1555 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
1556 | 0 | } |
1557 | | |
1558 | | // We declare this as an array so that retrieving a pointer to this |
1559 | | // binding's property hooks only requires compile/link-time resolvable |
1560 | | // address arithmetic. Declaring it as a pointer instead would require |
1561 | | // doing a run-time load to fetch a pointer to this binding's property |
1562 | | // hooks. And then structures which embedded a pointer to this structure |
1563 | | // would require a run-time load for proper initialization, which would |
1564 | | // then induce static constructors. Lots of static constructors. |
1565 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
1566 | | |
1567 | | void |
1568 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
1569 | | |
1570 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
1571 | 0 | { |
1572 | 0 | /* Get the interface prototype object for this class. This will create the |
1573 | 0 | object as needed. */ |
1574 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::CryptoKey, |
1575 | 0 | &CreateInterfaceObjects, |
1576 | 0 | /* aDefineOnGlobal = */ true); |
1577 | 0 |
|
1578 | 0 | } |
1579 | | |
1580 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
1581 | 0 | { |
1582 | 0 | /* Get the interface object for this class. This will create the object as |
1583 | 0 | needed. */ |
1584 | 0 |
|
1585 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::CryptoKey, |
1586 | 0 | &CreateInterfaceObjects, |
1587 | 0 | aDefineOnGlobal); |
1588 | 0 | } |
1589 | | |
1590 | | JSObject* |
1591 | | GetConstructorObject(JSContext* aCx); |
1592 | | |
1593 | | } // namespace CryptoKey_Binding |
1594 | | |
1595 | | |
1596 | | |
1597 | | namespace SubtleCrypto_Binding { |
1598 | | |
1599 | | typedef mozilla::dom::SubtleCrypto NativeType; |
1600 | | |
1601 | | const JSClass* |
1602 | | GetJSClass(); |
1603 | | |
1604 | | bool |
1605 | | Wrap(JSContext* aCx, mozilla::dom::SubtleCrypto* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
1606 | | |
1607 | | template <class T> |
1608 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
1609 | 0 | { |
1610 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
1611 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
1612 | 0 | } |
1613 | | |
1614 | | // We declare this as an array so that retrieving a pointer to this |
1615 | | // binding's property hooks only requires compile/link-time resolvable |
1616 | | // address arithmetic. Declaring it as a pointer instead would require |
1617 | | // doing a run-time load to fetch a pointer to this binding's property |
1618 | | // hooks. And then structures which embedded a pointer to this structure |
1619 | | // would require a run-time load for proper initialization, which would |
1620 | | // then induce static constructors. Lots of static constructors. |
1621 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
1622 | | |
1623 | | void |
1624 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
1625 | | |
1626 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
1627 | 0 | { |
1628 | 0 | /* Get the interface prototype object for this class. This will create the |
1629 | 0 | object as needed. */ |
1630 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::SubtleCrypto, |
1631 | 0 | &CreateInterfaceObjects, |
1632 | 0 | /* aDefineOnGlobal = */ true); |
1633 | 0 |
|
1634 | 0 | } |
1635 | | |
1636 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
1637 | 0 | { |
1638 | 0 | /* Get the interface object for this class. This will create the object as |
1639 | 0 | needed. */ |
1640 | 0 |
|
1641 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::SubtleCrypto, |
1642 | 0 | &CreateInterfaceObjects, |
1643 | 0 | aDefineOnGlobal); |
1644 | 0 | } |
1645 | | |
1646 | | JSObject* |
1647 | | GetConstructorObject(JSContext* aCx); |
1648 | | |
1649 | | } // namespace SubtleCrypto_Binding |
1650 | | |
1651 | | |
1652 | | |
1653 | | } // namespace dom |
1654 | | } // namespace mozilla |
1655 | | |
1656 | | #endif // mozilla_dom_SubtleCryptoBinding_h |