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 #ifndef MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ | 5 #ifndef MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ |
6 #define MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ | 6 #define MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ |
7 | 7 |
8 // Helper class to handle encryption for the Cast Transport library. | 8 // Helper class to handle encryption for the Cast Transport library. |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
14 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
15 | 14 |
16 namespace crypto { | 15 namespace crypto { |
17 class Encryptor; | 16 class Encryptor; |
18 class SymmetricKey; | 17 class SymmetricKey; |
19 } | 18 } |
20 | 19 |
21 namespace media { | 20 namespace media { |
22 namespace cast { | 21 namespace cast { |
23 | 22 |
24 class TransportEncryptionHandler : public base::NonThreadSafe { | 23 class TransportEncryptionHandler : public base::NonThreadSafe { |
25 public: | 24 public: |
26 TransportEncryptionHandler(); | 25 TransportEncryptionHandler(); |
27 ~TransportEncryptionHandler(); | 26 ~TransportEncryptionHandler(); |
28 | 27 |
29 bool Initialize(const std::string& aes_key, const std::string& aes_iv_mask); | 28 bool Initialize(const std::string& aes_key, const std::string& aes_iv_mask); |
30 | 29 |
31 bool Encrypt(uint32 frame_id, | 30 bool Encrypt(uint32_t frame_id, |
32 const base::StringPiece& data, | 31 const base::StringPiece& data, |
33 std::string* encrypted_data); | 32 std::string* encrypted_data); |
34 | 33 |
35 bool Decrypt(uint32 frame_id, | 34 bool Decrypt(uint32_t frame_id, |
36 const base::StringPiece& ciphertext, | 35 const base::StringPiece& ciphertext, |
37 std::string* plaintext); | 36 std::string* plaintext); |
38 | 37 |
39 bool is_activated() const { return is_activated_; } | 38 bool is_activated() const { return is_activated_; } |
40 | 39 |
41 private: | 40 private: |
42 scoped_ptr<crypto::SymmetricKey> key_; | 41 scoped_ptr<crypto::SymmetricKey> key_; |
43 scoped_ptr<crypto::Encryptor> encryptor_; | 42 scoped_ptr<crypto::Encryptor> encryptor_; |
44 std::string iv_mask_; | 43 std::string iv_mask_; |
45 bool is_activated_; | 44 bool is_activated_; |
46 | 45 |
47 DISALLOW_COPY_AND_ASSIGN(TransportEncryptionHandler); | 46 DISALLOW_COPY_AND_ASSIGN(TransportEncryptionHandler); |
48 }; | 47 }; |
49 | 48 |
50 } // namespace cast | 49 } // namespace cast |
51 } // namespace media | 50 } // namespace media |
52 | 51 |
53 #endif // MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ | 52 #endif // MEDIA_CAST_COMMON_TRANSPORT_ENCRYPTION_HANDLER_H_ |
OLD | NEW |