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" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // The key used to perform the integrity check. Currently the HMAC key is | 83 // The key used to perform the integrity check. Currently the HMAC key is |
84 // defined by the WebM encrypted specification. Current encrypted WebM | 84 // defined by the WebM encrypted specification. Current encrypted WebM |
85 // request for comments specification is here | 85 // request for comments specification is here |
86 // http://wiki.webmproject.org/encryption/webm-encryption-rfc | 86 // http://wiki.webmproject.org/encryption/webm-encryption-rfc |
87 std::string hmac_key_; | 87 std::string hmac_key_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); | 89 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); |
90 }; | 90 }; |
91 | 91 |
| 92 // Sets |key| for |key_id|. The AesDecryptor takes the ownership of the |key|. |
| 93 void SetKey(const std::string& key_id, scoped_ptr<DecryptionKey> key); |
| 94 |
| 95 // Gets a DecryptionKey associated with |key_id|. The AesDecryptor still owns |
| 96 // the key. Returns NULL if no key is associated with |key_id|. |
| 97 DecryptionKey* GetKey(const std::string& key_id) const; |
| 98 |
92 // KeyMap owns the DecryptionKey* and must delete them when they are | 99 // KeyMap owns the DecryptionKey* and must delete them when they are |
93 // not needed any more. | 100 // not needed any more. |
94 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; | 101 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; |
95 | 102 |
96 // Since only Decrypt() is called off the renderer thread, we only need to | 103 // Since only Decrypt() is called off the renderer thread, we only need to |
97 // protect |key_map_|, the only member variable that is shared between | 104 // protect |key_map_|, the only member variable that is shared between |
98 // Decrypt() and other methods. | 105 // Decrypt() and other methods. |
99 KeyMap key_map_; // Protected by the |key_map_lock_|. | 106 KeyMap key_map_; // Protected by the |key_map_lock_|. |
100 base::Lock key_map_lock_; // Protects the |key_map_|. | 107 mutable base::Lock key_map_lock_; // Protects the |key_map_|. |
101 | 108 |
102 // Make session ID unique per renderer by making it static. | 109 // Make session ID unique per renderer by making it static. |
103 // TODO(xhwang): Make session ID more strictly defined if needed: | 110 // TODO(xhwang): Make session ID more strictly defined if needed: |
104 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 | 111 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 |
105 static uint32 next_session_id_; | 112 static uint32 next_session_id_; |
106 | 113 |
107 DecryptorClient* const client_; | 114 DecryptorClient* const client_; |
108 | 115 |
109 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 116 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
110 }; | 117 }; |
111 | 118 |
112 } // namespace media | 119 } // namespace media |
113 | 120 |
114 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 121 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
OLD | NEW |