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

Side by Side Diff: crypto/signature_verifier_unittest.cc

Issue 7528010: Remove Purify and Quantify (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "crypto/signature_verifier.h" 5 #include "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
247 EXPECT_FALSE(ok); 241 EXPECT_FALSE(ok);
248 #endif
249 242
250 // Test 4: verify a bad signature. 243 // Test 4: verify a bad signature.
251 uint8 bad_signature[sizeof(signature)]; 244 uint8 bad_signature[sizeof(signature)];
252 memcpy(bad_signature, signature, sizeof(signature)); 245 memcpy(bad_signature, signature, sizeof(signature));
253 bad_signature[10] += 1; // Corrupt one byte of the signature. 246 bad_signature[10] += 1; // Corrupt one byte of the signature.
254 ok = verifier.VerifyInit(signature_algorithm, 247 ok = verifier.VerifyInit(signature_algorithm,
255 sizeof(signature_algorithm), 248 sizeof(signature_algorithm),
256 bad_signature, sizeof(bad_signature), 249 bad_signature, sizeof(bad_signature),
257 public_key_info, sizeof(public_key_info)); 250 public_key_info, sizeof(public_key_info));
258 251
259 // A crypto library (e.g., NSS) may detect that the signature is corrupted 252 // A crypto library (e.g., NSS) may detect that the signature is corrupted
260 // and cause VerifyInit to return false, so it is fine for 'ok' to be false. 253 // and cause VerifyInit to return false, so it is fine for 'ok' to be false.
261 if (ok) { 254 if (ok) {
262 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate)); 255 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate));
263 ok = verifier.VerifyFinal(); 256 ok = verifier.VerifyFinal();
264 #ifndef PURIFY
265 EXPECT_FALSE(ok); 257 EXPECT_FALSE(ok);
266 #endif
267 } 258 }
268 } 259 }
OLDNEW
« no previous file with comments | « content/browser/resolve_proxy_msg_helper_unittest.cc ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698