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 #ifndef BASE_CRYPTO_ENCRYPTOR_H_ | 5 #ifndef CRYPTO_ENCRYPTOR_H_ |
6 #define BASE_CRYPTO_ENCRYPTOR_H_ | 6 #define CRYPTO_ENCRYPTOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/base_api.h" | |
12 #include "build/build_config.h" | 11 #include "build/build_config.h" |
13 | 12 |
14 #if defined(USE_NSS) | 13 #if defined(USE_NSS) |
15 #include "base/crypto/scoped_nss_types.h" | 14 #include "crypto/scoped_nss_types.h" |
16 #elif defined(OS_WIN) | 15 #elif defined(OS_WIN) |
17 #include "base/crypto/scoped_capi_types.h" | 16 #include "crypto/scoped_capi_types.h" |
18 #endif | 17 #endif |
19 | 18 |
20 namespace base { | 19 namespace crypto { |
21 | 20 |
22 class SymmetricKey; | 21 class SymmetricKey; |
23 | 22 |
24 class BASE_API Encryptor { | 23 class Encryptor { |
25 public: | 24 public: |
26 enum Mode { | 25 enum Mode { |
27 CBC | 26 CBC |
28 }; | 27 }; |
29 Encryptor(); | 28 Encryptor(); |
30 virtual ~Encryptor(); | 29 virtual ~Encryptor(); |
31 | 30 |
32 // Initializes the encryptor using |key| and |iv|. Returns false if either the | 31 // Initializes the encryptor using |key| and |iv|. Returns false if either the |
33 // key or the initialization vector cannot be used. | 32 // key or the initialization vector cannot be used. |
34 bool Init(SymmetricKey* key, Mode mode, const std::string& iv); | 33 bool Init(SymmetricKey* key, Mode mode, const std::string& iv); |
(...skipping 23 matching lines...) Expand all Loading... |
58 const std::string& input, | 57 const std::string& input, |
59 std::string* output); | 58 std::string* output); |
60 | 59 |
61 std::string iv_; | 60 std::string iv_; |
62 #elif defined(OS_WIN) | 61 #elif defined(OS_WIN) |
63 ScopedHCRYPTKEY capi_key_; | 62 ScopedHCRYPTKEY capi_key_; |
64 DWORD block_size_; | 63 DWORD block_size_; |
65 #endif | 64 #endif |
66 }; | 65 }; |
67 | 66 |
68 } // namespace base | 67 } // namespace crypto |
69 | 68 |
70 #endif // BASE_CRYPTO_ENCRYPTOR_H_ | 69 #endif // CRYPTO_ENCRYPTOR_H_ |
OLD | NEW |