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

Unified Diff: crypto/ghash_unittest.cc

Issue 19619003: net: fix buffer overflow in GHASH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « crypto/ghash.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/ghash_unittest.cc
diff --git a/crypto/ghash_unittest.cc b/crypto/ghash_unittest.cc
index c491f76699bb6c9f692a46b7557cae9e97361cd1..459e177c817d25e3593c6b9770500311ad07e0d7 100644
--- a/crypto/ghash_unittest.cc
+++ b/crypto/ghash_unittest.cc
@@ -117,19 +117,27 @@ TEST(GaloisHash, TestCases) {
}
}
-TEST(GaloisHash, TestCasesByteAtATime) {
+TEST(GaloisHash, VaryLengths) {
uint8 out[16];
- for (size_t i = 0; i < arraysize(kTestCases); ++i) {
- const TestCase& test = kTestCases[i];
-
- GaloisHash hash(test.key);
- for (size_t i = 0; i < test.additional_length; ++i)
- hash.UpdateAdditional(test.additional + i, 1);
- for (size_t i = 0; i < test.ciphertext_length; ++i)
- hash.UpdateCiphertext(test.ciphertext + i, 1);
- hash.Finish(out, sizeof(out));
- EXPECT_TRUE(0 == memcmp(out, test.expected, 16));
+ for (size_t chunk_size = 1; chunk_size < 16; chunk_size++) {
+ for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+ const TestCase& test = kTestCases[i];
+
+ GaloisHash hash(test.key);
+ for (size_t i = 0; i < test.additional_length;) {
+ size_t n = std::min(test.additional_length - i, chunk_size);
+ hash.UpdateAdditional(test.additional + i, n);
+ i += n;
+ }
+ for (size_t i = 0; i < test.ciphertext_length;) {
+ size_t n = std::min(test.ciphertext_length - i, chunk_size);
+ hash.UpdateCiphertext(test.ciphertext + i, n);
+ i += n;
+ }
+ hash.Finish(out, sizeof(out));
+ EXPECT_TRUE(0 == memcmp(out, test.expected, 16));
+ }
}
}
« no previous file with comments | « crypto/ghash.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698