Bug 1769628 [wpt PR 34081] - Update wpt metadata, a=testonly
[gecko.git] / dom / webauthn / U2FSoftTokenManager.h
blob2807e28f2c31d23104c28fda383cddba1fbfba0d
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 {
21 public:
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;
31 private:
32 ~U2FSoftTokenManager() = default;
33 nsresult Init();
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);
44 bool mInitialized;
45 mozilla::UniquePK11SymKey mWrappingKey;
47 static const nsCString mSecretNickname;
49 nsresult GetOrCreateWrappingKey(const mozilla::UniquePK11SlotInfo& aSlot);
50 uint32_t mCounter;
53 } // namespace mozilla::dom
55 #endif // mozilla_dom_U2FSoftTokenManager_h