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

Unified Diff: crypto/encryptor.h

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 | « no previous file | crypto/encryptor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor.h
diff --git a/crypto/encryptor.h b/crypto/encryptor.h
index 712a19c78b8aedc1f3207573964bea09cb4b7bbf..cfab6f284b902291662d42172e3f451ca628d30d 100644
--- a/crypto/encryptor.h
+++ b/crypto/encryptor.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
+#include "base/string_piece.h"
#include "build/build_config.h"
#include "crypto/crypto_api.h"
@@ -34,7 +35,7 @@ class CRYPTO_API Encryptor {
// Only 128-bits counter is supported in this class.
class Counter {
public:
- Counter(const std::string& counter);
+ Counter(const base::StringPiece& counter);
~Counter();
// Increment the counter value.
@@ -61,19 +62,19 @@ class CRYPTO_API Encryptor {
// key or the initialization vector cannot be used.
//
// When |mode| is CTR then |iv| should be empty.
- bool Init(SymmetricKey* key, Mode mode, const std::string& iv);
+ bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv);
// Encrypts |plaintext| into |ciphertext|.
- bool Encrypt(const std::string& plaintext, std::string* ciphertext);
+ bool Encrypt(const base::StringPiece& plaintext, std::string* ciphertext);
// Decrypts |ciphertext| into |plaintext|.
- bool Decrypt(const std::string& ciphertext, std::string* plaintext);
+ bool Decrypt(const base::StringPiece& ciphertext, std::string* plaintext);
// Sets the counter value when in CTR mode. Currently only 128-bits
// counter value is supported.
//
// Returns true only if update was successful.
- bool SetCounter(const std::string& counter);
+ bool SetCounter(const base::StringPiece& counter);
// TODO(albertb): Support streaming encryption.
@@ -107,21 +108,21 @@ class CRYPTO_API Encryptor {
#if defined(USE_OPENSSL)
bool Crypt(bool encrypt, // Pass true to encrypt, false to decrypt.
- const std::string& input,
+ const base::StringPiece& input,
std::string* output);
std::string iv_;
#elif defined(USE_NSS)
bool Crypt(PK11Context* context,
- const std::string& input,
+ const base::StringPiece& input,
std::string* output);
bool CryptCTR(PK11Context* context,
- const std::string& input,
+ const base::StringPiece& input,
std::string* output);
ScopedPK11Slot slot_;
ScopedSECItem param_;
#elif defined(OS_MACOSX)
bool Crypt(int /*CCOperation*/ op,
- const std::string& input,
+ const base::StringPiece& input,
std::string* output);
std::string iv_;
« no previous file with comments | « no previous file | crypto/encryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698