forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathattestation_statement_formats.h
71 lines (57 loc) · 2.41 KB
/
attestation_statement_formats.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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_ATTESTATION_STATEMENT_FORMATS_H_
#define DEVICE_FIDO_ATTESTATION_STATEMENT_FORMATS_H_
#include <stdint.h>
#include <memory>
#include <vector>
#include "base/component_export.h"
#include "base/containers/span.h"
#include "base/macros.h"
#include "components/cbor/values.h"
#include "device/fido/attestation_statement.h"
#include "device/fido/fido_constants.h"
namespace device {
// https://www.w3.org/TR/2017/WD-webauthn-20170505/#fido-u2f-attestation
class COMPONENT_EXPORT(DEVICE_FIDO) FidoAttestationStatement
: public AttestationStatement {
public:
static std::unique_ptr<FidoAttestationStatement>
CreateFromU2fRegisterResponse(base::span<const uint8_t> u2f_data);
FidoAttestationStatement(std::vector<uint8_t> signature,
std::vector<std::vector<uint8_t>> x509_certificates);
~FidoAttestationStatement() override;
cbor::Value AsCBOR() const override;
bool IsSelfAttestation() override;
bool IsAttestationCertificateInappropriatelyIdentifying() override;
base::Optional<base::span<const uint8_t>> GetLeafCertificate() const override;
private:
const std::vector<uint8_t> signature_;
const std::vector<std::vector<uint8_t>> x509_certificates_;
DISALLOW_COPY_AND_ASSIGN(FidoAttestationStatement);
};
// Implements the "packed" attestation statement format from
// https://www.w3.org/TR/webauthn/#packed-attestation.
//
// It currently only supports the (optional) "x5c" field, but not "ecdaaKeyId"
// (see packedStmtFormat choices).
class COMPONENT_EXPORT(DEVICE_FIDO) PackedAttestationStatement
: public AttestationStatement {
public:
PackedAttestationStatement(
CoseAlgorithmIdentifier algorithm,
std::vector<uint8_t> signature,
std::vector<std::vector<uint8_t>> x509_certificates);
~PackedAttestationStatement() override;
cbor::Value AsCBOR() const override;
bool IsSelfAttestation() override;
bool IsAttestationCertificateInappropriatelyIdentifying() override;
base::Optional<base::span<const uint8_t>> GetLeafCertificate() const override;
private:
const CoseAlgorithmIdentifier algorithm_;
const std::vector<uint8_t> signature_;
const std::vector<std::vector<uint8_t>> x509_certificates_;
};
} // namespace device
#endif // DEVICE_FIDO_ATTESTATION_STATEMENT_FORMATS_H_