OLD | NEW |
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> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
| 11 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
11 #include "crypto/symmetric_key.h" | 14 #include "crypto/symmetric_key.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
13 | 16 |
14 TEST(EncryptorTest, EncryptDecrypt) { | 17 TEST(EncryptorTest, EncryptDecrypt) { |
15 scoped_ptr<crypto::SymmetricKey> key( | 18 scoped_ptr<crypto::SymmetricKey> key( |
16 crypto::SymmetricKey::DeriveKeyFromPassword( | 19 crypto::SymmetricKey::DeriveKeyFromPassword( |
17 crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256)); | 20 crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256)); |
18 EXPECT_TRUE(key.get()); | 21 EXPECT_TRUE(key.get()); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // | 525 // |
523 // Otherwise when using std::string as the other tests do, accesses several | 526 // Otherwise when using std::string as the other tests do, accesses several |
524 // bytes off the end of the buffer may fall inside the reservation of | 527 // bytes off the end of the buffer may fall inside the reservation of |
525 // the string and not be detected. | 528 // the string and not be detected. |
526 scoped_ptr<char[]> ciphertext(new char[1]); | 529 scoped_ptr<char[]> ciphertext(new char[1]); |
527 | 530 |
528 std::string plaintext; | 531 std::string plaintext; |
529 EXPECT_FALSE( | 532 EXPECT_FALSE( |
530 encryptor.Decrypt(base::StringPiece(ciphertext.get(), 1), &plaintext)); | 533 encryptor.Decrypt(base::StringPiece(ciphertext.get(), 1), &plaintext)); |
531 } | 534 } |
OLD | NEW |