SymmetricKey::GetRawKey/key are now const methods.
instance and should have been const. Making this change also allowed for several other methods to pass const SymmetricKey pointers where previously they were non-const. SymmetricKey: :GetRawKey() and SymmetricKey::key() did not modify the Change-Id: I937e477f91870a1026c2c0aaf767a2e7d5e0ed42 Reviewed-on: https://chromium-review.googlesource.com/529746 Reviewed-by: Adam Langley <agl@chromium.org> Reviewed-by: Luke Halliwell <halliwell@chromium.org> Reviewed-by: Xiaohan Wang <xhwang@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Commit-Queue: Chris Mumford <cmumford@chromium.org> Cr-Commit-Position: refs/heads/master@{#478693}
This commit is contained in:

committed by
Commit Bot

parent
049b2a8688
commit
ea3b6c196c
chrome/browser/chromeos/settings
chromecast/media/base
crypto
media/cdm
@ -75,7 +75,7 @@ std::unique_ptr<crypto::SymmetricKey> CryptohomeTokenEncryptor::PassphraseToKey(
|
||||
}
|
||||
|
||||
std::string CryptohomeTokenEncryptor::EncryptTokenWithKey(
|
||||
crypto::SymmetricKey* key,
|
||||
const crypto::SymmetricKey* key,
|
||||
const std::string& salt,
|
||||
const std::string& token) {
|
||||
crypto::Encryptor encryptor;
|
||||
@ -97,7 +97,7 @@ std::string CryptohomeTokenEncryptor::EncryptTokenWithKey(
|
||||
}
|
||||
|
||||
std::string CryptohomeTokenEncryptor::DecryptTokenWithKey(
|
||||
crypto::SymmetricKey* key,
|
||||
const crypto::SymmetricKey* key,
|
||||
const std::string& salt,
|
||||
const std::string& encrypted_token_hex) {
|
||||
std::vector<uint8_t> encrypted_token_bytes;
|
||||
|
@ -52,12 +52,12 @@ class CryptohomeTokenEncryptor : public TokenEncryptor {
|
||||
const std::string& salt);
|
||||
|
||||
// Encrypts (AES) the token given |key| and |salt|.
|
||||
std::string EncryptTokenWithKey(crypto::SymmetricKey* key,
|
||||
std::string EncryptTokenWithKey(const crypto::SymmetricKey* key,
|
||||
const std::string& salt,
|
||||
const std::string& token);
|
||||
|
||||
// Decrypts (AES) hex encoded encrypted token given |key| and |salt|.
|
||||
std::string DecryptTokenWithKey(crypto::SymmetricKey* key,
|
||||
std::string DecryptTokenWithKey(const crypto::SymmetricKey* key,
|
||||
const std::string& salt,
|
||||
const std::string& encrypted_token_hex);
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace chromecast {
|
||||
namespace media {
|
||||
|
||||
DecryptContextImplClearKey::DecryptContextImplClearKey(
|
||||
crypto::SymmetricKey* key)
|
||||
const crypto::SymmetricKey* key)
|
||||
: DecryptContextImpl(KEY_SYSTEM_CLEAR_KEY), key_(key) {
|
||||
CHECK(key);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace media {
|
||||
class DecryptContextImplClearKey : public DecryptContextImpl {
|
||||
public:
|
||||
// Note: DecryptContextClearKey does not take ownership of |key|.
|
||||
explicit DecryptContextImplClearKey(crypto::SymmetricKey* key);
|
||||
explicit DecryptContextImplClearKey(const crypto::SymmetricKey* key);
|
||||
~DecryptContextImplClearKey() override;
|
||||
|
||||
// DecryptContextImpl implementation.
|
||||
@ -37,7 +37,7 @@ class DecryptContextImplClearKey : public DecryptContextImpl {
|
||||
bool DoDecrypt(CastDecoderBuffer* buffer,
|
||||
uint8_t* output,
|
||||
size_t data_offset);
|
||||
crypto::SymmetricKey* const key_;
|
||||
const crypto::SymmetricKey* const key_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DecryptContextImplClearKey);
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ namespace crypto {
|
||||
|
||||
namespace {
|
||||
|
||||
const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) {
|
||||
const EVP_CIPHER* GetCipherForKey(const SymmetricKey* key) {
|
||||
switch (key->key().length()) {
|
||||
case 16: return EVP_aes_128_cbc();
|
||||
case 32: return EVP_aes_256_cbc();
|
||||
@ -90,7 +90,7 @@ Encryptor::Encryptor() : key_(nullptr), mode_(CBC) {}
|
||||
Encryptor::~Encryptor() {
|
||||
}
|
||||
|
||||
bool Encryptor::Init(SymmetricKey* key,
|
||||
bool Encryptor::Init(const SymmetricKey* key,
|
||||
Mode mode,
|
||||
const base::StringPiece& iv) {
|
||||
DCHECK(key);
|
||||
|
@ -58,7 +58,7 @@ class CRYPTO_EXPORT Encryptor {
|
||||
//
|
||||
// If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be
|
||||
// empty.
|
||||
bool Init(SymmetricKey* key, Mode mode, const base::StringPiece& iv);
|
||||
bool Init(const SymmetricKey* key, Mode mode, const base::StringPiece& iv);
|
||||
|
||||
// Encrypts |plaintext| into |ciphertext|. |plaintext| may only be empty if
|
||||
// the mode is CBC.
|
||||
@ -84,7 +84,7 @@ class CRYPTO_EXPORT Encryptor {
|
||||
// TODO(albertb): Support streaming encryption.
|
||||
|
||||
private:
|
||||
SymmetricKey* key_;
|
||||
const SymmetricKey* key_;
|
||||
Mode mode_;
|
||||
std::unique_ptr<Counter> counter_;
|
||||
|
||||
|
@ -49,7 +49,7 @@ bool HMAC::Init(const unsigned char* key, size_t key_length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HMAC::Init(SymmetricKey* key) {
|
||||
bool HMAC::Init(const SymmetricKey* key) {
|
||||
std::string raw_key;
|
||||
bool result = key->GetRawKey(&raw_key) && Init(raw_key);
|
||||
// Zero out key copy. This might get optimized away, but one can hope.
|
||||
|
@ -53,7 +53,7 @@ class CRYPTO_EXPORT HMAC {
|
||||
|
||||
// Initializes this instance using |key|. Call Init
|
||||
// only once. It returns false on the second or later calls.
|
||||
bool Init(SymmetricKey* key) WARN_UNUSED_RESULT;
|
||||
bool Init(const SymmetricKey* key) WARN_UNUSED_RESULT;
|
||||
|
||||
// Initializes this instance using |key|. Call Init only once. It returns
|
||||
// false on the second or later calls.
|
||||
|
@ -100,7 +100,7 @@ std::unique_ptr<SymmetricKey> SymmetricKey::Import(Algorithm algorithm,
|
||||
return key;
|
||||
}
|
||||
|
||||
bool SymmetricKey::GetRawKey(std::string* raw_key) {
|
||||
bool SymmetricKey::GetRawKey(std::string* raw_key) const {
|
||||
*raw_key = key_;
|
||||
return true;
|
||||
}
|
||||
|
@ -55,12 +55,12 @@ class CRYPTO_EXPORT SymmetricKey {
|
||||
static std::unique_ptr<SymmetricKey> Import(Algorithm algorithm,
|
||||
const std::string& raw_key);
|
||||
|
||||
const std::string& key() { return key_; }
|
||||
const std::string& key() const { return key_; }
|
||||
|
||||
// Extracts the raw key from the platform specific data.
|
||||
// Warning: |raw_key| holds the raw key as bytes and thus must be handled
|
||||
// carefully.
|
||||
bool GetRawKey(std::string* raw_key);
|
||||
bool GetRawKey(std::string* raw_key) const;
|
||||
|
||||
private:
|
||||
SymmetricKey();
|
||||
|
@ -172,8 +172,9 @@ static void CopySubsamples(const std::vector<SubsampleEntry>& subsamples,
|
||||
|
||||
// Decrypts |input| using |key|. Returns a DecoderBuffer with the decrypted
|
||||
// data if decryption succeeded or NULL if decryption failed.
|
||||
static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
|
||||
crypto::SymmetricKey* key) {
|
||||
static scoped_refptr<DecoderBuffer> DecryptData(
|
||||
const DecoderBuffer& input,
|
||||
const crypto::SymmetricKey* key) {
|
||||
CHECK(input.data_size());
|
||||
CHECK(input.decrypt_config());
|
||||
CHECK(key);
|
||||
|
Reference in New Issue
Block a user