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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 size_t GetLengthInBytes() const; | 44 size_t GetLengthInBytes() const; |
45 | 45 |
46 private: | 46 private: |
47 union { | 47 union { |
48 uint32_t components32[4]; | 48 uint32_t components32[4]; |
49 uint64_t components64[2]; | 49 uint64_t components64[2]; |
50 } counter_; | 50 } counter_; |
51 }; | 51 }; |
52 | 52 |
53 Encryptor(); | 53 Encryptor(); |
54 virtual ~Encryptor(); | 54 ~Encryptor(); |
55 | 55 |
56 // Initializes the encryptor using |key| and |iv|. Returns false if either the | 56 // Initializes the encryptor using |key| and |iv|. Returns false if either the |
57 // key or the initialization vector cannot be used. | 57 // key or the initialization vector cannot be used. |
58 // | 58 // |
59 // If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be | 59 // If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be |
60 // empty. | 60 // empty. |
61 bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv); | 61 bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv); |
62 | 62 |
63 // Encrypts |plaintext| into |ciphertext|. |plaintext| may only be empty if | 63 // Encrypts |plaintext| into |ciphertext|. |plaintext| may only be empty if |
64 // the mode is CBC. | 64 // the mode is CBC. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 std::string* output); | 116 std::string* output); |
117 bool CryptCTR(bool do_encrypt, | 117 bool CryptCTR(bool do_encrypt, |
118 const base::StringPiece& input, | 118 const base::StringPiece& input, |
119 std::string* output); | 119 std::string* output); |
120 std::string iv_; | 120 std::string iv_; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace crypto | 123 } // namespace crypto |
124 | 124 |
125 #endif // CRYPTO_ENCRYPTOR_H_ | 125 #endif // CRYPTO_ENCRYPTOR_H_ |
OLD | NEW |