| OLD | NEW |
| 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 "base/crypto/encryptor.h" | 5 #include "crypto/encryptor.h" |
| 6 | 6 |
| 7 #include <CommonCrypto/CommonCryptor.h> | 7 #include <CommonCrypto/CommonCryptor.h> |
| 8 | 8 |
| 9 #include "base/crypto/symmetric_key.h" | |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "crypto/symmetric_key.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace crypto { |
| 14 | 14 |
| 15 Encryptor::Encryptor() | 15 Encryptor::Encryptor() |
| 16 : key_(NULL), | 16 : key_(NULL), |
| 17 mode_(CBC) { | 17 mode_(CBC) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 Encryptor::~Encryptor() { | 20 Encryptor::~Encryptor() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool Encryptor::Init(SymmetricKey* key, Mode mode, const std::string& iv) { | 23 bool Encryptor::Init(SymmetricKey* key, Mode mode, const std::string& iv) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) { | 68 bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) { |
| 69 return Crypt(kCCEncrypt, plaintext, ciphertext); | 69 return Crypt(kCCEncrypt, plaintext, ciphertext); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) { | 72 bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) { |
| 73 return Crypt(kCCDecrypt, ciphertext, plaintext); | 73 return Crypt(kCCDecrypt, ciphertext, plaintext); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace base | 76 } // namespace crypto |
| OLD | NEW |