diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 02:53:09 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 02:53:09 +0000 |
commit | 44a016a843efffc53256c862c792e53d7909c802 (patch) | |
tree | 57a31ad697342085bbdb29b2f9bcd3e5f5d58cce /crypto/encryptor_nss.cc | |
parent | 98bc449977534905d2254d76686249e18603819e (diff) | |
download | chromium_src-44a016a843efffc53256c862c792e53d7909c802.zip chromium_src-44a016a843efffc53256c862c792e53d7909c802.tar.gz chromium_src-44a016a843efffc53256c862c792e53d7909c802.tar.bz2 |
Use base::StringPiece for input parameters in Encryptor, rather than std::string
R=wtc
BUG=none
TEST=crypto_unittests
Review URL: http://codereview.chromium.org/7230037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/encryptor_nss.cc')
-rw-r--r-- | crypto/encryptor_nss.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crypto/encryptor_nss.cc b/crypto/encryptor_nss.cc index c53fc10..c4610903 100644 --- a/crypto/encryptor_nss.cc +++ b/crypto/encryptor_nss.cc @@ -41,7 +41,9 @@ Encryptor::Encryptor() Encryptor::~Encryptor() { } -bool Encryptor::Init(SymmetricKey* key, Mode mode, const std::string& iv) { +bool Encryptor::Init(SymmetricKey* key, + Mode mode, + const base::StringPiece& iv) { DCHECK(key); DCHECK(CBC == mode || CTR == mode) << "Unsupported mode of operation"; @@ -75,7 +77,8 @@ bool Encryptor::Init(SymmetricKey* key, Mode mode, const std::string& iv) { return true; } -bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) { +bool Encryptor::Encrypt(const base::StringPiece& plaintext, + std::string* ciphertext) { ScopedPK11Context context(PK11_CreateContextBySymKey(GetMechanism(mode_), CKA_ENCRYPT, key_->key(), @@ -89,7 +92,8 @@ bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) { return Crypt(context.get(), plaintext, ciphertext); } -bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) { +bool Encryptor::Decrypt(const base::StringPiece& ciphertext, + std::string* plaintext) { if (ciphertext.empty()) return false; @@ -105,7 +109,8 @@ bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) { return Crypt(context.get(), ciphertext, plaintext); } -bool Encryptor::Crypt(PK11Context* context, const std::string& input, +bool Encryptor::Crypt(PK11Context* context, + const base::StringPiece& input, std::string* output) { size_t output_len = input.size() + AES_BLOCK_SIZE; CHECK(output_len > input.size()) << "Output size overflow"; @@ -145,7 +150,8 @@ bool Encryptor::Crypt(PK11Context* context, const std::string& input, return true; } -bool Encryptor::CryptCTR(PK11Context* context, const std::string& input, +bool Encryptor::CryptCTR(PK11Context* context, + const base::StringPiece& input, std::string* output) { if (!counter_.get()) { LOG(ERROR) << "Counter value not set in CTR mode."; |