Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: extensions/common/cast/cast_cert_validator.h

Issue 792353002: Refactoring of Cast-related crypto code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/NetworkingPrivateCredentialsGetterCrOs/NetworkingPrivateCredentialsGetterChromeos/g Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
6 #define EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/strings/string_piece.h"
12
13 namespace extensions {
14 namespace core_api {
15 namespace cast_crypto {
16
17 struct VerificationResult {
Ryan Sleevi 2014/12/15 21:43:00 Document
sheretov 2014/12/16 08:44:21 Done. And consolidated error types into more sens
18 enum ErrorType {
19 ERROR_NONE = 0,
20 ERROR_CERT_PARSING_FAILED,
21 ERROR_CERT_NOT_SIGNED_BY_TRUSTED_CA,
22 ERROR_CANNOT_EXTRACT_PUBLIC_KEY,
23 ERROR_SIGNATURE_INVALID,
24 ERROR_CRYPTO_LIBRARY,
25 // Always update ERROR_TYPE_MAX to the last error code in the enum.
26 ERROR_TYPE_MAX = ERROR_CRYPTO_LIBRARY
27 };
28
29 // Constructs a VerificationResult that corresponds to success.
30 VerificationResult();
31
32 // Construct error-related objects
33 VerificationResult(const std::string& error_message, ErrorType error_type);
34 VerificationResult(const std::string& error_message,
35 ErrorType error_type,
36 int error_code);
37
38 bool Success() const { return error_type == ERROR_NONE; }
39 bool Failure() const { return error_type != ERROR_NONE; }
40
41 ErrorType error_type;
42 std::string error_message;
43 int library_error_code;
44 };
45
46 class CertVerificationContext {
Ryan Sleevi 2014/12/15 21:43:00 Document
sheretov 2014/12/16 08:44:21 Done.
47 public:
48 CertVerificationContext() {}
49 virtual ~CertVerificationContext() {}
50
51 virtual VerificationResult VerifySignatureOverData(
Ryan Sleevi 2014/12/15 21:43:00 Document
sheretov 2014/12/16 08:44:21 Done.
52 const base::StringPiece& signature,
53 const base::StringPiece& data) const = 0;
54 virtual std::string getCommonName() const = 0;
Ryan Sleevi 2014/12/15 21:43:00 Document
Ryan Sleevi 2014/12/15 21:43:00 NAMING: This does not conform to the C++ style gui
sheretov 2014/12/16 08:44:21 Done.
sheretov 2014/12/16 08:44:21 Done.
55
56 private:
57 DISALLOW_COPY_AND_ASSIGN(CertVerificationContext);
58 };
59
60 VerificationResult VerifyCert(const base::StringPiece& device_cert,
Ryan Sleevi 2014/12/15 21:42:59 Document
Ryan Sleevi 2014/12/15 21:43:00 naming: VerifyDeviceCert? VerifyDevice?
sheretov 2014/12/16 08:44:21 Done.
sheretov 2014/12/16 08:44:21 VerifyDeviceCert
61 const std::vector<std::string>& ica_certs,
62 CertVerificationContext** out_context);
Ryan Sleevi 2014/12/15 21:42:59 API DESIGN: Don't return pointers to pointers, esp
sheretov 2014/12/16 08:44:21 Done.
63
64 } // namespace cast_crypto
65 } // namespace core_api
66 } // namespace extensions
67
68 #endif // EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698