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.
21 class U2FSoftTokenManager final
: public U2FTokenTransport
{
23 explicit U2FSoftTokenManager(uint32_t aCounter
);
25 RefPtr
<U2FRegisterPromise
> Register(const WebAuthnMakeCredentialInfo
& aInfo
,
26 bool aForceNoneAttestation
) override
;
28 RefPtr
<U2FSignPromise
> Sign(const WebAuthnGetAssertionInfo
& aInfo
) override
;
30 void Cancel() override
;
33 ~U2FSoftTokenManager() = default;
36 nsresult
IsRegistered(const nsTArray
<uint8_t>& aKeyHandle
,
37 const nsTArray
<uint8_t>& aAppParam
, bool& aResult
);
39 bool FindRegisteredKeyHandle(
40 const nsTArray
<nsTArray
<uint8_t>>& aAppIds
,
41 const nsTArray
<WebAuthnScopedCredential
>& aCredentials
,
42 /*out*/ nsTArray
<uint8_t>& aKeyHandle
,
43 /*out*/ nsTArray
<uint8_t>& aAppId
);
46 mozilla::UniquePK11SymKey mWrappingKey
;
48 static const nsCString mSecretNickname
;
50 nsresult
GetOrCreateWrappingKey(const mozilla::UniquePK11SlotInfo
& aSlot
);
55 } // namespace mozilla
57 #endif // mozilla_dom_U2FSoftTokenManager_h