| 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 #ifndef CRYPTO_ENCRYPTOR_H_ | 5 #ifndef CRYPTO_ENCRYPTOR_H_ |
| 6 #define CRYPTO_ENCRYPTOR_H_ | 6 #define CRYPTO_ENCRYPTOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "crypto/crypto_export.h" | 16 #include "crypto/crypto_export.h" |
| 17 | 17 |
| 18 #if !defined(USE_OPENSSL) | |
| 19 #include "crypto/scoped_nss_types.h" | |
| 20 #endif | |
| 21 | |
| 22 namespace crypto { | 18 namespace crypto { |
| 23 | 19 |
| 24 class SymmetricKey; | 20 class SymmetricKey; |
| 25 | 21 |
| 26 class CRYPTO_EXPORT Encryptor { | 22 class CRYPTO_EXPORT Encryptor { |
| 27 public: | 23 public: |
| 28 enum Mode { | 24 enum Mode { |
| 29 CBC, | 25 CBC, |
| 30 CTR, | 26 CTR, |
| 31 }; | 27 }; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // |ciphertext|. |ciphertext| must have at least |plaintext_len| bytes. | 104 // |ciphertext|. |ciphertext| must have at least |plaintext_len| bytes. |
| 109 void MaskMessage(const void* plaintext, | 105 void MaskMessage(const void* plaintext, |
| 110 size_t plaintext_len, | 106 size_t plaintext_len, |
| 111 const void* mask, | 107 const void* mask, |
| 112 void* ciphertext) const; | 108 void* ciphertext) const; |
| 113 | 109 |
| 114 SymmetricKey* key_; | 110 SymmetricKey* key_; |
| 115 Mode mode_; | 111 Mode mode_; |
| 116 std::unique_ptr<Counter> counter_; | 112 std::unique_ptr<Counter> counter_; |
| 117 | 113 |
| 118 #if defined(USE_OPENSSL) | |
| 119 bool Crypt(bool do_encrypt, // Pass true to encrypt, false to decrypt. | 114 bool Crypt(bool do_encrypt, // Pass true to encrypt, false to decrypt. |
| 120 const base::StringPiece& input, | 115 const base::StringPiece& input, |
| 121 std::string* output); | 116 std::string* output); |
| 122 bool CryptCTR(bool do_encrypt, | 117 bool CryptCTR(bool do_encrypt, |
| 123 const base::StringPiece& input, | 118 const base::StringPiece& input, |
| 124 std::string* output); | 119 std::string* output); |
| 125 std::string iv_; | 120 std::string iv_; |
| 126 #else | |
| 127 bool Crypt(PK11Context* context, | |
| 128 const base::StringPiece& input, | |
| 129 std::string* output); | |
| 130 bool CryptCTR(PK11Context* context, | |
| 131 const base::StringPiece& input, | |
| 132 std::string* output); | |
| 133 ScopedSECItem param_; | |
| 134 #endif | |
| 135 }; | 121 }; |
| 136 | 122 |
| 137 } // namespace crypto | 123 } // namespace crypto |
| 138 | 124 |
| 139 #endif // CRYPTO_ENCRYPTOR_H_ | 125 #endif // CRYPTO_ENCRYPTOR_H_ |
| OLD | NEW |