2017-10-27 01:08:41 +03: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 03:48:34 +03: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-25 01:44:01 +03:00
|
|
|
class U2FSoftTokenManager final : public U2FTokenTransport
|
2017-05-05 03:48:34 +03:00
|
|
|
{
|
|
|
|
public:
|
2017-05-05 03:56:47 +03:00
|
|
|
explicit U2FSoftTokenManager(uint32_t aCounter);
|
2017-06-23 05:50:31 +03:00
|
|
|
|
2017-07-11 12:09:08 +03:00
|
|
|
virtual RefPtr<U2FRegisterPromise>
|
2018-01-09 09:27:35 +03:00
|
|
|
Register(const nsTArray<WebAuthnScopedCredential>& aCredentials,
|
2017-11-29 15:58:33 +03:00
|
|
|
const WebAuthnAuthenticatorSelection &aAuthenticatorSelection,
|
2017-06-23 13:36:32 +03:00
|
|
|
const nsTArray<uint8_t>& aApplication,
|
2017-07-14 20:27:53 +03:00
|
|
|
const nsTArray<uint8_t>& aChallenge,
|
|
|
|
uint32_t aTimeoutMS) override;
|
2017-06-23 13:36:32 +03:00
|
|
|
|
2017-07-11 12:09:08 +03:00
|
|
|
virtual RefPtr<U2FSignPromise>
|
2018-01-09 09:27:35 +03:00
|
|
|
Sign(const nsTArray<WebAuthnScopedCredential>& aCredentials,
|
2017-06-23 13:36:32 +03:00
|
|
|
const nsTArray<uint8_t>& aApplication,
|
2017-07-14 20:27:53 +03:00
|
|
|
const nsTArray<uint8_t>& aChallenge,
|
2018-01-09 09:27:35 +03:00
|
|
|
bool aRequireUserVerification,
|
2017-07-14 20:27:53 +03:00
|
|
|
uint32_t aTimeoutMS) override;
|
2017-05-05 03:56:47 +03:00
|
|
|
|
2017-06-23 22:04:38 +03:00
|
|
|
virtual void Cancel() override;
|
|
|
|
|
2017-05-05 03:48:34 +03:00
|
|
|
private:
|
2018-01-25 01:29:08 +03:00
|
|
|
~U2FSoftTokenManager() {}
|
2017-05-05 03:56:47 +03:00
|
|
|
nsresult Init();
|
|
|
|
|
2017-06-23 05:50:31 +03:00
|
|
|
nsresult IsRegistered(const nsTArray<uint8_t>& aKeyHandle,
|
|
|
|
const nsTArray<uint8_t>& aAppParam,
|
|
|
|
bool& aResult);
|
|
|
|
|
2017-05-05 03:56:47 +03:00
|
|
|
bool mInitialized;
|
|
|
|
mozilla::UniquePK11SymKey mWrappingKey;
|
|
|
|
|
|
|
|
static const nsCString mSecretNickname;
|
|
|
|
|
2018-01-23 21:37:47 +03:00
|
|
|
nsresult GetOrCreateWrappingKey(const mozilla::UniquePK11SlotInfo& aSlot);
|
2017-05-05 03:48:34 +03:00
|
|
|
uint32_t mCounter;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_U2FSoftTokenManager_h
|