Shaka Player Embedded
decryptor.h
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_UTIL_DECRYPTORS_H_
16 #define SHAKA_EMBEDDED_UTIL_DECRYPTORS_H_
17 
18 #include <memory>
19 #include <vector>
20 
22 #include "src/util/macros.h"
23 
24 #define AES_BLOCK_SIZE 16u
25 
26 namespace shaka {
27 namespace util {
28 
35 class Decryptor {
36  public:
37  Decryptor(eme::EncryptionScheme scheme, const std::vector<uint8_t>& key,
38  const std::vector<uint8_t>& iv);
39  ~Decryptor();
40 
42 
47  bool DecryptPartialBlock(const uint8_t* data, size_t data_size,
48  uint32_t block_offset, uint8_t* dest);
49 
54  bool Decrypt(const uint8_t* data, size_t data_size, uint8_t* dest);
55 
56  private:
57  bool InitIfNeeded();
58 
59  const eme::EncryptionScheme scheme_;
60  const std::vector<uint8_t> key_;
61  std::vector<uint8_t> iv_;
62 
63  struct Impl;
64  std::unique_ptr<Impl> extra_;
65 };
66 
67 } // namespace util
68 } // namespace shaka
69 
70 #endif // SHAKA_EMBEDDED_UTIL_DECRYPTORS_H_
const char * dest
Definition: media_utils.cc:31
SHAKA_NON_COPYABLE_OR_MOVABLE_TYPE(Decryptor)
bool DecryptPartialBlock(const uint8_t *data, size_t data_size, uint32_t block_offset, uint8_t *dest)
Decryptor(eme::EncryptionScheme scheme, const std::vector< uint8_t > &key, const std::vector< uint8_t > &iv)
bool Decrypt(const uint8_t *data, size_t data_size, uint8_t *dest)