/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * 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/. */
// Generic key store implementation for platforms that we don't support with OS // specific implementations.
class AbstractOSKeyStore { public: // Retrieve a secret with the given label. virtual nsresult RetrieveSecret(const nsACString& aLabel, /* out */ nsACString& aSecret) = 0; // Store a new secret with the given label. virtual nsresult StoreSecret(const nsACString& secret, const nsACString& label) = 0; // Delete the secret with the given label. virtual nsresult DeleteSecret(const nsACString& label) = 0; virtual ~AbstractOSKeyStore() = default;
// Returns true if the secret with the given label is available in the key // store, false otherwise. virtualbool SecretAvailable(const nsACString& label); // Perform encryption or decryption operation with the given secret and input // bytes. The output is written in outBytes. This function can make use of the // AesGcm class to use NSS for encryption and decryption. virtual nsresult EncryptDecrypt(const nsACString& label, const std::vector<uint8_t>& inBytes,
std::vector<uint8_t>& outBytes, bool encrypt);
protected: /* These helper functions are implemented in OSKeyStore.cpp and implement * common functionality of the abstract key store to encrypt and decrypt.
*/
nsresult DoCipher(const mozilla::UniquePK11SymKey& aSymKey, const std::vector<uint8_t>& inBytes,
std::vector<uint8_t>& outBytes, bool aEncrypt);
nsresult BuildAesGcmKey(std::vector<uint8_t> keyBytes, /* out */ mozilla::UniquePK11SymKey& aKey);
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.