2017-10-26 22:08:41 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-05-05 00:48:34 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_U2FSoftTokenManager_h
|
|
|
|
#define mozilla_dom_U2FSoftTokenManager_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/U2FTokenTransport.h"
|
|
|
|
#include "ScopedNSSTypes.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* U2FSoftTokenManager is a software implementation of a secure token manager
|
|
|
|
* for the U2F and WebAuthn APIs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-01-24 22:44:01 +00:00
|
|
|
class U2FSoftTokenManager final : public U2FTokenTransport
|
2017-05-05 00:48:34 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-05-05 00:56:47 +00:00
|
|
|
explicit U2FSoftTokenManager(uint32_t aCounter);
|
2017-06-23 02:50:31 +00:00
|
|
|
|
2018-02-19 11:45:43 +00:00
|
|
|
RefPtr<U2FRegisterPromise>
|
2018-05-30 14:06:09 +00:00
|
|
|
Register(const WebAuthnMakeCredentialInfo& aInfo,
|
|
|
|
bool aForceNoneAttestation) override;
|
2017-06-23 10:36:32 +00:00
|
|
|
|
2018-02-19 11:45:43 +00:00
|
|
|
RefPtr<U2FSignPromise>
|
2018-02-22 21:09:00 +00:00
|
|
|
Sign(const WebAuthnGetAssertionInfo& aInfo) override;
|
2017-05-05 00:56:47 +00:00
|
|
|
|
2018-02-19 11:45:43 +00:00
|
|
|
void Cancel() override;
|
2017-06-23 19:04:38 +00:00
|
|
|
|
2017-05-05 00:48:34 +00:00
|
|
|
private:
|
2018-01-24 22:29:08 +00:00
|
|
|
~U2FSoftTokenManager() {}
|
2017-05-05 00:56:47 +00:00
|
|
|
nsresult Init();
|
|
|
|
|
2017-06-23 02:50:31 +00:00
|
|
|
nsresult IsRegistered(const nsTArray<uint8_t>& aKeyHandle,
|
|
|
|
const nsTArray<uint8_t>& aAppParam,
|
|
|
|
bool& aResult);
|
|
|
|
|
2018-02-22 09:53:49 +00:00
|
|
|
bool
|
|
|
|
FindRegisteredKeyHandle(const nsTArray<nsTArray<uint8_t>>& aAppIds,
|
|
|
|
const nsTArray<WebAuthnScopedCredential>& aCredentials,
|
|
|
|
/*out*/ nsTArray<uint8_t>& aKeyHandle,
|
|
|
|
/*out*/ nsTArray<uint8_t>& aAppId);
|
|
|
|
|
2017-05-05 00:56:47 +00:00
|
|
|
bool mInitialized;
|
|
|
|
mozilla::UniquePK11SymKey mWrappingKey;
|
|
|
|
|
|
|
|
static const nsCString mSecretNickname;
|
|
|
|
|
2018-01-23 18:37:47 +00:00
|
|
|
nsresult GetOrCreateWrappingKey(const mozilla::UniquePK11SlotInfo& aSlot);
|
2017-05-05 00:48:34 +00:00
|
|
|
uint32_t mCounter;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_U2FSoftTokenManager_h
|