Index: crypto/symmetric_key.h |
diff --git a/crypto/symmetric_key.h b/crypto/symmetric_key.h |
index 2b2e2ce304fbb3c8f066cbf586663766ec063852..7494634b5ef5ad25693d87e82323234d6d05b853 100644 |
--- a/crypto/symmetric_key.h |
+++ b/crypto/symmetric_key.h |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
+#include <memory> |
#include <string> |
#include "base/macros.h" |
@@ -31,25 +32,28 @@ class CRYPTO_EXPORT SymmetricKey { |
// Generates a random key suitable to be used with |algorithm| and of |
// |key_size_in_bits| bits. |key_size_in_bits| must be a multiple of 8. |
// The caller is responsible for deleting the returned SymmetricKey. |
- static SymmetricKey* GenerateRandomKey(Algorithm algorithm, |
- size_t key_size_in_bits); |
+ static std::unique_ptr<SymmetricKey> GenerateRandomKey( |
+ Algorithm algorithm, |
+ size_t key_size_in_bits); |
// Derives a key from the supplied password and salt using PBKDF2, suitable |
// for use with specified |algorithm|. Note |algorithm| is not the algorithm |
// used to derive the key from the password. |key_size_in_bits| must be a |
// multiple of 8. The caller is responsible for deleting the returned |
// SymmetricKey. |
- static SymmetricKey* DeriveKeyFromPassword(Algorithm algorithm, |
- const std::string& password, |
- const std::string& salt, |
- size_t iterations, |
- size_t key_size_in_bits); |
+ static std::unique_ptr<SymmetricKey> DeriveKeyFromPassword( |
+ Algorithm algorithm, |
+ const std::string& password, |
+ const std::string& salt, |
+ size_t iterations, |
+ size_t key_size_in_bits); |
// Imports an array of key bytes in |raw_key|. This key may have been |
// generated by GenerateRandomKey or DeriveKeyFromPassword and exported with |
// GetRawKey, or via another compatible method. The key must be of suitable |
// size for use with |algorithm|. The caller owns the returned SymmetricKey. |
- static SymmetricKey* Import(Algorithm algorithm, const std::string& raw_key); |
+ static std::unique_ptr<SymmetricKey> Import(Algorithm algorithm, |
+ const std::string& raw_key); |
const std::string& key() { return key_; } |
@@ -59,7 +63,8 @@ class CRYPTO_EXPORT SymmetricKey { |
bool GetRawKey(std::string* raw_key); |
private: |
- SymmetricKey() {} |
+ SymmetricKey(); |
+ |
std::string key_; |
DISALLOW_COPY_AND_ASSIGN(SymmetricKey); |