Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: crypto/encryptor.h

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/utils.cc ('k') | crypto/encryptor_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CRYPTO_ENCRYPTOR_H_ 5 #ifndef CRYPTO_ENCRYPTOR_H_
6 #define CRYPTO_ENCRYPTOR_H_ 6 #define CRYPTO_ENCRYPTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 uint64 components64[2]; 54 uint64 components64[2];
55 } counter_; 55 } counter_;
56 }; 56 };
57 57
58 Encryptor(); 58 Encryptor();
59 virtual ~Encryptor(); 59 virtual ~Encryptor();
60 60
61 // Initializes the encryptor using |key| and |iv|. Returns false if either the 61 // Initializes the encryptor using |key| and |iv|. Returns false if either the
62 // key or the initialization vector cannot be used. 62 // key or the initialization vector cannot be used.
63 // 63 //
64 // When |mode| is CTR then |iv| should be empty. 64 // If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be
65 // empty.
65 bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv); 66 bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv);
66 67
67 // Encrypts |plaintext| into |ciphertext|. 68 // Encrypts |plaintext| into |ciphertext|. |plaintext| may only be empty if
69 // the mode is CBC.
68 bool Encrypt(const base::StringPiece& plaintext, std::string* ciphertext); 70 bool Encrypt(const base::StringPiece& plaintext, std::string* ciphertext);
69 71
70 // Decrypts |ciphertext| into |plaintext|. 72 // Decrypts |ciphertext| into |plaintext|. |ciphertext| must not be empty.
71 bool Decrypt(const base::StringPiece& ciphertext, std::string* plaintext); 73 bool Decrypt(const base::StringPiece& ciphertext, std::string* plaintext);
72 74
73 // Sets the counter value when in CTR mode. Currently only 128-bits 75 // Sets the counter value when in CTR mode. Currently only 128-bits
74 // counter value is supported. 76 // counter value is supported.
75 // 77 //
76 // Returns true only if update was successful. 78 // Returns true only if update was successful.
77 bool SetCounter(const base::StringPiece& counter); 79 bool SetCounter(const base::StringPiece& counter);
78 80
79 // TODO(albertb): Support streaming encryption. 81 // TODO(albertb): Support streaming encryption.
80 82
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 std::string iv_; 130 std::string iv_;
129 #elif defined(OS_WIN) 131 #elif defined(OS_WIN)
130 ScopedHCRYPTKEY capi_key_; 132 ScopedHCRYPTKEY capi_key_;
131 DWORD block_size_; 133 DWORD block_size_;
132 #endif 134 #endif
133 }; 135 };
134 136
135 } // namespace crypto 137 } // namespace crypto
136 138
137 #endif // CRYPTO_ENCRYPTOR_H_ 139 #endif // CRYPTO_ENCRYPTOR_H_
OLDNEW
« no previous file with comments | « chrome_frame/utils.cc ('k') | crypto/encryptor_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698