Use std::move for key strings.
[ Cherry-pick of v19 http://go/wvgerrit/219351 ] [ Merge of http://go/wvgerrit/219455 ] Coverity discovered an oppertunity to use the C++'s move semantics for the prov 4.0 keys. A similar possibility was available for the matching wrapped key. The CryptoWrappedKey class was updated to enable moving of the wrapped key as well. Bug: 406539167 Bug: 391469176 Change-Id: I7d76013638c220fc81d6d9c42add2516abd7374a
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#define WVCDM_CORE_CRYPTO_WRAPPED_KEY_H_
|
#define WVCDM_CORE_CRYPTO_WRAPPED_KEY_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ class CryptoWrappedKey {
|
|||||||
CryptoWrappedKey() {}
|
CryptoWrappedKey() {}
|
||||||
CryptoWrappedKey(Type type, const std::string& key)
|
CryptoWrappedKey(Type type, const std::string& key)
|
||||||
: type_(type), key_(key) {}
|
: type_(type), key_(key) {}
|
||||||
|
CryptoWrappedKey(Type type, std::string&& key)
|
||||||
|
: type_(type), key_(std::move(key)) {}
|
||||||
|
|
||||||
Type type() const { return type_; }
|
Type type() const { return type_; }
|
||||||
void set_type(Type type) { type_ = type; }
|
void set_type(Type type) { type_ = type; }
|
||||||
@@ -26,6 +29,7 @@ class CryptoWrappedKey {
|
|||||||
// Mutable reference getter for passing to OMECrypto.
|
// Mutable reference getter for passing to OMECrypto.
|
||||||
std::string& key() { return key_; }
|
std::string& key() { return key_; }
|
||||||
void set_key(const std::string& key) { key_ = key; }
|
void set_key(const std::string& key) { key_ = key; }
|
||||||
|
void set_key(std::string&& key) { key_ = std::move(key); }
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
type_ = kUninitialized;
|
type_ = kUninitialized;
|
||||||
|
|||||||
@@ -651,10 +651,10 @@ CdmResponseType CertificateProvisioning::GetProvisioning40RequestInternal(
|
|||||||
// Need the wrapped Prov 4.0 private key to store once the response
|
// Need the wrapped Prov 4.0 private key to store once the response
|
||||||
// is received. The wrapped key is not available in the response.
|
// is received. The wrapped key is not available in the response.
|
||||||
prov40_wrapped_private_key_ =
|
prov40_wrapped_private_key_ =
|
||||||
CryptoWrappedKey(private_key_type, wrapped_private_key);
|
CryptoWrappedKey(private_key_type, std::move(wrapped_private_key));
|
||||||
// Store the public key from the request. This is used to match
|
// Store the public key from the request. This is used to match
|
||||||
// up the response with the most recently generated request.
|
// up the response with the most recently generated request.
|
||||||
prov40_public_key_ = public_key;
|
prov40_public_key_ = std::move(public_key);
|
||||||
|
|
||||||
state_ = is_oem_prov_request ? kOemRequestSent : kDrmRequestSent;
|
state_ = is_oem_prov_request ? kOemRequestSent : kDrmRequestSent;
|
||||||
return CdmResponseType(NO_ERROR);
|
return CdmResponseType(NO_ERROR);
|
||||||
|
|||||||
Reference in New Issue
Block a user