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 
71  std::string key_server_url;
73  std::string program_identifier;
76  std::string ca_file;
78  std::string client_cert_file;
83 };
84 
86 struct RawKeyParams {
90  std::vector<uint8_t> iv;
94  std::vector<uint8_t> pssh;
95 
96  using StreamLabel = std::string;
97  struct KeyInfo {
98  std::vector<uint8_t> key_id;
99  std::vector<uint8_t> key;
100  };
104  std::map<StreamLabel, KeyInfo> key_map;
105 };
106 
112  KeyProvider key_provider = KeyProvider::kNone;
113  // Only one of the three fields is valid.
114  WidevineEncryptionParams widevine;
115  PlayReadyEncryptionParams playready;
116  RawKeyParams raw_key;
117 
119  enum class ProtectionSystem {
120  kCommonSystem,
121  kFairPlay,
122  kMarlin,
123  kPlayReady,
124  kWidevine,
125  };
127  std::vector<ProtectionSystem> protection_systems;
128 
130  double clear_lead_in_seconds = 0;
132  static constexpr uint32_t kProtectionSchemeCenc = 0x63656E63;
133  static constexpr uint32_t kProtectionSchemeCbc1 = 0x63626331;
134  static constexpr uint32_t kProtectionSchemeCens = 0x63656E73;
135  static constexpr uint32_t kProtectionSchemeCbcs = 0x63626373;
136  uint32_t protection_scheme = kProtectionSchemeCenc;
139  static constexpr double kNoKeyRotation = 0;
140  double crypto_period_duration_in_seconds = kNoKeyRotation;
142  bool vp9_subsample_encryption = true;
143 
146  enum StreamType {
147  kUnknown,
148  kVideo,
149  kAudio,
150  };
151 
152  StreamType stream_type = kUnknown;
153  union OneOf {
154  OneOf() {}
155 
156  struct {
157  int width = 0;
158  int height = 0;
159  float frame_rate = 0;
160  int bit_depth = 0;
161  } video;
162 
163  struct {
164  int number_of_channels = 0;
165  } audio;
166  } oneof;
167  };
173  std::function<std::string(const EncryptedStreamAttributes& stream_attributes)>
175 };
176 
180  std::string key_server_url;
183 };
184 
190  KeyProvider key_provider = KeyProvider::kNone;
191  // Only one of the two fields is valid.
192  WidevineDecryptionParams widevine;
193  RawKeyParams raw_key;
194 };
195 
196 } // namespace shaka
197 
198 #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:71
std::string client_cert_private_key_password
Password to the private key file.
Definition: crypto_params.h:82
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:73
WidevineSigner signer
Signer credential for Widevine license / key server.
All the methods that are virtual are virtual for mocking.
ProtectionSystem
Supported protection systems.
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:86
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:90
Widevine encryption parameters.
Definition: crypto_params.h:51
std::vector< ProtectionSystem > protection_systems
Protection systems to be generated.
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:78
std::string key
RSA signing private key.
Definition: crypto_params.h:46
std::vector< uint8_t > pssh
Definition: crypto_params.h:94
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:80
std::vector< uint8_t > iv
AES signing IV.
Definition: crypto_params.h:42