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