/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class JSObject; class nsIGlobalObject; struct JSContext; struct JSStructuredCloneReader; struct JSStructuredCloneWriter;
namespace mozilla {
class ErrorResult;
namespace dom {
/*
The internal structure of keys is dictated by the need for cloning. We store everything besides the key data itself in a 32-bit bitmask, with the following structure (byte-aligned for simplicity, in order from least to most significant):
Thus, internally, a key has the following fields: * uint32_t - flags for extractable, usage, type * KeyAlgorithm - the algorithm (which must serialize/deserialize itself) * The actual keys (which the CryptoKey must serialize)
*/
struct JsonWebKey;
class CryptoKey final : public nsISupports, public nsWrapperCache { public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(CryptoKey)
// Accessors for the keys themselves const CryptoBuffer& GetSymKey() const;
UniqueSECKEYPrivateKey GetPrivateKey() const;
UniqueSECKEYPublicKey GetPublicKey() const;
// Serialization and deserialization convenience methods // Note: // 1. The inputs aKeyData are non-const only because the NSS import // functions lack the const modifier. They should not be modified. // 2. All of the NSS key objects returned need to be freed by the caller. static UniqueSECKEYPrivateKey PrivateKeyFromPkcs8(CryptoBuffer& aKeyData); static nsresult PrivateKeyToPkcs8(SECKEYPrivateKey* aPrivKey,
CryptoBuffer& aRetVal);
// Structured clone methods use these to clone keys bool WriteStructuredClone(JSContext* aCx,
JSStructuredCloneWriter* aWriter) const; static already_AddRefed<CryptoKey> ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
private:
~CryptoKey() = default;
RefPtr<nsIGlobalObject> mGlobal;
uint32_t mAttributes; // see above
KeyAlgorithmProxy mAlgorithm;
// Only one key handle should be set, according to the KeyType
CryptoBuffer mSymKey;
UniqueSECKEYPrivateKey mPrivateKey;
UniqueSECKEYPublicKey mPublicKey;
};
} // namespace dom
} // namespace mozilla
#endif// mozilla_dom_CryptoKey_h
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.