summaryrefslogtreecommitdiffstats
path: root/media/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'media/crypto')
-rw-r--r--media/crypto/aes_decryptor.cc22
-rw-r--r--media/crypto/aes_decryptor.h7
-rw-r--r--media/crypto/aes_decryptor_unittest.cc13
3 files changed, 22 insertions, 20 deletions
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc
index 8d56d76..cbb75b3 100644
--- a/media/crypto/aes_decryptor.cc
+++ b/media/crypto/aes_decryptor.cc
@@ -9,8 +9,7 @@
#include "base/string_piece.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
-#include "media/base/buffers.h"
-#include "media/base/data_buffer.h"
+#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
namespace media {
@@ -19,10 +18,10 @@ namespace media {
static const char kInitialCounter[] = "0000000000000000";
// Decrypt |input| using |key|.
-// Return a scoped_refptr to a Buffer object with the decrypted data on success.
-// Return a scoped_refptr to NULL if the data could not be decrypted.
-static scoped_refptr<Buffer> DecryptData(const Buffer& input,
- crypto::SymmetricKey* key) {
+// Return a DecoderBuffer with the decrypted data if decryption succeeded.
+// Return NULL if decryption failed.
+static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
+ crypto::SymmetricKey* key) {
CHECK(input.GetDataSize());
CHECK(key);
@@ -43,9 +42,8 @@ static scoped_refptr<Buffer> DecryptData(const Buffer& input,
return NULL;
}
- // TODO(xhwang): Implement a string based Buffer implementation to avoid
- // data copying.
- return DataBuffer::CopyFrom(
+ // TODO(xhwang): Find a way to avoid this data copy.
+ return DecoderBuffer::CopyFrom(
reinterpret_cast<const uint8*>(decrypted_text.data()),
decrypted_text.size());
}
@@ -81,8 +79,8 @@ void AesDecryptor::AddKey(const uint8* key_id, int key_id_size,
key_map_[key_id_string] = symmetric_key;
}
-scoped_refptr<Buffer> AesDecryptor::Decrypt(
- const scoped_refptr<Buffer>& encrypted) {
+scoped_refptr<DecoderBuffer> AesDecryptor::Decrypt(
+ const scoped_refptr<DecoderBuffer>& encrypted) {
CHECK(encrypted->GetDecryptConfig());
const uint8* key_id = encrypted->GetDecryptConfig()->key_id();
const int key_id_size = encrypted->GetDecryptConfig()->key_id_size();
@@ -101,7 +99,7 @@ scoped_refptr<Buffer> AesDecryptor::Decrypt(
key = found->second;
}
- scoped_refptr<Buffer> decrypted = DecryptData(*encrypted, key);
+ scoped_refptr<DecoderBuffer> decrypted = DecryptData(*encrypted, key);
if (decrypted) {
decrypted->SetTimestamp(encrypted->GetTimestamp());
diff --git a/media/crypto/aes_decryptor.h b/media/crypto/aes_decryptor.h
index 212c9ac..d62528f 100644
--- a/media/crypto/aes_decryptor.h
+++ b/media/crypto/aes_decryptor.h
@@ -19,7 +19,7 @@ class SymmetricKey;
namespace media {
-class Buffer;
+class DecoderBuffer;
// Decrypts AES encrypted buffer into unencrypted buffer.
class MEDIA_EXPORT AesDecryptor {
@@ -35,9 +35,10 @@ class MEDIA_EXPORT AesDecryptor {
const uint8* key, int key_size);
// Decrypt |input| buffer. The |input| should not be NULL.
- // Return a Buffer that contains decrypted data if decryption succeeded.
+ // Return a DecoderBuffer with the decrypted data if decryption succeeded.
// Return NULL if decryption failed.
- scoped_refptr<Buffer> Decrypt(const scoped_refptr<Buffer>& input);
+ scoped_refptr<DecoderBuffer> Decrypt(
+ const scoped_refptr<DecoderBuffer>& input);
private:
// KeyMap owns the crypto::SymmetricKey* and must delete them when they are
diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc
index 70b6881..0b33f61 100644
--- a/media/crypto/aes_decryptor_unittest.cc
+++ b/media/crypto/aes_decryptor_unittest.cc
@@ -4,7 +4,7 @@
#include <string>
-#include "media/base/data_buffer.h"
+#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/crypto/aes_decryptor.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,7 +28,8 @@ static const unsigned char kKeyId2[] = "Key ID 2.";
class AesDecryptorTest : public testing::Test {
public:
AesDecryptorTest() {
- encrypted_data_ = DataBuffer::CopyFrom(kEncryptedData, kEncryptedDataSize);
+ encrypted_data_ = DecoderBuffer::CopyFrom(
+ kEncryptedData, kEncryptedDataSize);
}
protected:
@@ -38,7 +39,8 @@ class AesDecryptorTest : public testing::Test {
}
void DecryptAndExpectToSucceed() {
- scoped_refptr<Buffer> decrypted = decryptor_.Decrypt(encrypted_data_);
+ scoped_refptr<DecoderBuffer> decrypted =
+ decryptor_.Decrypt(encrypted_data_);
ASSERT_TRUE(decrypted);
int data_length = sizeof(kOriginalData) - 1;
ASSERT_EQ(data_length, decrypted->GetDataSize());
@@ -46,11 +48,12 @@ class AesDecryptorTest : public testing::Test {
}
void DecryptAndExpectToFail() {
- scoped_refptr<Buffer> decrypted = decryptor_.Decrypt(encrypted_data_);
+ scoped_refptr<DecoderBuffer> decrypted =
+ decryptor_.Decrypt(encrypted_data_);
EXPECT_FALSE(decrypted);
}
- scoped_refptr<DataBuffer> encrypted_data_;
+ scoped_refptr<DecoderBuffer> encrypted_data_;
AesDecryptor decryptor_;
};