OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 5 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
15 | 15 |
16 namespace crypto { | 16 namespace crypto { |
17 class SymmetricKey; | 17 class SymmetricKey; |
18 } | 18 } |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 class Buffer; | 22 class DecoderBuffer; |
23 | 23 |
24 // Decrypts AES encrypted buffer into unencrypted buffer. | 24 // Decrypts AES encrypted buffer into unencrypted buffer. |
25 class MEDIA_EXPORT AesDecryptor { | 25 class MEDIA_EXPORT AesDecryptor { |
26 public: | 26 public: |
27 AesDecryptor(); | 27 AesDecryptor(); |
28 ~AesDecryptor(); | 28 ~AesDecryptor(); |
29 | 29 |
30 // Add a |key_id| and |key| pair to the key system. The key is not limited to | 30 // Add a |key_id| and |key| pair to the key system. The key is not limited to |
31 // a decryption key. It can be any data that the key system accepts, such as | 31 // a decryption key. It can be any data that the key system accepts, such as |
32 // a license. If multiple calls of this function set different keys for the | 32 // a license. If multiple calls of this function set different keys for the |
33 // same |key_id|, the older key will be replaced by the newer key. | 33 // same |key_id|, the older key will be replaced by the newer key. |
34 void AddKey(const uint8* key_id, int key_id_size, | 34 void AddKey(const uint8* key_id, int key_id_size, |
35 const uint8* key, int key_size); | 35 const uint8* key, int key_size); |
36 | 36 |
37 // Decrypt |input| buffer. The |input| should not be NULL. | 37 // Decrypt |input| buffer. The |input| should not be NULL. |
38 // Return a Buffer that contains decrypted data if decryption succeeded. | 38 // Return a DecoderBuffer with the decrypted data if decryption succeeded. |
39 // Return NULL if decryption failed. | 39 // Return NULL if decryption failed. |
40 scoped_refptr<Buffer> Decrypt(const scoped_refptr<Buffer>& input); | 40 scoped_refptr<DecoderBuffer> Decrypt( |
| 41 const scoped_refptr<DecoderBuffer>& input); |
41 | 42 |
42 private: | 43 private: |
43 // KeyMap owns the crypto::SymmetricKey* and must delete them when they are | 44 // KeyMap owns the crypto::SymmetricKey* and must delete them when they are |
44 // not needed any more. | 45 // not needed any more. |
45 typedef base::hash_map<std::string, crypto::SymmetricKey*> KeyMap; | 46 typedef base::hash_map<std::string, crypto::SymmetricKey*> KeyMap; |
46 KeyMap key_map_; | 47 KeyMap key_map_; |
47 base::Lock lock_; | 48 base::Lock lock_; |
48 | 49 |
49 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 50 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
50 }; | 51 }; |
51 | 52 |
52 } // namespace media | 53 } // namespace media |
53 | 54 |
54 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 55 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
OLD | NEW |