| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromecast/media/base/decrypt_context_impl_clearkey.h" | 5 #include "chromecast/media/base/decrypt_context_impl_clearkey.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return true; | 44 return true; |
| 45 | 45 |
| 46 const CastDecryptConfig* decrypt_config = buffer->decrypt_config(); | 46 const CastDecryptConfig* decrypt_config = buffer->decrypt_config(); |
| 47 if (!decrypt_config || decrypt_config->iv().size() == 0) | 47 if (!decrypt_config || decrypt_config->iv().size() == 0) |
| 48 return false; | 48 return false; |
| 49 | 49 |
| 50 // Apply the |data_offset|, if requested. | 50 // Apply the |data_offset|, if requested. |
| 51 output += data_offset; | 51 output += data_offset; |
| 52 | 52 |
| 53 // Get the key. | 53 // Get the key. |
| 54 std::string raw_key; | 54 const std::string& raw_key = key_->key(); |
| 55 if (!key_->GetRawKey(&raw_key)) { | |
| 56 LOG(ERROR) << "Failed to get the underlying AES key"; | |
| 57 return false; | |
| 58 } | |
| 59 DCHECK_EQ(static_cast<int>(raw_key.length()), AES_BLOCK_SIZE); | 55 DCHECK_EQ(static_cast<int>(raw_key.length()), AES_BLOCK_SIZE); |
| 60 const uint8_t* key_u8 = reinterpret_cast<const uint8_t*>(raw_key.data()); | 56 const uint8_t* key_u8 = reinterpret_cast<const uint8_t*>(raw_key.data()); |
| 61 AES_KEY aes_key; | 57 AES_KEY aes_key; |
| 62 if (AES_set_encrypt_key(key_u8, AES_BLOCK_SIZE * 8, &aes_key) != 0) { | 58 if (AES_set_encrypt_key(key_u8, AES_BLOCK_SIZE * 8, &aes_key) != 0) { |
| 63 LOG(ERROR) << "Failed to set the AES key"; | 59 LOG(ERROR) << "Failed to set the AES key"; |
| 64 return false; | 60 return false; |
| 65 } | 61 } |
| 66 | 62 |
| 67 // Get the IV. | 63 // Get the IV. |
| 68 uint8_t aes_iv[AES_BLOCK_SIZE]; | 64 uint8_t aes_iv[AES_BLOCK_SIZE]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 } | 83 } |
| 88 return true; | 84 return true; |
| 89 } | 85 } |
| 90 | 86 |
| 91 bool DecryptContextImplClearKey::CanDecryptToBuffer() const { | 87 bool DecryptContextImplClearKey::CanDecryptToBuffer() const { |
| 92 return true; | 88 return true; |
| 93 } | 89 } |
| 94 | 90 |
| 95 } // namespace media | 91 } // namespace media |
| 96 } // namespace chromecast | 92 } // namespace chromecast |
| OLD | NEW |