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

Side by Side Diff: crypto/signature_verifier_unittest.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
OLDNEW
1 // Copyright (c) 2009 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 "base/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 //
11 // tbs_certificate ("to-be-signed certificate", the part of a certificate 11 // tbs_certificate ("to-be-signed certificate", the part of a certificate
12 // that is signed), signature_algorithm, and algorithm come from the 12 // that is signed), signature_algorithm, and algorithm come from the
13 // certificate of bugs.webkit.org. 13 // certificate of bugs.webkit.org.
14 // 14 //
15 // public_key_info comes from the certificate of the issuer, Go Daddy Secure 15 // public_key_info comes from the certificate of the issuer, Go Daddy Secure
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 0xcc, 0x14, 0x39, 0xe2, 0x36, 0x85, 0xb5, 0x7e, 0x1a, 0x37, 193 0xcc, 0x14, 0x39, 0xe2, 0x36, 0x85, 0xb5, 0x7e, 0x1a, 0x37,
194 0xfd, 0x16, 0xf6, 0x71, 0x11, 0x9a, 0x74, 0x30, 0x16, 0xfe, 194 0xfd, 0x16, 0xf6, 0x71, 0x11, 0x9a, 0x74, 0x30, 0x16, 0xfe,
195 0x13, 0x94, 0xa3, 0x3f, 0x84, 0x0d, 0x4f, 195 0x13, 0x94, 0xa3, 0x3f, 0x84, 0x0d, 0x4f,
196 // public exponent 196 // public exponent
197 0x02, 0x03, // an INTEGER of length 3 197 0x02, 0x03, // an INTEGER of length 3
198 0x01, 0x00, 0x01 198 0x01, 0x00, 0x01
199 }; 199 };
200 200
201 // We use the signature verifier to perform four signature verification 201 // We use the signature verifier to perform four signature verification
202 // tests. 202 // tests.
203 base::SignatureVerifier verifier; 203 crypto::SignatureVerifier verifier;
204 bool ok; 204 bool ok;
205 205
206 // Test 1: feed all of the data to the verifier at once (a single 206 // Test 1: feed all of the data to the verifier at once (a single
207 // VerifyUpdate call). 207 // VerifyUpdate call).
208 ok = verifier.VerifyInit(signature_algorithm, 208 ok = verifier.VerifyInit(signature_algorithm,
209 sizeof(signature_algorithm), 209 sizeof(signature_algorithm),
210 signature, sizeof(signature), 210 signature, sizeof(signature),
211 public_key_info, sizeof(public_key_info)); 211 public_key_info, sizeof(public_key_info));
212 EXPECT_TRUE(ok); 212 EXPECT_TRUE(ok);
213 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate)); 213 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // 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
260 // 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.
261 if (ok) { 261 if (ok) {
262 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate)); 262 verifier.VerifyUpdate(tbs_certificate, sizeof(tbs_certificate));
263 ok = verifier.VerifyFinal(); 263 ok = verifier.VerifyFinal();
264 #ifndef PURIFY 264 #ifndef PURIFY
265 EXPECT_FALSE(ok); 265 EXPECT_FALSE(ok);
266 #endif 266 #endif
267 } 267 }
268 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698