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

Unified Diff: net/cert/ct_log_verifier.cc

Issue 230713002: Certificate Transparency: Parse Signed Tree Heads and validate them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicitly exporting symbol Created 6 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/ct_log_verifier.cc
diff --git a/net/cert/ct_log_verifier.cc b/net/cert/ct_log_verifier.cc
index 1c9374dfd941baf7bcff7bad5cfa8fbda633f788..85d0b20cbd07479a408439f75c1fbaa254c30485 100644
--- a/net/cert/ct_log_verifier.cc
+++ b/net/cert/ct_log_verifier.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "net/cert/ct_serialization.h"
+#include "net/cert/signed_tree_head.h"
namespace net {
@@ -26,17 +27,8 @@ bool CTLogVerifier::Verify(const ct::LogEntry& entry,
return false;
}
- if (sct.signature.hash_algorithm != hash_algorithm_) {
- DVLOG(1) << "Mismatched hash algorithm. Expected " << hash_algorithm_
- << ", got " << sct.signature.hash_algorithm << ".";
- return false;
- }
-
- if (sct.signature.signature_algorithm != signature_algorithm_) {
- DVLOG(1) << "Mismatched sig algorithm. Expected " << signature_algorithm_
- << ", got " << sct.signature.signature_algorithm << ".";
+ if (!SignatureParametersMatch(sct.signature))
return false;
- }
std::string serialized_log_entry;
if (!ct::EncodeLogEntry(entry, &serialized_log_entry)) {
@@ -53,4 +45,36 @@ bool CTLogVerifier::Verify(const ct::LogEntry& entry,
return VerifySignature(serialized_data, sct.signature.signature_data);
}
+bool CTLogVerifier::SetSignedTreeHead(
+ scoped_ptr<ct::SignedTreeHead> signed_tree_head) {
+ if (!SignatureParametersMatch(signed_tree_head->signature))
+ return false;
+
+ std::string serialized_data;
+ ct::EncodeTreeHeadSignature(*signed_tree_head.get(), &serialized_data);
+ if (VerifySignature(serialized_data,
+ signed_tree_head->signature.signature_data)) {
+ sth_.reset(signed_tree_head.release());
+ return true;
+ }
+ return false;
+}
+
+bool CTLogVerifier::SignatureParametersMatch(
+ const ct::DigitallySigned& signature) {
Ryan Sleevi 2014/04/25 23:33:19 Should this be a helper on ct::DigitallySigned?
Eran Messeri 2014/04/29 15:22:24 Done.
+ if (signature.hash_algorithm != hash_algorithm_) {
+ DVLOG(1) << "Mismatched hash algorithm. Expected " << hash_algorithm_
+ << ", got " << signature.hash_algorithm << ".";
+ return false;
+ }
+
+ if (signature.signature_algorithm != signature_algorithm_) {
+ DVLOG(1) << "Mismatched sig algorithm. Expected " << signature_algorithm_
+ << ", got " << signature.signature_algorithm << ".";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698