summaryrefslogtreecommitdiffstats
path: root/crypto/encryptor.h
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 20:06:18 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 20:06:18 +0000
commitfdce4788af32cb9af8d77361cfddb96249263437 (patch)
tree30c6e4b04a7f46658a57a1265729e0b5ebd2de10 /crypto/encryptor.h
parent7d1025eeb76f1fe0e7bfe19f9f23b64974a63820 (diff)
downloadchromium_src-fdce4788af32cb9af8d77361cfddb96249263437.zip
chromium_src-fdce4788af32cb9af8d77361cfddb96249263437.tar.gz
chromium_src-fdce4788af32cb9af8d77361cfddb96249263437.tar.bz2
ake string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the without-'\0' string is non-empty. This replaces the conditional code added recently that makes this case return NULL. It's easier to understand if it's simply an error to call WriteInto() in this case at all.
Add DCHECK()s or conditionals as appropriate to callers in order to ensure this assertion holds. BUG=none TEST=none Review URL: http://codereview.chromium.org/8418034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/encryptor.h')
-rw-r--r--crypto/encryptor.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/encryptor.h b/crypto/encryptor.h
index a407266..6b23619 100644
--- a/crypto/encryptor.h
+++ b/crypto/encryptor.h
@@ -61,13 +61,15 @@ class CRYPTO_EXPORT Encryptor {
// Initializes the encryptor using |key| and |iv|. Returns false if either the
// key or the initialization vector cannot be used.
//
- // When |mode| is CTR then |iv| should be empty.
+ // If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be
+ // empty.
bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv);
- // Encrypts |plaintext| into |ciphertext|.
+ // Encrypts |plaintext| into |ciphertext|. |plaintext| may only be empty if
+ // the mode is CBC.
bool Encrypt(const base::StringPiece& plaintext, std::string* ciphertext);
- // Decrypts |ciphertext| into |plaintext|.
+ // Decrypts |ciphertext| into |plaintext|. |ciphertext| must not be empty.
bool Decrypt(const base::StringPiece& ciphertext, std::string* plaintext);
// Sets the counter value when in CTR mode. Currently only 128-bits