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;
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 
99 struct RawKeyParams {
103  std::vector<uint8_t> iv;
107  std::vector<uint8_t> pssh;
108 
109  using StreamLabel = std::string;
110  struct KeyInfo {
111  std::vector<uint8_t> key_id;
112  std::vector<uint8_t> key;
113  };
117  std::map<StreamLabel, KeyInfo> key_map;
118 };
119 
125  KeyProvider key_provider = KeyProvider::kNone;
126  // Only one of the three fields is valid.
127  WidevineEncryptionParams widevine;
128  PlayreadyEncryptionParams playready;
129  RawKeyParams raw_key;
130 
132  double clear_lead_in_seconds = 0;
134  static constexpr uint32_t kProtectionSchemeCenc = 0x63656E63;
135  static constexpr uint32_t kProtectionSchemeCbc1 = 0x63626331;
136  static constexpr uint32_t kProtectionSchemeCens = 0x63656E73;
137  static constexpr uint32_t kProtectionSchemeCbcs = 0x63626373;
138  uint32_t protection_scheme = kProtectionSchemeCenc;
141  static constexpr double kNoKeyRotation = 0;
142  double crypto_period_duration_in_seconds = kNoKeyRotation;
144  bool vp9_subsample_encryption = true;
145 
148  enum StreamType {
149  kUnknown,
150  kVideo,
151  kAudio,
152  };
153 
154  StreamType stream_type = kUnknown;
155  union OneOf {
156  OneOf() {}
157 
158  struct {
159  int width = 0;
160  int height = 0;
161  float frame_rate = 0;
162  int bit_depth = 0;
163  } video;
164 
165  struct {
166  int number_of_channels = 0;
167  } audio;
168  } oneof;
169  };
175  std::function<std::string(const EncryptedStreamAttributes& stream_attributes)>
177 };
178 
182  std::string key_server_url;
185 };
186 
192  KeyProvider key_provider = KeyProvider::kNone;
193  // Only one of the two fields is valid.
194  WidevineDecryptionParams widevine;
195  RawKeyParams raw_key;
196 };
197 
198 } // namespace shaka
199 
200 #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::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
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
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.
Raw key encryption/decryption parameters, i.e. with key parameters provided.
Definition: crypto_params.h:99
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 > key
Provides a raw Playready Key.
Definition: crypto_params.h:95
std::vector< uint8_t > iv
Widevine encryption parameters.
Definition: crypto_params.h:51
Decryption parameters.
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
std::string program_identifier
Playready program identifier.
Definition: crypto_params.h:80
std::string key
RSA signing private key.
Definition: crypto_params.h:46
std::vector< uint8_t > pssh
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