/* -*- 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/. */
/* Implementing OSKeyStore when there is no platform specific one. * This key store instead puts the keys into the NSS DB.
*/
usingnamespace mozilla; using mozilla::SyncRunnable;
LazyLogModule gNSSKeyStoreLog("nsskeystore");
NSSKeyStore::NSSKeyStore() {
MOZ_ASSERT(XRE_IsParentProcess()); if (!XRE_IsParentProcess()) { // This shouldn't happen as this is only initialised when creating the // OSKeyStore, which is ParentProcessOnly. return;
}
Unused << EnsureNSSInitializedChromeOrContent();
Unused << InitToken();
}
NSSKeyStore::~NSSKeyStore() = default;
// It is possible for multiple keys to have the same nickname in NSS. To // prevent the problem of not knowing which key to use in the future, simply // delete all keys with this nickname before storing a new one.
nsresult rv = DeleteSecret(aLabel); if (NS_FAILED(rv)) {
MOZ_LOG(gNSSKeyStoreLog, LogLevel::Debug,
("DeleteSecret before StoreSecret failed")); return rv;
}
UniquePK11SymKey symKey(PK11_ListFixedKeysInSlot(
mSlot.get(), const_cast<char*>(PromiseFlatCString(aLabel).get()),
nullptr)); if (!symKey) {
MOZ_LOG(gNSSKeyStoreLog, LogLevel::Debug,
("Error finding key for given label")); return NS_ERROR_FAILURE;
}
// Unfortunately we can't use PK11_ExtractKeyValue(symKey.get()) here because // softoken marks all token objects of type CKO_SECRET_KEY as sensitive. So // we have to wrap and unwrap symKey to obtain a non-sensitive copy of symKey // as a session object.
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.