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

Side by Side Diff: crypto/encryptor_unittest.cc

Issue 2677583002: Fix non-noise cpplint errors in //crypto. (Closed)
Patch Set: fix p224_unittest.cc Created 3 years, 10 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
« no previous file with comments | « crypto/encryptor.cc ('k') | crypto/hmac.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/encryptor.h" 5 #include "crypto/encryptor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 318 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
319 unsigned char buf[16]; 319 unsigned char buf[16];
320 320
321 // Increment 10 times. 321 // Increment 10 times.
322 crypto::Encryptor::Counter counter1( 322 crypto::Encryptor::Counter counter1(
323 std::string(reinterpret_cast<const char*>(kTest1), kCounterSize)); 323 std::string(reinterpret_cast<const char*>(kTest1), kCounterSize));
324 for (int i = 0; i < 10; ++i) 324 for (int i = 0; i < 10; ++i)
325 counter1.Increment(); 325 counter1.Increment();
326 counter1.Write(buf); 326 counter1.Write(buf);
327 EXPECT_EQ(0, memcmp(buf, kTest1, 15)); 327 EXPECT_EQ(0, memcmp(buf, kTest1, 15));
328 EXPECT_TRUE(buf[15] == 10); 328 EXPECT_EQ(10, buf[15]);
329 329
330 // Check corner cases. 330 // Check corner cases.
331 const unsigned char kTest2[] = { 331 const unsigned char kTest2[] = {
332 0, 0, 0, 0, 0, 0, 0, 0, 332 0, 0, 0, 0, 0, 0, 0, 0,
333 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 333 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
334 }; 334 };
335 const unsigned char kExpect2[] = 335 const unsigned char kExpect2[] =
336 {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}; 336 {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
337 crypto::Encryptor::Counter counter2( 337 crypto::Encryptor::Counter counter2(
338 std::string(reinterpret_cast<const char*>(kTest2), kCounterSize)); 338 std::string(reinterpret_cast<const char*>(kTest2), kCounterSize));
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // 523 //
524 // Otherwise when using std::string as the other tests do, accesses several 524 // Otherwise when using std::string as the other tests do, accesses several
525 // bytes off the end of the buffer may fall inside the reservation of 525 // bytes off the end of the buffer may fall inside the reservation of
526 // the string and not be detected. 526 // the string and not be detected.
527 std::unique_ptr<char[]> ciphertext(new char[1]); 527 std::unique_ptr<char[]> ciphertext(new char[1]);
528 528
529 std::string plaintext; 529 std::string plaintext;
530 EXPECT_FALSE( 530 EXPECT_FALSE(
531 encryptor.Decrypt(base::StringPiece(ciphertext.get(), 1), &plaintext)); 531 encryptor.Decrypt(base::StringPiece(ciphertext.get(), 1), &plaintext));
532 } 532 }
OLDNEW
« no previous file with comments | « crypto/encryptor.cc ('k') | crypto/hmac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698