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

Side by Side Diff: net/cert/ct_log_verifier.h

Issue 1100003006: Certificate Transparency: Fetching of Signed Tree Heads (DRAFT) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_CERT_CT_LOG_VERIFIER_H_ 5 #ifndef NET_CERT_CT_LOG_VERIFIER_H_
6 #define NET_CERT_CT_LOG_VERIFIER_H_ 6 #define NET_CERT_CT_LOG_VERIFIER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 17 matching lines...) Expand all
28 } // namespace ct 28 } // namespace ct
29 29
30 // Class for verifying Signed Certificate Timestamps (SCTs) provided by a 30 // Class for verifying Signed Certificate Timestamps (SCTs) provided by a
31 // specific log (whose identity is provided during construction). 31 // specific log (whose identity is provided during construction).
32 class NET_EXPORT CTLogVerifier { 32 class NET_EXPORT CTLogVerifier {
33 public: 33 public:
34 // Creates a new CTLogVerifier that will verify SignedCertificateTimestamps 34 // Creates a new CTLogVerifier that will verify SignedCertificateTimestamps
35 // using |public_key|, which is a DER-encoded SubjectPublicKeyInfo. 35 // using |public_key|, which is a DER-encoded SubjectPublicKeyInfo.
36 // If |public_key| refers to an unsupported public key, returns NULL. 36 // If |public_key| refers to an unsupported public key, returns NULL.
37 // |description| is a textual description of the log. 37 // |description| is a textual description of the log.
38 static scoped_ptr<CTLogVerifier> Create( 38 static scoped_ptr<CTLogVerifier> Create(const base::StringPiece& public_key,
39 const base::StringPiece& public_key, 39 const base::StringPiece& description,
40 const base::StringPiece& description); 40 const base::StringPiece& url);
41 41
42 ~CTLogVerifier(); 42 ~CTLogVerifier();
43 43
44 // Returns the log's key ID (RFC6962, Section 3.2) 44 // Returns the log's key ID (RFC6962, Section 3.2)
45 const std::string& key_id() const { return key_id_; } 45 const std::string& key_id() const { return key_id_; }
46 // Returns the log's human-readable description. 46 // Returns the log's human-readable description.
47 const std::string& description() const { return description_; } 47 const std::string& description() const { return description_; }
48 // Returns the log's URL
49 const std::string& url() const { return url_; }
48 50
49 // Verifies that |sct| contains a valid signature for |entry|. 51 // Verifies that |sct| contains a valid signature for |entry|.
50 bool Verify(const ct::LogEntry& entry, 52 bool Verify(const ct::LogEntry& entry,
51 const ct::SignedCertificateTimestamp& sct); 53 const ct::SignedCertificateTimestamp& sct);
52 54
53 // Verifies and sets |signed_tree_head|. If |signed_tree_head|'s signature is 55 // Verifies and sets |signed_tree_head|. If |signed_tree_head|'s signature is
54 // valid, stores it and returns true. Otherwise, discards the sth and 56 // valid, stores it and returns true. Otherwise, discards the sth and
55 // returns false. 57 // returns false.
56 bool SetSignedTreeHead(scoped_ptr<ct::SignedTreeHead> signed_tree_head); 58 bool VerifySignedTreeHead(const ct::SignedTreeHead* signed_tree_head);
Ryan Sleevi 2015/04/24 10:42:08 No need to pass as pointer - just pass as const-re
Eran Messeri 2015/06/18 15:18:42 Done.
57 59
58 private: 60 private:
59 FRIEND_TEST_ALL_PREFIXES(CTLogVerifierTest, VerifySignature); 61 FRIEND_TEST_ALL_PREFIXES(CTLogVerifierTest, VerifySignature);
60 62
61 CTLogVerifier(); 63 CTLogVerifier(const base::StringPiece& description,
64 const base::StringPiece& url);
62 65
63 // Performs crypto-library specific initialization. 66 // Performs crypto-library specific initialization.
64 bool Init(const base::StringPiece& public_key, 67 bool Init(const base::StringPiece& public_key);
65 const base::StringPiece& description);
66 68
67 // Performs the underlying verification using the selected public key. Note 69 // Performs the underlying verification using the selected public key. Note
68 // that |signature| contains the raw signature data (eg: without any 70 // that |signature| contains the raw signature data (eg: without any
69 // DigitallySigned struct encoding). 71 // DigitallySigned struct encoding).
70 bool VerifySignature(const base::StringPiece& data_to_sign, 72 bool VerifySignature(const base::StringPiece& data_to_sign,
71 const base::StringPiece& signature); 73 const base::StringPiece& signature);
72 74
73 // Returns true if the signature and hash algorithms in |signature| 75 // Returns true if the signature and hash algorithms in |signature|
74 // match those of the log 76 // match those of the log
75 bool SignatureParametersMatch(const ct::DigitallySigned& signature); 77 bool SignatureParametersMatch(const ct::DigitallySigned& signature);
76 78
77 std::string key_id_; 79 std::string key_id_;
78 std::string description_; 80 std::string description_;
81 std::string url_;
79 ct::DigitallySigned::HashAlgorithm hash_algorithm_; 82 ct::DigitallySigned::HashAlgorithm hash_algorithm_;
80 ct::DigitallySigned::SignatureAlgorithm signature_algorithm_; 83 ct::DigitallySigned::SignatureAlgorithm signature_algorithm_;
81 scoped_ptr<ct::SignedTreeHead> signed_tree_head_;
82 84
83 #if defined(USE_OPENSSL) 85 #if defined(USE_OPENSSL)
84 EVP_PKEY* public_key_; 86 EVP_PKEY* public_key_;
85 #else 87 #else
86 SECKEYPublicKey* public_key_; 88 SECKEYPublicKey* public_key_;
87 #endif 89 #endif
88 }; 90 };
89 91
90 } // namespace net 92 } // namespace net
91 93
92 #endif // NET_CERT_CT_LOG_VERIFIER_H_ 94 #endif // NET_CERT_CT_LOG_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698