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

Unified Diff: crypto/encryptor_openssl.cc

Issue 7230037: Use base::StringPiece for input parameters in Encryptor, rather than std::string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OpenSSL fix Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/encryptor_nss.cc ('k') | crypto/encryptor_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_openssl.cc
diff --git a/crypto/encryptor_openssl.cc b/crypto/encryptor_openssl.cc
index 7b1e13fc5dfd29ea62c94e62d8d65f6ed173d5ce..65131818243edbf48733b84015e5c36d36cc2a35 100644
--- a/crypto/encryptor_openssl.cc
+++ b/crypto/encryptor_openssl.cc
@@ -52,7 +52,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_EQ(CBC, mode);
@@ -65,20 +67,22 @@ bool Encryptor::Init(SymmetricKey* key, Mode mode, const std::string& iv) {
key_ = key;
mode_ = mode;
- iv_ = iv;
+ iv.CopyToString(&iv_);
return true;
}
-bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) {
+bool Encryptor::Encrypt(const base::StringPiece& plaintext,
+ std::string* ciphertext) {
return Crypt(true, plaintext, ciphertext);
}
-bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) {
+bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
+ std::string* plaintext) {
return Crypt(false, ciphertext, plaintext);
}
bool Encryptor::Crypt(bool do_encrypt,
- const std::string& input,
+ const base::StringPiece& input,
std::string* output) {
DCHECK(key_); // Must call Init() before En/De-crypt.
// Work on the result in a local variable, and then only transfer it to
« no previous file with comments | « crypto/encryptor_nss.cc ('k') | crypto/encryptor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698