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  kPlayReady,
123  kWidevine,
124  };
126  std::vector<ProtectionSystem> protection_systems;
127 
129  double clear_lead_in_seconds = 0;
131  static constexpr uint32_t kProtectionSchemeCenc = 0x63656E63;
132  static constexpr uint32_t kProtectionSchemeCbc1 = 0x63626331;
133  static constexpr uint32_t kProtectionSchemeCens = 0x63656E73;
134  static constexpr uint32_t kProtectionSchemeCbcs = 0x63626373;
135  uint32_t protection_scheme = kProtectionSchemeCenc;
138  static constexpr double kNoKeyRotation = 0;
139  double crypto_period_duration_in_seconds = kNoKeyRotation;
141  bool vp9_subsample_encryption = true;
142 
145  enum StreamType {
146  kUnknown,
147  kVideo,
148  kAudio,
149  };
150 
151  StreamType stream_type = kUnknown;
152  union OneOf {
153  OneOf() {}
154 
155  struct {
156  int width = 0;
157  int height = 0;
158  float frame_rate = 0;
159  int bit_depth = 0;
160  } video;
161 
162  struct {
163  int number_of_channels = 0;
164  } audio;
165  } oneof;
166  };
172  std::function<std::string(const EncryptedStreamAttributes& stream_attributes)>
174 };
175 
179  std::string key_server_url;
182 };
183 
189  KeyProvider key_provider = KeyProvider::kNone;
190  // Only one of the two fields is valid.
191  WidevineDecryptionParams widevine;
192  RawKeyParams raw_key;
193 };
194 
195 } // namespace shaka
196 
197 #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