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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_U2FSoftTokenManager_h
8 #define mozilla_dom_U2FSoftTokenManager_h
10 #include "mozilla/dom/U2FTokenTransport.h"
11 #include "ScopedNSSTypes.h"
14 * U2FSoftTokenManager is a software implementation of a secure token manager
15 * for the U2F and WebAuthn APIs.
18 namespace mozilla::dom
{
20 class U2FSoftTokenManager final
: public U2FTokenTransport
{
22 explicit U2FSoftTokenManager(uint32_t aCounter
);
24 RefPtr
<U2FRegisterPromise
> Register(const WebAuthnMakeCredentialInfo
& aInfo
,
25 bool aForceNoneAttestation
) override
;
27 RefPtr
<U2FSignPromise
> Sign(const WebAuthnGetAssertionInfo
& aInfo
) override
;
29 void Cancel() override
;
32 ~U2FSoftTokenManager() = default;
35 nsresult
IsRegistered(const nsTArray
<uint8_t>& aKeyHandle
,
36 const nsTArray
<uint8_t>& aAppParam
, bool& aResult
);
38 bool FindRegisteredKeyHandle(
39 const nsTArray
<nsTArray
<uint8_t>>& aAppIds
,
40 const nsTArray
<WebAuthnScopedCredential
>& aCredentials
,
41 /*out*/ nsTArray
<uint8_t>& aKeyHandle
,
42 /*out*/ nsTArray
<uint8_t>& aAppId
);
45 mozilla::UniquePK11SymKey mWrappingKey
;
47 static const nsCString mSecretNickname
;
49 nsresult
GetOrCreateWrappingKey(const mozilla::UniquePK11SlotInfo
& aSlot
);
53 } // namespace mozilla::dom
55 #endif // mozilla_dom_U2FSoftTokenManager_h