Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/RTCCertificate.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_RTCCertificate_h
8
#define mozilla_dom_RTCCertificate_h
9
10
#include "nsCycleCollectionParticipant.h"
11
#include "nsWrapperCache.h"
12
#include "nsIGlobalObject.h"
13
#include "prtime.h"
14
#include "sslt.h"
15
#include "ScopedNSSTypes.h"
16
17
#include "mozilla/ErrorResult.h"
18
#include "mozilla/UniquePtr.h"
19
#include "mozilla/RefPtr.h"
20
#include "mozilla/dom/CryptoKey.h"
21
#include "mozilla/dom/RTCCertificateBinding.h"
22
#include "mtransport/dtlsidentity.h"
23
#include "js/StructuredClone.h"
24
#include "js/TypeDecls.h"
25
26
namespace mozilla {
27
namespace dom {
28
29
class ObjectOrString;
30
31
class RTCCertificate final : public nsISupports
32
                           , public nsWrapperCache
33
{
34
public:
35
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
36
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCCertificate)
37
38
  // WebIDL method that implements RTCPeerConnection.generateCertificate.
39
  static already_AddRefed<Promise> GenerateCertificate(
40
      const GlobalObject& aGlobal, const ObjectOrString& aOptions,
41
      ErrorResult& aRv, JS::Compartment* aCompartment = nullptr);
42
43
  explicit RTCCertificate(nsIGlobalObject* aGlobal);
44
  RTCCertificate(nsIGlobalObject* aGlobal, SECKEYPrivateKey* aPrivateKey,
45
                 CERTCertificate* aCertificate, SSLKEAType aAuthType,
46
                 PRTime aExpires);
47
48
0
  nsIGlobalObject* GetParentObject() const { return mGlobal; }
49
  virtual JSObject* WrapObject(JSContext* aCx,
50
                               JS::Handle<JSObject*> aGivenProto) override;
51
52
  // WebIDL expires attribute.  Note: JS dates are milliseconds since epoch;
53
  // NSPR PRTime is in microseconds since the same epoch.
54
  uint64_t Expires() const
55
0
  {
56
0
    return mExpires / PR_USEC_PER_MSEC;
57
0
  }
58
59
  // Accessors for use by PeerConnectionImpl.
60
  RefPtr<DtlsIdentity> CreateDtlsIdentity() const;
61
0
  const UniqueCERTCertificate& Certificate() const { return mCertificate; }
62
63
  // Structured clone methods
64
  bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
65
  bool ReadStructuredClone(JSStructuredCloneReader* aReader);
66
67
private:
68
0
  ~RTCCertificate() {}
69
  void operator=(const RTCCertificate&) = delete;
70
  RTCCertificate(const RTCCertificate&) = delete;
71
72
  bool ReadCertificate(JSStructuredCloneReader* aReader);
73
  bool ReadPrivateKey(JSStructuredCloneReader* aReader);
74
  bool WriteCertificate(JSStructuredCloneWriter* aWriter) const;
75
  bool WritePrivateKey(JSStructuredCloneWriter* aWriter) const;
76
77
  RefPtr<nsIGlobalObject> mGlobal;
78
  UniqueSECKEYPrivateKey mPrivateKey;
79
  UniqueCERTCertificate mCertificate;
80
  SSLKEAType mAuthType;
81
  PRTime mExpires;
82
};
83
84
} // namespace dom
85
} // namespace mozilla
86
87
#endif // mozilla_dom_RTCCertificate_h