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

Side by Side Diff: base/crypto/signature_verifier_unittest.cc

Issue 69010: Disable the negative test cases in the test... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Only disable the EXPECT_FALSE(ok) lines Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/data/purify/base_unittests.exe.gtest.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "base/crypto/signature_verifier.h" 5 #include "base/crypto/signature_verifier.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 TEST(SignatureVerifierTest, BasicTest) { 8 TEST(SignatureVerifierTest, BasicTest) {
9 // The input data in this test comes from real certificates. 9 // The input data in this test comes from real certificates.
10 // 10 //
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 uint8 bad_tbs_certificate[sizeof(tbs_certificate)]; 231 uint8 bad_tbs_certificate[sizeof(tbs_certificate)];
232 memcpy(bad_tbs_certificate, tbs_certificate, sizeof(tbs_certificate)); 232 memcpy(bad_tbs_certificate, tbs_certificate, sizeof(tbs_certificate));
233 bad_tbs_certificate[10] += 1; // Corrupt one byte of the data. 233 bad_tbs_certificate[10] += 1; // Corrupt one byte of the data.
234 ok = verifier.VerifyInit(signature_algorithm, 234 ok = verifier.VerifyInit(signature_algorithm,
235 sizeof(signature_algorithm), 235 sizeof(signature_algorithm),
236 signature, sizeof(signature), 236 signature, sizeof(signature),
237 public_key_info, sizeof(public_key_info)); 237 public_key_info, sizeof(public_key_info));
238 EXPECT_TRUE(ok); 238 EXPECT_TRUE(ok);
239 verifier.VerifyUpdate(bad_tbs_certificate, sizeof(bad_tbs_certificate)); 239 verifier.VerifyUpdate(bad_tbs_certificate, sizeof(bad_tbs_certificate));
240 ok = verifier.VerifyFinal(); 240 ok = verifier.VerifyFinal();
241
242 // Purify disables digital signature verification, causing the Windows
243 // CryptoAPI function CryptVerifySignature to always succeed. So we can't
244 // check the signature verification results of the negative tests when
245 // running inside Purify. See http://crbug.com/10031.
246 #ifndef PURIFY
241 EXPECT_FALSE(ok); 247 EXPECT_FALSE(ok);
248 #endif
242 249
243 // Test 4: verify a bad signature. 250 // Test 4: verify a bad signature.
244 uint8 bad_signature[sizeof(signature)]; 251 uint8 bad_signature[sizeof(signature)];
245 memcpy(bad_signature, signature, sizeof(signature)); 252 memcpy(bad_signature, signature, sizeof(signature));
246 bad_signature[10] += 1; // Corrupt one byte of the signature. 253 bad_signature[10] += 1; // Corrupt one byte of the signature.
247 ok = verifier.VerifyInit(signature_algorithm, 254 ok = verifier.VerifyInit(signature_algorithm,
248 sizeof(signature_algorithm), 255 sizeof(signature_algorithm),
249 bad_signature, sizeof(bad_signature), 256 bad_signature, sizeof(bad_signature),
250 public_key_info, sizeof(public_key_info)); 257 public_key_info, sizeof(public_key_info));
251 258
252 // A crypto library (e.g., NSS) may detect that the signature is corrupted 259 // A crypto library (e.g., NSS) may detect that the signature is corrupted
253 // and cause VerifyInit to return false, so it is fine for 'ok' to be false. 260 // and cause VerifyInit to return false, so it is fine for 'ok' to be false.
254 if (ok) { 261 if (ok) {
255 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate)); 262 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate));
256 ok = verifier.VerifyFinal(); 263 ok = verifier.VerifyFinal();
264 #ifndef PURIFY
257 EXPECT_FALSE(ok); 265 EXPECT_FALSE(ok);
266 #endif
258 } 267 }
259 } 268 }
OLDNEW
« no previous file with comments | « no previous file | base/data/purify/base_unittests.exe.gtest.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698