summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authorrtenneti <rtenneti@chromium.org>2015-12-07 08:27:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-07 16:28:07 +0000
commit6486d0d7c119576d0ead5e55c41b2269a4b01cfc (patch)
tree78c36230a453d070d8a1d25d49ff6bbb89b940e3 /net/test
parente4a145b55cacf54dad5dfa1c87ac2658f4f9a84d (diff)
downloadchromium_src-6486d0d7c119576d0ead5e55c41b2269a4b01cfc.zip
chromium_src-6486d0d7c119576d0ead5e55c41b2269a4b01cfc.tar.gz
chromium_src-6486d0d7c119576d0ead5e55c41b2269a4b01cfc.tar.bz2
CT Verify test utilities change - Moved the following common functions
between ProofVerifierChromiumTest and MultiLogCTVerifierTest into ct_test_utils.cc. GetSCTListForTesting() GetSCTListWithInvalidSCT() CheckForSingleVerifiedSCTInResult(...) CheckForSCTOrigin(...) R=eranm@chromium.org, rch@chromium.org Review URL: https://codereview.chromium.org/1498983004 Cr-Commit-Position: refs/heads/master@{#363494}
Diffstat (limited to 'net/test')
-rw-r--r--net/test/ct_test_util.cc34
-rw-r--r--net/test/ct_test_util.h20
2 files changed, 52 insertions, 2 deletions
diff --git a/net/test/ct_test_util.cc b/net/test/ct_test_util.cc
index 3bd30ff..2ad827d 100644
--- a/net/test/ct_test_util.cc
+++ b/net/test/ct_test_util.cc
@@ -14,7 +14,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/cert/ct_serialization.h"
-#include "net/cert/signed_certificate_timestamp.h"
+#include "net/cert/ct_verify_result.h"
#include "net/cert/signed_tree_head.h"
#include "net/cert/x509_certificate.h"
@@ -329,6 +329,38 @@ std::string CreateConsistencyProofJsonString(
return consistency_proof_json;
}
+std::string GetSCTListForTesting() {
+ const std::string sct = ct::GetTestSignedCertificateTimestamp();
+ std::string sct_list;
+ ct::EncodeSCTListForTesting(sct, &sct_list);
+ return sct_list;
+}
+
+std::string GetSCTListWithInvalidSCT() {
+ std::string sct(ct::GetTestSignedCertificateTimestamp());
+
+ // Change a byte inside the Log ID part of the SCT so it does not match the
+ // log used in the tests.
+ sct[15] = 't';
+
+ std::string sct_list;
+ ct::EncodeSCTListForTesting(sct, &sct_list);
+ return sct_list;
+}
+
+bool CheckForSingleVerifiedSCTInResult(const ct::CTVerifyResult& result,
+ const std::string& log_description) {
+ return (result.verified_scts.size() == 1U) && result.invalid_scts.empty() &&
+ result.unknown_logs_scts.empty() &&
+ result.verified_scts[0]->log_description == log_description;
+}
+
+bool CheckForSCTOrigin(const ct::CTVerifyResult& result,
+ ct::SignedCertificateTimestamp::Origin origin) {
+ return (result.verified_scts.size() > 0) &&
+ (result.verified_scts[0]->origin == origin);
+}
+
} // namespace ct
} // namespace net
diff --git a/net/test/ct_test_util.h b/net/test/ct_test_util.h
index 5bb2d7a..c54c38b 100644
--- a/net/test/ct_test_util.h
+++ b/net/test/ct_test_util.h
@@ -9,14 +9,15 @@
#include <vector>
#include "base/memory/ref_counted.h"
+#include "net/cert/signed_certificate_timestamp.h"
namespace net {
namespace ct {
+struct CTVerifyResult;
struct DigitallySigned;
struct LogEntry;
-struct SignedCertificateTimestamp;
struct SignedTreeHead;
// Note: unless specified otherwise, all test data is taken from Certificate
@@ -91,6 +92,23 @@ std::string CreateSignedTreeHeadJsonString(size_t tree_size,
// the provided raw nodes (i.e. the raw nodes will be base64-encoded).
std::string CreateConsistencyProofJsonString(
const std::vector<std::string>& raw_nodes);
+
+// Returns SCTList for testing.
+std::string GetSCTListForTesting();
+
+// Returns a corrupted SCTList. This is done by changing a byte inside the
+// Log ID part of the SCT so it does not match the log used in the tests.
+std::string GetSCTListWithInvalidSCT();
+
+// Returns true if |log_description| is in the |result|'s |verified_scts| and
+// number of |verified_scts| in |result| is equal to 1.
+bool CheckForSingleVerifiedSCTInResult(const CTVerifyResult& result,
+ const std::string& log_description);
+
+// Returns true if |origin| is in the |result|'s |verified_scts|.
+bool CheckForSCTOrigin(const CTVerifyResult& result,
+ SignedCertificateTimestamp::Origin origin);
+
} // namespace ct
} // namespace net