tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Crypto.h (1411B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_Crypto_h
      8 #define mozilla_dom_Crypto_h
      9 
     10 #include "mozilla/dom/SubtleCrypto.h"
     11 #include "mozilla/dom/TypedArray.h"
     12 #include "nsIGlobalObject.h"
     13 #include "nsString.h"
     14 #include "nsWrapperCache.h"
     15 
     16 namespace mozilla {
     17 
     18 class ErrorResult;
     19 
     20 namespace dom {
     21 
     22 class Crypto final : public nsISupports, public nsWrapperCache {
     23 protected:
     24  virtual ~Crypto();
     25 
     26 public:
     27  explicit Crypto(nsIGlobalObject* aParent);
     28 
     29  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     30  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(Crypto)
     31 
     32  void GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
     33                       JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv);
     34 
     35  void RandomUUID(nsACString& aRetVal);
     36 
     37  SubtleCrypto* Subtle();
     38 
     39  nsIGlobalObject* GetParentObject() const { return mParent; }
     40 
     41  virtual JSObject* WrapObject(JSContext* aCx,
     42                               JS::Handle<JSObject*> aGivenProto) override;
     43 
     44 private:
     45  nsCOMPtr<nsIGlobalObject> mParent;
     46  RefPtr<SubtleCrypto> mSubtle;
     47 };
     48 
     49 }  // namespace dom
     50 }  // namespace mozilla
     51 
     52 #endif  // mozilla_dom_Crypto_h