Shaka Packager SDK
crypto_params.h
1 // Copyright 2017 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
8 #define PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
9 
10 #include <functional>
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 namespace shaka {
16 
18 enum class KeyProvider {
19  kNone = 0,
20  kWidevine = 1,
21  kPlayReady = 2,
22  kRawKey = 3,
23 };
24 
28  std::string signer_name;
29 
30  enum class SigningKeyType {
31  kNone,
32  kAes,
33  kRsa,
34  };
37  SigningKeyType signing_key_type = SigningKeyType::kNone;
38  struct {
40  std::vector<uint8_t> key;
42  std::vector<uint8_t> iv;
43  } aes;
44  struct {
46  std::string key;
47  } rsa;
48 };
49 
53  std::string key_server_url;
55  std::vector<uint8_t> content_id;
57  std::string policy;
61  std::vector<uint8_t> group_id;
64 };
65 
75  std::string key_server_url;
77  std::string program_identifier;
80  std::string ca_file;
82  std::string client_cert_file;
87 };
88 
90 struct RawKeyParams {
94  std::vector<uint8_t> iv;
98  std::vector<uint8_t> pssh;
99 
100  using StreamLabel = std::string;
101  struct KeyInfo {
102  std::vector<uint8_t> key_id;
103  std::vector<uint8_t> key;
104  };
108  std::map<StreamLabel, KeyInfo> key_map;
109 };
110 
116  KeyProvider key_provider = KeyProvider::kNone;
117  // Only one of the three fields is valid.
118  WidevineEncryptionParams widevine;
119  PlayReadyEncryptionParams playready;
120  RawKeyParams raw_key;
121 
126  bool generate_common_pssh = false;
130  bool generate_playready_pssh = false;
134  bool generate_widevine_pssh = false;
135 
137  double clear_lead_in_seconds = 0;
139  static constexpr uint32_t kProtectionSchemeCenc = 0x63656E63;
140  static constexpr uint32_t kProtectionSchemeCbc1 = 0x63626331;
141  static constexpr uint32_t kProtectionSchemeCens = 0x63656E73;
142  static constexpr uint32_t kProtectionSchemeCbcs = 0x63626373;
143  uint32_t protection_scheme = kProtectionSchemeCenc;
146  static constexpr double kNoKeyRotation = 0;
147  double crypto_period_duration_in_seconds = kNoKeyRotation;
149  bool vp9_subsample_encryption = true;
150 
153  enum StreamType {
154  kUnknown,
155  kVideo,
156  kAudio,
157  };
158 
159  StreamType stream_type = kUnknown;
160  union OneOf {
161  OneOf() {}
162 
163  struct {
164  int width = 0;
165  int height = 0;
166  float frame_rate = 0;
167  int bit_depth = 0;
168  } video;
169 
170  struct {
171  int number_of_channels = 0;
172  } audio;
173  } oneof;
174  };
180  std::function<std::string(const EncryptedStreamAttributes& stream_attributes)>
182 };
183 
187  std::string key_server_url;
190 };
191 
197  KeyProvider key_provider = KeyProvider::kNone;
198  // Only one of the two fields is valid.
199  WidevineDecryptionParams widevine;
200  RawKeyParams raw_key;
201 };
202 
203 } // namespace shaka
204 
205 #endif // PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
std::string key_server_url
Widevine license / key server URL.
Definition: crypto_params.h:53
std::string key_server_url
PlayReady license / key server URL.
Definition: crypto_params.h:75
std::string client_cert_private_key_password
Password to the private key file.
Definition: crypto_params.h:86
KeyProvider
Encryption / decryption key providers.
Definition: crypto_params.h:18
Widevine decryption parameters.
std::function< std::string(const EncryptedStreamAttributes &stream_attributes)> stream_label_func
WidevineSigner signer
Signer credential for Widevine license / key server.
Definition: crypto_params.h:59
std::vector< uint8_t > content_id
Content identifier.
Definition: crypto_params.h:55
std::string program_identifier
PlayReady program identifier.
Definition: crypto_params.h:77
WidevineSigner signer
Signer credential for Widevine license / key server.
All the methods that are virtual are virtual for mocking.
std::string key_server_url
Widevine license / key server URL.
bool enable_entitlement_license
Enables entitlement license when set to true.
Definition: crypto_params.h:63
Raw key encryption/decryption parameters, i.e. with key parameters provided.
Definition: crypto_params.h:90
std::string signer_name
Name of the signer / content provider.
Definition: crypto_params.h:28
std::map< StreamLabel, KeyInfo > key_map
std::vector< uint8_t > iv
Definition: crypto_params.h:94
Widevine encryption parameters.
Definition: crypto_params.h:51
Decryption parameters.
Encryption parameters.
Encrypted stream information that is used to determine stream label.
std::vector< uint8_t > key
AES signing key.
Definition: crypto_params.h:40
std::string policy
The name of a stored policy, which specifies DRM content rights.
Definition: crypto_params.h:57
std::string client_cert_file
Absolute path to client certificate file.
Definition: crypto_params.h:82
std::string key
RSA signing private key.
Definition: crypto_params.h:46
std::vector< uint8_t > pssh
Definition: crypto_params.h:98
Signer credential for Widevine license server.
Definition: crypto_params.h:26
std::vector< uint8_t > group_id
Group identifier, if present licenses will belong to this group.
Definition: crypto_params.h:61
std::string client_cert_private_key_file
Absolute path to the private key file.
Definition: crypto_params.h:84
std::vector< uint8_t > iv
AES signing IV.
Definition: crypto_params.h:42