blob: c369b6307812585b6a410fb24ebf08f4ce769ba0 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_FIDO_CTAP_GET_ASSERTION_REQUEST_H_
#define DEVICE_FIDO_CTAP_GET_ASSERTION_REQUEST_H_
#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/containers/span.h"
#include "base/macros.h"
#include "base/optional.h"
#include "crypto/sha2.h"
#include "device/fido/cable/cable_discovery_data.h"
#include "device/fido/fido_constants.h"
#include "device/fido/public_key_credential_descriptor.h"
namespace cbor {
class Value;
}
namespace device {
// Object that encapsulates request parameters for AuthenticatorGetAssertion as
// specified in the CTAP spec.
// https://fidoalliance.org/specs/fido-v2.0-rd-20161004/fido-client-to-authenticator-protocol-v2.0-rd-20161004.html#authenticatorgetassertion
struct COMPONENT_EXPORT(DEVICE_FIDO) CtapGetAssertionRequest {
public:
using ClientDataHash = std::array<uint8_t, kClientDataHashLength>;
CtapGetAssertionRequest(std::string rp_id, std::string client_data_json);
CtapGetAssertionRequest(const CtapGetAssertionRequest& that);
CtapGetAssertionRequest(CtapGetAssertionRequest&& that);
CtapGetAssertionRequest& operator=(const CtapGetAssertionRequest& other);
CtapGetAssertionRequest& operator=(CtapGetAssertionRequest&& other);
~CtapGetAssertionRequest();
std::string rp_id;
std::string client_data_json;
std::array<uint8_t, kClientDataHashLength> client_data_hash;
UserVerificationRequirement user_verification =
UserVerificationRequirement::kDiscouraged;
bool user_presence_required = true;
std::vector<PublicKeyCredentialDescriptor> allow_list;
base::Optional<std::vector<uint8_t>> pin_auth;
base::Optional<uint8_t> pin_protocol;
base::Optional<std::vector<CableDiscoveryData>> cable_extension;
base::Optional<std::string> app_id;
base::Optional<std::array<uint8_t, crypto::kSHA256Length>>
alternative_application_parameter;
bool is_incognito_mode = false;
bool is_u2f_only = false;
};
struct CtapGetNextAssertionRequest {
};
// Serializes GetAssertion request parameter into CBOR encoded map with
// integer keys and CBOR encoded values as defined by the CTAP spec.
// https://drafts.fidoalliance.org/fido-2/latest/fido-client-to-authenticator-protocol-v2.0-wd-20180305.html#authenticatorGetAssertion
COMPONENT_EXPORT(DEVICE_FIDO)
std::pair<CtapRequestCommand, base::Optional<cbor::Value>>
AsCTAPRequestValuePair(const CtapGetAssertionRequest&);
COMPONENT_EXPORT(DEVICE_FIDO)
std::pair<CtapRequestCommand, base::Optional<cbor::Value>>
AsCTAPRequestValuePair(const CtapGetNextAssertionRequest&);
} // namespace device
#endif // DEVICE_FIDO_CTAP_GET_ASSERTION_REQUEST_H_