RDK Documentation (Open Sourced RDK Components)
ClearKeyDrmSession.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21 * @file ClearKeyDrmSession.cpp
22 * @brief Source file for ClearKey DRM Session.
23 */
24 
25 #include "config.h"
26 #include "ClearKeyDrmSession.h"
27 #include "AampUtils.h"
28 #include "AampConfig.h"
29 #include <gst/gst.h>
30 #include <sstream>
31 #include <string>
32 #include <string.h>
33 #include <vector>
34 #include "priv_aamp.h"
35 
36 #include <openssl/err.h>
37 #include <sys/time.h>
38 #include <gst/base/gstbytereader.h>
39 
40 #define AES_CTR_KID_LEN 16
41 #define AES_CTR_IV_LEN 16
42 #define AES_CTR_KEY_LEN 16
43 
44 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
45 #define OPEN_SSL_CONTEXT mOpensslCtx
46 #else
47 #define OPEN_SSL_CONTEXT &mOpensslCtx
48 #endif
49 
50 
51 /**
52  * @brief ClearKeySession Constructor
53  */
55  AampDrmSession(logObj, CLEAR_KEY_SYSTEM_STRING),
56  m_sessionID(),
57  m_eKeyState(KEY_INIT),
58  decryptMutex(),
59  m_keyId(NULL),
60  mOpensslCtx(),
61  m_keyStr(NULL),
62  m_keyLen(0),
63  m_keyIdLen(0)
64 {
65  pthread_mutex_init(&decryptMutex,NULL);
67 }
68 
69 
70 /**
71  * @brief Initialize CK DRM session, Initializes EVP context.
72  */
74 {
75 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
76  OPEN_SSL_CONTEXT = EVP_CIPHER_CTX_new();
77 #else
78  EVP_CIPHER_CTX_init(OPEN_SSL_CONTEXT);
79 #endif
80  AAMPLOG_ERR("ClearKeySession: enter ");
81 }
82 
83 /**
84  * @brief SetKid for this session.
85  */
86 void ClearKeySession::setKeyId(const char* keyId, int32_t keyIDLen)
87 {
88  if (m_keyId != NULL)
89  {
90  free(m_keyId);
91  }
92  m_keyId = (unsigned char*) malloc(sizeof(unsigned char) * keyIDLen);
93  memcpy(m_keyId, keyId, keyIDLen);
94  m_keyIdLen = keyIDLen;
95 }
96 
97 /**
98  * @brief Extract the keyId from PSSH data.
99  * Different procedures are used for PlayReady and WideVine.
100  *
101  * @param[in] psshData - Pointer to PSSH data.
102  * @param[in] dataLength - Length of PSSH data.
103  * @param[out] len - Gets updated with length of keyId.
104  * @return Pointer to extracted keyId.
105  * @note Memory for keyId is dynamically allocated, deallocation
106  * should be handled at the caller side.
107  */
108 static unsigned char * extractKeyIdFromPssh(const char* psshData, int dataLength, int *len)
109 {
110  unsigned char* key_id = NULL;
111  /*
112  00 00 00 34 70 73 73 68 01 00 00 00 10 77 ef ec
113  c0 b2 4d 02 ac e3 3c 1e 52 e2 fb 4b 00 00 00 01
114 
115  fe ed f0 0d ee de ad be ef f0 ba ad f0 0d d0 0d
116  00 00 00 00
117  */
118  uint32_t header = 32; //CID:10819 : key_id_count variable removed since its declared but not used
119  //uint8_t key_id_count = (uint8_t)psshData[header]; // unused
120  key_id = (unsigned char*)malloc(16 + 1);
121  memset(key_id, 0, 16 + 1);
122  strncpy(reinterpret_cast<char*>(key_id), psshData + header, 16);
123  *len = (int)16;
124  AAMPLOG_INFO("ck keyid: %s keyIdlen: %d", key_id, 16);
126  {
127  DumpBlob(key_id, 16);
128  }
129 
130  return key_id;
131 }
132 
133 /**
134  * @brief Create drm session with given init data
135  * state will be KEY_INIT on success KEY_ERROR if failed
136  */
137 void ClearKeySession::generateAampDRMSession(const uint8_t *f_pbInitData,
138  uint32_t f_cbInitData, std::string &customData)
139 {
140  unsigned char *keyId = NULL;
141  if(f_pbInitData != NULL && f_cbInitData > 0)
142  {
143  int keyIDLen = 0;
144  keyId = extractKeyIdFromPssh(reinterpret_cast<const char*>(f_pbInitData),f_cbInitData, &keyIDLen);
145  if (keyId == NULL)
146  {
147  AAMPLOG_ERR("ClearKeySession: ERROR: Key Id not found in initdata");
148  m_eKeyState = KEY_ERROR;
149  }
150  else
151  {
152  if(keyIDLen != AES_CTR_KID_LEN)
153  {
154  AAMPLOG_ERR("ClearKeySession: ERROR: Invalid keyID length %d", keyIDLen);
155  m_eKeyState = KEY_ERROR;
156  }
157  else
158  {
159  setKeyId(reinterpret_cast<const char*>(keyId), keyIDLen);
160  AAMPLOG_ERR("ClearKeySession: Session generated for clearkey");
161  }
162  free(keyId);
163  }
164  }
165  else
166  {
167  AAMPLOG_ERR("Invalid init data");
168  m_eKeyState = KEY_ERROR;
169  }
170  return;
171 }
172 
173 
174 /**
175  * @brief ClearKeySession Destructor
176  */
178 {
179  pthread_mutex_destroy(&decryptMutex);
180 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
181  if( OPEN_SSL_CONTEXT )
182  {
183  EVP_CIPHER_CTX_free(OPEN_SSL_CONTEXT);
184  OPEN_SSL_CONTEXT = NULL;
185  }
186 #else
187  EVP_CIPHER_CTX_cleanup(OPEN_SSL_CONTEXT);
188 #endif
189  if(m_keyId != NULL)
190  {
191  free(m_keyId);
192  }
193  if(m_keyStr != NULL)
194  {
195  free(m_keyStr);
196  }
197 
198  m_eKeyState = KEY_CLOSED;
199 }
200 
201 
202 /**
203  * @brief Generate key request from DRM session
204  * Caller function should free the returned memory.
205  */
206 DrmData * ClearKeySession::aampGenerateKeyRequest(string& destinationURL, uint32_t timeout)
207 {
208  DrmData *licenseChallenge = NULL;
209  if(NULL == m_keyId || m_keyIdLen <= 0)
210  {
211  AAMPLOG_ERR("ClearKeySession: Error generating license request ");
212  }
213  else
214  {
215  char* urlEncodedkeyId = aamp_Base64_URL_Encode(m_keyId, m_keyIdLen);
216  if(urlEncodedkeyId)
217  {
218  cJSON *licenseRequest = cJSON_CreateObject();
219  if(licenseRequest)
220  {
221  cJSON *keyIds = cJSON_CreateArray();
222  if(keyIds)
223  {
224  cJSON_AddItemToArray(keyIds, cJSON_CreateString(urlEncodedkeyId));
225  cJSON_AddItemToObject(licenseRequest, "kids", keyIds);
226  cJSON_AddItemToObject(licenseRequest, "type",cJSON_CreateString("temporary"));
227  char* requestBody = cJSON_PrintUnformatted(licenseRequest);
228  if(requestBody)
229  {
230  AAMPLOG_INFO("Generated license request : %s", requestBody);
231  licenseChallenge = new DrmData(reinterpret_cast<unsigned char*>(requestBody), strlen(requestBody)+1); //CID:154682 - overrun
232  m_eKeyState = KEY_PENDING;
233  cJSON_free(requestBody);
234  }
235  }
236  cJSON_Delete(licenseRequest);
237  }
238  free(urlEncodedkeyId);
239  }
240  }
241  return licenseChallenge;
242 }
243 
244 
245 /**
246  * @brief Updates the received key to DRM session
247  */
248 int ClearKeySession::aampDRMProcessKey(DrmData* key, uint32_t timeout)
249 {
250  int ret = 0;
251  if (!key)
252  {
253  AAMPLOG_ERR("ClearKeySession: Cannot Process Null Key ");
254  return ret;
255  }
256 
257  std::string keyDataStr = key->getData();
258  AAMPLOG_INFO("ClearKeySession: Processing license response %s", keyDataStr.c_str());
259  if (m_eKeyState == KEY_PENDING)
260  {
261  cJSON *licenseResponse = cJSON_Parse(keyDataStr.c_str());
262  if (licenseResponse)
263  {
264  if (cJSON_HasObjectItem(licenseResponse, "keys"))
265  {
266  cJSON * keyEntry = NULL;
267  cJSON *keyJsonObj = NULL;
268  cJSON *keyIdJsonObj = NULL;
269 
270  cJSON *keysArray = cJSON_GetObjectItem(licenseResponse, "keys");
271  if(keysArray)
272  {
273  keyEntry = keysArray->child;
274  if(keyEntry)
275  {
276  keyJsonObj = cJSON_GetObjectItem(keyEntry, "k");
277  keyIdJsonObj = cJSON_GetObjectItem(keyEntry, "kid");
278  }
279  }
280 
281  if (keyJsonObj && keyIdJsonObj)
282  {
283  char *keyJsonStr = cJSON_GetStringValue(keyJsonObj);
284  char *keyIdStr = cJSON_GetStringValue(keyIdJsonObj);
285  size_t resKeyIdLen = 0;
286  size_t resKeyLen = 0;
287  unsigned char * resKeyId = aamp_Base64_URL_Decode(keyIdStr, &resKeyIdLen, strlen(keyIdStr));
288  if (resKeyIdLen == m_keyIdLen && 0 == memcmp(m_keyId, resKeyId, m_keyIdLen))
289  {
290  if (m_keyStr != NULL)
291  {
292  free (m_keyStr);
293  }
294  m_keyStr = aamp_Base64_URL_Decode(keyJsonStr, &resKeyLen, strlen(keyJsonStr));
295  if (resKeyLen == AES_CTR_KEY_LEN)
296  {
297  m_keyLen = resKeyLen;
298  m_eKeyState = KEY_READY;
299  AAMPLOG_INFO("ClearKeySession: Got key from license response keyLength %d", m_keyLen);
300  ret = 1;
301  }
302  else
303  {
304  AAMPLOG_ERR("ClearKeySession: ERROR : Failed parse Key from response");
305  if (m_keyStr)
306  {
307  free (m_keyStr);
308  m_keyStr = NULL;
309  }
310  m_eKeyState = KEY_ERROR;
311  }
312  }
313  else
314  {
315  AAMPLOG_ERR("ClearKeySession: ERROR : Failed parse KeyID/invalid keyID, from response");
316  m_eKeyState = KEY_ERROR;
317  }
318  if (resKeyId)
319  {
320  free(resKeyId);
321  }
322  }
323  else
324  {
325  AAMPLOG_ERR("ClearKeySession: ERROR : Failed parse Key info, from response");
326  m_eKeyState = KEY_ERROR;
327  }
328  }
329  cJSON_Delete(licenseResponse);
330  }
331  else
332  {
333  AAMPLOG_ERR("ClearKeySession: ERROR : Failed parse response JSON");
334  m_eKeyState = KEY_ERROR;
335  }
336  }
337  else
338  {
339  AAMPLOG_ERR("ClearKeySession: ERROR : Invalid DRM state : DRMState %d", m_eKeyState);
340  }
341  return ret;
342 }
343 
344 /**
345  * @brief Function to decrypt stream.
346  */
347 int ClearKeySession::decrypt(GstBuffer* keyIDBuffer, GstBuffer* ivBuffer, GstBuffer* buffer, unsigned subSampleCount,
348  GstBuffer* subSamplesBuffer, GstCaps* caps)
349 {
350  int retVal = 1;
351  uint8_t *pbData = NULL;
352  uint32_t cbData = 0;
353  uint16_t nBytesClear = 0;
354  uint32_t nBytesEncrypted = 0;
355 
356  GstMapInfo ivMap;
357  GstMapInfo subsampleMap = GST_MAP_INFO_INIT;
358  GstMapInfo bufferMap;
359  GstByteReader* reader = NULL;
360 
361  bool ivMapped = false;
362  bool subSampleMapped = false;
363  bool bufferMapped = false;
364 
365  if(!(ivBuffer && buffer && (subSampleCount == 0 || subSamplesBuffer)))
366  {
367  AAMPLOG_ERR(
368  "ClearKeySession: ERROR : Ivalid buffer ivBuffer(%p), buffer(%p), subSamplesBuffer(%p) ",
369  ivBuffer, buffer, subSamplesBuffer);
370  }
371  else
372  {
373  bufferMapped = gst_buffer_map(buffer, &bufferMap,static_cast<GstMapFlags>(GST_MAP_READWRITE));
374  if (!bufferMapped)
375  {
376  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to map buffer");
377  }
378 
379  ivMapped = gst_buffer_map(ivBuffer, &ivMap, GST_MAP_READ);
380  if (!ivMapped)
381  {
382  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to map ivBuffer");
383  }
384 
385  if(subSampleCount > 0)
386  {
387  subSampleMapped = gst_buffer_map(subSamplesBuffer, &subsampleMap, GST_MAP_READ);
388  if (!subSampleMapped)
389  {
390  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to map subSamplesBuffer");
391  }
392  }
393  }
394 
395  if(bufferMapped && ivMapped && (subSampleCount ==0 || subSampleMapped))
396  {
397  reader = gst_byte_reader_new(subsampleMap.data, subsampleMap.size);
398  if(reader)
399  {
400  // collect all the encrypted bytes into one contiguous buffer
401  // we need to call decrypt once for all encrypted bytes.
402  if (subSampleCount > 0)
403  {
404  pbData = (uint8_t *) malloc(sizeof(uint8_t) * bufferMap.size);
405  uint8_t *pbCurrTarget = (uint8_t *) pbData;
406  uint32_t iCurrSource = 0;
407 
408  for (int i = 0; i < subSampleCount; i++)
409  {
410  if (!gst_byte_reader_get_uint16_be(reader, &nBytesClear)
411  || !gst_byte_reader_get_uint32_be(reader, &nBytesEncrypted))
412  {
413  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to read from subsamples reader");
414  cbData = 0;
415  break;
416  }
417  // Skip the clear byte range from source buffer.
418  iCurrSource += nBytesClear;
419 
420  // Copy cipher bytes from f_pbData to target buffer.
421  memcpy(pbCurrTarget, (uint8_t*) bufferMap.data + iCurrSource, nBytesEncrypted);
422 
423  // Adjust current pointer of target buffer.
424  pbCurrTarget += nBytesEncrypted;
425 
426  // Adjust current offset of source buffer.
427  iCurrSource += nBytesEncrypted;
428  cbData += nBytesEncrypted;
429  }
430  }
431  else
432  {
433  pbData = bufferMap.data;
434  cbData = bufferMap.size;
435  }
436 
437  if(cbData != 0)
438  {
439  retVal = decrypt(static_cast<uint8_t *>(ivMap.data), static_cast<uint32_t>(ivMap.size),
440  pbData, cbData, NULL);
441  }
442 
443  if(retVal == 0)
444  {
445  if(subSampleCount > 0)
446  {
447  // If subsample mapping is used, copy decrypted bytes back
448  // to the original buffer.
449  gst_byte_reader_set_pos(reader, 0);
450  uint8_t *pbCurrTarget = bufferMap.data;
451  uint32_t iCurrSource = 0;
452 
453  for (int i = 0; i < subSampleCount; i++)
454  {
455  if (!gst_byte_reader_get_uint16_be(reader, &nBytesClear)
456  || !gst_byte_reader_get_uint32_be(reader, &nBytesEncrypted))
457  {
458  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to read from subsamples reader");
459  retVal = 1;
460  break;
461  }
462  // Skip the clear byte range from target buffer.
463  pbCurrTarget += nBytesClear;
464  memcpy(pbCurrTarget, pbData + iCurrSource, nBytesEncrypted);
465 
466  // Adjust current pointer of target buffer.
467  pbCurrTarget += nBytesEncrypted;
468 
469  // Adjust current offset of source buffer.
470  iCurrSource += nBytesEncrypted;
471  }
472  }//SubSample end if
473  } //retVal end if
474  }//reader end if
475  else
476  {
477  AAMPLOG_ERR("ClearKeySession: ERROR : Failed to allocate subsample reader");
478  }
479  }
480 
481  if(subSampleCount > 0 && pbData)
482  {
483  free(pbData);
484  }
485  if(bufferMapped)
486  {
487  gst_buffer_unmap(buffer, &bufferMap);
488  }
489  if(ivMapped)
490  {
491  gst_buffer_unmap(ivBuffer, &ivMap);
492  }
493  if(subSampleMapped)
494  {
495  gst_buffer_unmap(subSamplesBuffer, &subsampleMap);
496  }
497 
498  return retVal;
499 }
500 
501 /**
502  * @brief Function to decrypt stream buffer.
503  */
504 int ClearKeySession::decrypt(const uint8_t *f_pbIV, uint32_t f_cbIV,
505  const uint8_t *payloadData, uint32_t payloadDataSize, uint8_t **ppOpaqueData=NULL)
506 {
507  int status = 1;
508  pthread_mutex_lock(&decryptMutex);
509 
510  if (m_eKeyState == KEY_READY)
511  {
512  uint8_t *decryptedDataBuf = (uint8_t *)malloc(payloadDataSize);
513  uint32_t decryptedDataLen = 0;
514  uint8_t *ivBuff = NULL;
515  if(decryptedDataBuf)
516  {
517  memset(decryptedDataBuf, 0, payloadDataSize);
518  if(f_cbIV == 8)//8 byte IV need to pad with 0 before decrypt
519  {
520  ivBuff = (uint8_t *)malloc(sizeof(uint8_t) * AES_CTR_IV_LEN);
521  if(ivBuff != NULL)
522  {
523  memset(ivBuff + 8, 0, 8);
524  memcpy(ivBuff, f_pbIV, 8);
525  }
526  }
527  else if(f_cbIV == AES_CTR_IV_LEN)
528  {
529  ivBuff = (uint8_t *)malloc(sizeof(uint8_t) * AES_CTR_IV_LEN);
530  memcpy(ivBuff, f_pbIV, AES_CTR_IV_LEN);
531  }
532  else
533  {
534  AAMPLOG_TRACE("ClearKeySession: invalid IV size %u", f_cbIV);
535  }
536  }
537 
538  if (decryptedDataBuf && ivBuff)
539  {
540  uint32_t decLen = payloadDataSize;
541 
542  if(!EVP_DecryptInit_ex(OPEN_SSL_CONTEXT, EVP_aes_128_ctr(), NULL, m_keyStr, ivBuff))
543  {
544  AAMPLOG_TRACE( "ClearKeySession: EVP_DecryptInit_ex failed");
545  }
546  else
547  {
548  if (!EVP_DecryptUpdate(OPEN_SSL_CONTEXT,(unsigned char*) decryptedDataBuf, (int*) &decLen, (const unsigned char*) payloadData,
549  payloadDataSize))
550  {
551  AAMPLOG_TRACE("ClearKeySession: EVP_DecryptUpdate failed");
552  }
553  else
554  {
555  decryptedDataLen = decLen;
556  decLen = 0;
557  AAMPLOG_TRACE("ClearKeySession: EVP_DecryptUpdate success decryptedDataLen = %d payload Data length = %d", (int) decryptedDataLen, (int)payloadDataSize);
558  if (!EVP_DecryptFinal_ex(OPEN_SSL_CONTEXT, (unsigned char*) (decryptedDataBuf + decryptedDataLen), (int*) &decLen))
559  {
560  AAMPLOG_TRACE("ClearKeySession: EVP_DecryptFinal_ex failed mDrmState = %d", (int) m_eKeyState);
561  }
562  else
563  {
564  decryptedDataLen += decLen;
565  AAMPLOG_TRACE("ClearKeySession: decrypt success");
566  status = 0;
567  }
568  }
569  }
570 
571  memcpy((void *)payloadData, decryptedDataBuf, payloadDataSize);
572  }
573  if(ivBuff)
574  {
575  free(ivBuff); //CID:108053 - Resource leak
576  ivBuff = NULL;
577  }
578  if(decryptedDataBuf)
579  {
580  free(decryptedDataBuf);
581  decryptedDataBuf = NULL;
582  }
583  }
584  else
585  {
586  AAMPLOG_ERR( "ClearKeySession: key not ready! mDrmState = %d", m_eKeyState);
587  }
588  pthread_mutex_unlock(&decryptMutex);
589  return status;
590 }
591 
592 /**
593  * @brief Get the current state of DRM Session.
594  */
596 {
597  return m_eKeyState;
598 }
599 
600 /**
601  * @brief Clear the current session context
602  * So that new init data can be bound.
603  */
605 {
606  if(m_keyId != NULL)
607  {
608  free(m_keyId);
609  m_keyId = NULL;
610  m_keyIdLen = 0;
611  }
612  if(m_keyStr != NULL)
613  {
614  free(m_keyStr);
615  m_keyStr = NULL;
616  m_keyLen = 0;
617  }
618 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
619  if( OPEN_SSL_CONTEXT )
620  {
621  EVP_CIPHER_CTX_free(OPEN_SSL_CONTEXT);
622  OPEN_SSL_CONTEXT = NULL;
623  }
624 #else
625  EVP_CIPHER_CTX_cleanup(OPEN_SSL_CONTEXT);
626 #endif
627  m_eKeyState = KEY_INIT;
628 }
629 
630 
AampLogManager::trace
bool trace
Definition: AampLogManager.h:156
AampConfig::logging
AampLogManager logging
Definition: AampConfig.h:462
ClearKeySession::~ClearKeySession
~ClearKeySession()
ClearKeySession Destructor.
Definition: ClearKeyDrmSession.cpp:177
DrmData
To hold DRM key, license request etc.
Definition: AampDrmData.h:32
gpGlobalConfig
AampConfig * gpGlobalConfig
Global configuration.
Definition: main_aamp.cpp:48
DumpBlob
void DumpBlob(const unsigned char *ptr, size_t len)
Compactly log blobs of binary data.
Definition: aamplogging.cpp:533
ClearKeySession::aampGenerateKeyRequest
DrmData * aampGenerateKeyRequest(string &destinationURL, uint32_t timeout)
Generate key request from DRM session Caller function should free the returned memory.
Definition: ClearKeyDrmSession.cpp:206
ClearKeySession::setKeyId
void setKeyId(const char *keyId, int32_t keyIDLen)
SetKid for this session.
Definition: ClearKeyDrmSession.cpp:86
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
KEY_PENDING
@ KEY_PENDING
Definition: AampDrmSession.h:57
ClearKeySession::decrypt
int decrypt(const uint8_t *f_pbIV, uint32_t f_cbIV, const uint8_t *payloadData, uint32_t payloadDataSize, uint8_t **ppOpaqueData)
Function to decrypt stream buffer.
Definition: ClearKeyDrmSession.cpp:504
ClearKeySession::aampDRMProcessKey
int aampDRMProcessKey(DrmData *key, uint32_t timeout)
Updates the received key to DRM session.
Definition: ClearKeyDrmSession.cpp:248
ClearKeySession::initAampDRMSession
void initAampDRMSession()
Initialize CK DRM session, Initializes EVP context.
Definition: ClearKeyDrmSession.cpp:73
AampDrmSession
Base class for DRM sessions.
Definition: AampDrmSession.h:69
ClearKeySession::clearDecryptContext
void clearDecryptContext()
Clear the current session context So that new init data can be bound.
Definition: ClearKeyDrmSession.cpp:604
aamp_Base64_URL_Decode
unsigned char * aamp_Base64_URL_Decode(const char *src, size_t *len, size_t srcLen)
decode base64 URL encoded data to binary equivalent
Definition: AampUtils.cpp:340
AampConfig.h
Configurations for AAMP.
priv_aamp.h
Private functions and types used internally by AAMP.
ClearKeySession::getState
KeyState getState()
Get the current state of DRM Session.
Definition: ClearKeyDrmSession.cpp:595
ClearKeySession::ClearKeySession
ClearKeySession(AampLogManager *logObj)
ClearKeySession Constructor.
Definition: ClearKeyDrmSession.cpp:54
AAMPLOG_TRACE
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
Definition: AampLogManager.h:83
KEY_INIT
@ KEY_INIT
Definition: AampDrmSession.h:56
ClearKeyDrmSession.h
Header file for ClearKeySession.
aamp_Base64_URL_Encode
char * aamp_Base64_URL_Encode(const unsigned char *src, size_t len)
convert blob of binary data to ascii base64-URL-encoded equivalent
Definition: AampUtils.cpp:304
KEY_READY
@ KEY_READY
Definition: AampDrmSession.h:58
ClearKeySession::generateAampDRMSession
void generateAampDRMSession(const uint8_t *f_pbInitData, uint32_t f_cbInitData, std::string &customData)
Create drm session with given init data state will be KEY_INIT on success KEY_ERROR if failed.
Definition: ClearKeyDrmSession.cpp:137
KeyState
KeyState
DRM session states.
Definition: AampDrmSession.h:54
extractKeyIdFromPssh
static unsigned char * extractKeyIdFromPssh(const char *psshData, int dataLength, int *len)
Extract the keyId from PSSH data. Different procedures are used for PlayReady and WideVine.
Definition: ClearKeyDrmSession.cpp:108
DrmData::getData
const std::string & getData()
Getter method for data.
Definition: AampDRMutils.cpp:75
KEY_ERROR
@ KEY_ERROR
Definition: AampDrmSession.h:59
KEY_CLOSED
@ KEY_CLOSED
Definition: AampDrmSession.h:60