blob: ae1069b02d6fd8999fcdb658b4e5165bf64647be (
plain)
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
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_REPORTING_ENCRYPTION_VERIFICATION_H_
#define COMPONENTS_REPORTING_ENCRYPTION_VERIFICATION_H_
#include <string>
#include "base/strings/string_piece.h"
#include "components/reporting/util/status.h"
namespace reporting {
// Helper class that verifies an Ed25519 signed message received from
// the server. It uses boringssl implementation available on the client.
class SignatureVerifier {
public:
// Well-known public signature verification keys that is used to verify
// that signed data is indeed originating from reporting server.
// Exists in two flavors: PROD and DEV.
static base::StringPiece VerificationKey();
static base::StringPiece VerificationKeyDev();
// Ed25519 |verification_public_key| must consist of kKeySize bytes.
explicit SignatureVerifier(base::StringPiece verification_public_key);
// Actual verification - returns error status if provided |signature| does not
// match |message|. Signature must be kSignatureSize bytes.
Status Verify(base::StringPiece message, base::StringPiece signature);
private:
std::string verification_public_key_;
};
} // namespace reporting
#endif // COMPONENTS_REPORTING_ENCRYPTION_VERIFICATION_H_
|