Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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;
56  // TODO(kqyang): Move to EncryptionParams and support common PSSH generation
57  // in all key providers.
58  bool include_common_pssh = false;
60  std::vector<uint8_t> content_id;
62  std::string policy;
66  std::vector<uint8_t> group_id;
67 };
68 
78  std::string key_server_url;
80  std::string program_identifier;
83  std::string ca_file;
85  std::string client_cert_file;
90 
91  // TODO(kqyang): move raw playready key generation to RawKey.
93  std::vector<uint8_t> key_id;
95  std::vector<uint8_t> key;
96 };
97 
102  std::vector<uint8_t> iv;
105  std::vector<uint8_t> pssh;
106 
107  using StreamLabel = std::string;
108  struct KeyPair {
109  std::vector<uint8_t> key_id;
110  std::vector<uint8_t> key;
111  };
115  std::map<StreamLabel, KeyPair> key_map;
116 };
117 
123  KeyProvider key_provider = KeyProvider::kNone;
124  // Only one of the three fields is valid.
125  WidevineEncryptionParams widevine;
126  PlayreadyEncryptionParams playready;
127  RawKeyEncryptionParams raw_key;
128 
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;
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 
187  using StreamLabel = std::string;
188  struct KeyPair {
189  std::vector<uint8_t> key_id;
190  std::vector<uint8_t> key;
191  };
195  std::map<StreamLabel, KeyPair> key_map;
196 };
197 
203  KeyProvider key_provider = KeyProvider::kNone;
204  // Only one of the two fields is valid.
205  WidevineDecryptionParams widevine;
206  RawKeyDecryptionParams raw_key;
207 };
208 
209 } // namespace shaka
210 
211 #endif // PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
std::string client_cert_private_key_file
Absolute path to the private key file.
Definition: crypto_params.h:87
std::vector< uint8_t > iv
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:78
KeyProvider
Encryption / decryption key providers.
Definition: crypto_params.h:18
Widevine decryption parameters.
std::function< std::string(const EncryptedStreamAttributes &stream_attributes)> stream_label_func
static constexpr double kNoKeyRotation
WidevineSigner signer
Signer credential for Widevine license / key server.
Definition: crypto_params.h:64
std::vector< uint8_t > content_id
Content identifier.
Definition: crypto_params.h:60
std::string client_cert_private_key_password
Password to the private key file.
Definition: crypto_params.h:89
double clear_lead_in_seconds
Clear lead duration in seconds.
WidevineSigner signer
Signer credential for Widevine license / key server.
bool vp9_subsample_encryption
Enable/disable subsample encryption for VP9.
std::map< StreamLabel, KeyPair > key_map
std::string key_server_url
Widevine license / key server URL.
std::vector< uint8_t > pssh
std::map< StreamLabel, KeyPair > key_map
std::string signer_name
Name of the signer / content provider.
Definition: crypto_params.h:28
std::vector< uint8_t > key
Provides a raw Playready Key.
Definition: crypto_params.h:95
SigningKeyType signing_key_type
Definition: crypto_params.h:37
Widevine encryption parameters.
Definition: crypto_params.h:51
Raw key decryption parameters, i.e. with key parameters provided.
Decryption parameters.
Raw key encryption parameters, i.e. with key parameters provided.
Definition: crypto_params.h:99
Encryption parameters.
std::vector< uint8_t > key_id
Provides a raw Playready KeyId.
Definition: crypto_params.h:93
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:62
static constexpr uint32_t kProtectionSchemeCenc
The protection scheme: "cenc", "cens", "cbc1", "cbcs".
std::string program_identifier
Playready program identifier.
Definition: crypto_params.h:80
std::string key
RSA signing private key.
Definition: crypto_params.h:46
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:66
std::vector< uint8_t > iv
AES signing IV.
Definition: crypto_params.h:42
std::string client_cert_file
Absolute path to client certificate file.
Definition: crypto_params.h:85