Wasabi ExpressPlay SDK for Embedded Systems  1.23.0
Data Structures | Macros | Typedefs | Functions
Ts2Iec62455.h File Reference
#include "Ts2Tables.h"

Go to the source code of this file.

Data Structures

struct  TS2_KSM_AccessCriteria
 
struct  TS2_KSM_Programme
 
struct  TS2_KSM_Service
 
struct  TS2_KSM
 
struct  TS2_Mpeg2TsCryptKSM
 
struct  TS2_KSMT
 

Macros

#define TS2_KSM_TABLE80_ID   0x80
 
#define TS2_KSM_TABLE81_ID   0x81
 
#define TS2_KSM_PROTOCOL_VERSION_1   0x01
 
#define TS2_KSM_ENCRYPTED_PEK_SIZE   16
 
#define TS2_KSM_MAC_SIZE   12
 
#define TS2_KSM_CID_EXTENSION_SIZE   4
 
#define TS2_KSM_ALGO_IPSEC   0
 
#define TS2_KSM_ALGO_SRTP   1
 
#define TS2_KSM_ALGO_ISMACRYPT   2
 
#define TS2_KSM_ALGO_MPEG2_TS_CRYPT   7
 
#define TS2_KSM_FLAG_EVEN   0
 
#define TS2_KSM_FLAG_ODD   1
 
#define TS2_KSM_CONTENT_KEY_INDEX_DVB_CSA_64   0x00
 
#define TS2_KSM_CONTENT_KEY_INDEX_DES_56   0x01
 
#define TS2_KSM_CONTENT_KEY_INDEX_3DES_168   0x02
 
#define TS2_KSM_CONTENT_KEY_INDEX_3DES_112   0x03
 
#define TS2_KSM_CONTENT_KEY_INDEX_3DES_56   0x04
 
#define TS2_KSM_CONTENT_KEY_INDEX_AES_128   0x05 /* BBTS 1.0/1.1 */
 
#define TS2_KSM_CONTENT_KEY_INDEX_M2_64   0x06
 
#define TS2_KSM_CONTENT_KEY_INDEX_AES_128_KDF   0x0F /* BBTS 2.0, Key Derivation Function */
 
#define TS2_KSM_CIPHER_MODE_ECB   0x00
 
#define TS2_KSM_CIPHER_MODE_CBC   0x01
 
#define TS2_KSM_CIPHER_MODE_CSA   0x02
 
#define TS2_KSM_FLAG_EVEN   0
 
#define TS2_KSM_FLAG_ODD   1
 
#define TS2_KSM_Flags_ProtocolVersion(flags)   (((flags) & 0xF000) >> 12)
 
#define TS2_KSM_Flags_AccessCriteriaFlag(flags)   (((flags) & 0x0100) >> 8)
 
#define TS2_KSM_Flags_TrafficProtectionProtocol(flags)   (((flags) & 0x00E0) >> 5)
 
#define TS2_KSM_Flags_TrafficAuthenticationFlag(flags)   (((flags) & 0x0010) >> 4)
 
#define TS2_KSM_Flags_NextTrafficKeyFlag(flags)   (((flags) & 0x0008) >> 3)
 
#define TS2_KSM_Flags_TimestampFlag(flags)   (((flags) & 0x0004) >> 2)
 
#define TS2_KSM_Flags_ProgrammeFlag(flags)   (((flags) & 0x0002) >> 1)
 
#define TS2_KSM_Flags_ServiceFlag(flags)   (((flags) & 0x0001) )
 
#define TS2_Mpeg2TsCryptKSM_ContentKeyIndex(m2ksm)   ((((m2ksm)->info) & 0xF0) >> 4)
 
#define TS2_Mpeg2TsCryptKSM_OddEvenFlag(m2ksm)   ((((m2ksm)->info) & 0x08) >> 3)
 
#define TS2_Mpeg2TsCryptKSM_CipherMode(m2ksm)   ((((m2ksm)->info) & 0x07) )
 
#define TS2_GetKeyLifetimeInSecs(klf)   (1 << (klf))
 
#define TS2_KSM_Destroy(KSM)
 Release all the memory allocated for the KSM object. More...
 

Typedefs

typedef struct TS2_KSM TS2_KSM
 

Functions

TS2_EXPORT ATX_Result TS2_KSMT_Construct (TS2_KSMT *self)
 
ATX_Result TS2_KSM_Programme_Construct (TS2_KSM_Programme *self, const ATX_Byte *encrypted_pek, const ATX_Byte *cid_extension)
 Initialize the KSM Programme structure. More...
 
ATX_Result TS2_KSM_Service_Construct (TS2_KSM_Service *self, const ATX_Byte *cid_extension)
 Initialize the KSM Service structure. More...
 
ATX_Result TS2_Mpeg2TsCryptKSM_Create (ATX_UInt32 content_key_index, ATX_UInt32 crypto_period, ATX_UInt8 odd_even_flag, const ATX_Byte *enc_key_material, const ATX_Byte *next_enc_key_material, const ATX_Byte *iv, const ATX_Byte *next_iv, const TS2_KSM_Programme *programme, const TS2_KSM_Service *service, const ATX_Byte *mac_key, ATX_Size mac_key_size, const ATX_Byte *access_criteria, ATX_Size access_criteria_size, TS2_KSM **ksm)
 Create a Marlin BBTS Key Stream Message (KSM) object. More...
 
ATX_Result TS2_Mpeg2TsCryptKSM_Serialize (TS2_Mpeg2TsCryptKSM *m2ksm, ATX_DataBuffer **buffer)
 Serialize a Marlin Key Stream Message. More...
 
ATX_Result TS2_KSM_CreateFromBuffer (const ATX_Byte *buffer, ATX_Size buffer_size, TS2_KSM **ksm)
 
void TS2_Mpeg2TsCryptKSM_SwitchOddEvenFlag (TS2_Mpeg2TsCryptKSM *self)
 
ATX_Result TS2_KSM_AccessCriteria_Parse (const ATX_Byte *ac_data, ATX_Size *ac_size, TS2_KSM_AccessCriteria **ac)
 Parses the access_criteria block in the KSM. More...
 
ATX_Result TS2_KSM_AccessCriteria_Serialize (TS2_KSM_AccessCriteria *ac, ATX_Byte *buffer, ATX_Size *buffer_size)
 Serializes the TS2_KSM_AccessCriteria object to a data-buffer. More...
 
void TS2_KSM_AccessCriteria_Destroy (TS2_KSM_AccessCriteria *self)
 Destroys the TS2_KSM_AccessCriteria object. More...
 

Macro Definition Documentation

◆ TS2_GetKeyLifetimeInSecs

#define TS2_GetKeyLifetimeInSecs (   klf)    (1 << (klf))

◆ TS2_KSM_ALGO_IPSEC

#define TS2_KSM_ALGO_IPSEC   0

◆ TS2_KSM_ALGO_ISMACRYPT

#define TS2_KSM_ALGO_ISMACRYPT   2

◆ TS2_KSM_ALGO_MPEG2_TS_CRYPT

#define TS2_KSM_ALGO_MPEG2_TS_CRYPT   7

◆ TS2_KSM_ALGO_SRTP

#define TS2_KSM_ALGO_SRTP   1

◆ TS2_KSM_CID_EXTENSION_SIZE

#define TS2_KSM_CID_EXTENSION_SIZE   4

◆ TS2_KSM_CIPHER_MODE_CBC

#define TS2_KSM_CIPHER_MODE_CBC   0x01

◆ TS2_KSM_CIPHER_MODE_CSA

#define TS2_KSM_CIPHER_MODE_CSA   0x02

◆ TS2_KSM_CIPHER_MODE_ECB

#define TS2_KSM_CIPHER_MODE_ECB   0x00

◆ TS2_KSM_CONTENT_KEY_INDEX_3DES_112

#define TS2_KSM_CONTENT_KEY_INDEX_3DES_112   0x03

◆ TS2_KSM_CONTENT_KEY_INDEX_3DES_168

#define TS2_KSM_CONTENT_KEY_INDEX_3DES_168   0x02

◆ TS2_KSM_CONTENT_KEY_INDEX_3DES_56

#define TS2_KSM_CONTENT_KEY_INDEX_3DES_56   0x04

◆ TS2_KSM_CONTENT_KEY_INDEX_AES_128

#define TS2_KSM_CONTENT_KEY_INDEX_AES_128   0x05 /* BBTS 1.0/1.1 */

◆ TS2_KSM_CONTENT_KEY_INDEX_AES_128_KDF

#define TS2_KSM_CONTENT_KEY_INDEX_AES_128_KDF   0x0F /* BBTS 2.0, Key Derivation Function */

◆ TS2_KSM_CONTENT_KEY_INDEX_DES_56

#define TS2_KSM_CONTENT_KEY_INDEX_DES_56   0x01

◆ TS2_KSM_CONTENT_KEY_INDEX_DVB_CSA_64

#define TS2_KSM_CONTENT_KEY_INDEX_DVB_CSA_64   0x00

◆ TS2_KSM_CONTENT_KEY_INDEX_M2_64

#define TS2_KSM_CONTENT_KEY_INDEX_M2_64   0x06

◆ TS2_KSM_Destroy

#define TS2_KSM_Destroy (   KSM)
Value:
do { \
TS2_KSM* __ksm = (KSM); \
if (__ksm && __ksm->Destroy) { \
__ksm->Destroy(__ksm); \
} \
} while (0)

Release all the memory allocated for the KSM object.

◆ TS2_KSM_ENCRYPTED_PEK_SIZE

#define TS2_KSM_ENCRYPTED_PEK_SIZE   16

◆ TS2_KSM_FLAG_EVEN [1/2]

#define TS2_KSM_FLAG_EVEN   0

◆ TS2_KSM_FLAG_EVEN [2/2]

#define TS2_KSM_FLAG_EVEN   0

◆ TS2_KSM_FLAG_ODD [1/2]

#define TS2_KSM_FLAG_ODD   1

◆ TS2_KSM_FLAG_ODD [2/2]

#define TS2_KSM_FLAG_ODD   1

◆ TS2_KSM_Flags_AccessCriteriaFlag

#define TS2_KSM_Flags_AccessCriteriaFlag (   flags)    (((flags) & 0x0100) >> 8)

◆ TS2_KSM_Flags_NextTrafficKeyFlag

#define TS2_KSM_Flags_NextTrafficKeyFlag (   flags)    (((flags) & 0x0008) >> 3)

◆ TS2_KSM_Flags_ProgrammeFlag

#define TS2_KSM_Flags_ProgrammeFlag (   flags)    (((flags) & 0x0002) >> 1)

◆ TS2_KSM_Flags_ProtocolVersion

#define TS2_KSM_Flags_ProtocolVersion (   flags)    (((flags) & 0xF000) >> 12)

◆ TS2_KSM_Flags_ServiceFlag

#define TS2_KSM_Flags_ServiceFlag (   flags)    (((flags) & 0x0001) )

◆ TS2_KSM_Flags_TimestampFlag

#define TS2_KSM_Flags_TimestampFlag (   flags)    (((flags) & 0x0004) >> 2)

◆ TS2_KSM_Flags_TrafficAuthenticationFlag

#define TS2_KSM_Flags_TrafficAuthenticationFlag (   flags)    (((flags) & 0x0010) >> 4)

◆ TS2_KSM_Flags_TrafficProtectionProtocol

#define TS2_KSM_Flags_TrafficProtectionProtocol (   flags)    (((flags) & 0x00E0) >> 5)

◆ TS2_KSM_MAC_SIZE

#define TS2_KSM_MAC_SIZE   12

◆ TS2_KSM_PROTOCOL_VERSION_1

#define TS2_KSM_PROTOCOL_VERSION_1   0x01

◆ TS2_KSM_TABLE80_ID

#define TS2_KSM_TABLE80_ID   0x80

◆ TS2_KSM_TABLE81_ID

#define TS2_KSM_TABLE81_ID   0x81

◆ TS2_Mpeg2TsCryptKSM_CipherMode

#define TS2_Mpeg2TsCryptKSM_CipherMode (   m2ksm)    ((((m2ksm)->info) & 0x07) )

◆ TS2_Mpeg2TsCryptKSM_ContentKeyIndex

#define TS2_Mpeg2TsCryptKSM_ContentKeyIndex (   m2ksm)    ((((m2ksm)->info) & 0xF0) >> 4)

◆ TS2_Mpeg2TsCryptKSM_OddEvenFlag

#define TS2_Mpeg2TsCryptKSM_OddEvenFlag (   m2ksm)    ((((m2ksm)->info) & 0x08) >> 3)

Typedef Documentation

◆ TS2_KSM

typedef struct TS2_KSM TS2_KSM

Function Documentation

◆ TS2_KSM_AccessCriteria_Destroy()

void TS2_KSM_AccessCriteria_Destroy ( TS2_KSM_AccessCriteria self)

Destroys the TS2_KSM_AccessCriteria object.

Parameters
selfPointer to the TS2_KSM_AccessCriteria to destroy

◆ TS2_KSM_AccessCriteria_Parse()

ATX_Result TS2_KSM_AccessCriteria_Parse ( const ATX_Byte *  ac_data,
ATX_Size *  ac_size,
TS2_KSM_AccessCriteria **  ac 
)

Parses the access_criteria block in the KSM.

Parameters
ac_dataPointer to the buffer containing access_criteria descriptor block Contains the first reserved byte, number of access_criteria descriptors and the access_criteria descriptor loop
ac_sizeSize of the ac_data block, output contains actual size obtained in parsing
acAddress of the TS2_KSM_AccessCriteria pointer that will be set to the parsed TS2_KSM_AccessCriteria object

◆ TS2_KSM_AccessCriteria_Serialize()

ATX_Result TS2_KSM_AccessCriteria_Serialize ( TS2_KSM_AccessCriteria ac,
ATX_Byte *  buffer,
ATX_Size *  buffer_size 
)

Serializes the TS2_KSM_AccessCriteria object to a data-buffer.

Parameters
acPointer to the TS2_KSM_AccessCriteria object
bufferPointer to the data buffer
buffer_sizePointer to size of the buffer (in/out) - if buffer passed is too small function returns ATX_ERROR_NOT_ENOUGH_SPACE and the buffer_size is set to the required size

◆ TS2_KSM_CreateFromBuffer()

ATX_Result TS2_KSM_CreateFromBuffer ( const ATX_Byte *  buffer,
ATX_Size  buffer_size,
TS2_KSM **  ksm 
)

◆ TS2_KSM_Programme_Construct()

ATX_Result TS2_KSM_Programme_Construct ( TS2_KSM_Programme self,
const ATX_Byte *  encrypted_pek,
const ATX_Byte *  cid_extension 
)

Initialize the KSM Programme structure.

Parameters
selfpointer to the object.
encrypted_pekencrypted programme encryption key, pointer to an array of TS2_KSM_ENCRYPTED_PEK_SIZE data bytes.
cid_extensionContent ID extension, pointer to an array of TS2_KSM_CID_EXTENSION_SIZE bytes.

◆ TS2_KSM_Service_Construct()

ATX_Result TS2_KSM_Service_Construct ( TS2_KSM_Service self,
const ATX_Byte *  cid_extension 
)

Initialize the KSM Service structure.

Parameters
selfpointer to the object.
cid_extensionContent ID extension, pointer to an array of TS2_KSM_CID_EXTENSION_SIZE bytes.

◆ TS2_KSMT_Construct()

TS2_EXPORT ATX_Result TS2_KSMT_Construct ( TS2_KSMT self)

◆ TS2_Mpeg2TsCryptKSM_Create()

ATX_Result TS2_Mpeg2TsCryptKSM_Create ( ATX_UInt32  content_key_index,
ATX_UInt32  crypto_period,
ATX_UInt8  odd_even_flag,
const ATX_Byte *  enc_key_material,
const ATX_Byte *  next_enc_key_material,
const ATX_Byte *  iv,
const ATX_Byte *  next_iv,
const TS2_KSM_Programme programme,
const TS2_KSM_Service service,
const ATX_Byte *  mac_key,
ATX_Size  mac_key_size,
const ATX_Byte *  access_criteria,
ATX_Size  access_criteria_size,
TS2_KSM **  ksm 
)

Create a Marlin BBTS Key Stream Message (KSM) object.

The returned object must be released using TS2_KSM_Destroy once no longer needed.

Parameters
content_key_indexthe content_key_index field.
crypto_periodthe crypto period in seconds. Must be between 1 and 120.
odd_even_flagthe odd_even_flag field.
enc_key_materialthe encrypted_traffic_key_material field, TS2_AES_KEY_LENGTH bytes long.
next_enc_key_materialthe next encrypted_traffic_key_material field, TS2_AES_KEY_LENGTH bytes long.
ivthe initial_vector field, TS2_AES_CBC_IV_SIZE bytes long.
next_ivthe next_initial_vector, TS2_AES_CBC_IV_SIZE bytes long.
programmethe program object pointer, can be NULL.
servicethe service object pointer, can be NULL.
mac_keythe MAC key byte array.
mac_key_sizethe size of the mac_key array in bytes.
access_criteriaBuffer containing access criteria block (Optional)
access_criteria_sizeSize of access_criteria buffer (Optional)
ksmpointer to the pointer where a newly created KSM object is returned.

◆ TS2_Mpeg2TsCryptKSM_Serialize()

ATX_Result TS2_Mpeg2TsCryptKSM_Serialize ( TS2_Mpeg2TsCryptKSM m2ksm,
ATX_DataBuffer **  buffer 
)

Serialize a Marlin Key Stream Message.

Parameters
m2ksmpointer to the object.
bufferpointer to where a newly allocated output data buffer is returned. The returned buffer must be released by the caller using ATX_DataBuffer_Destroy() once no longer needed.

◆ TS2_Mpeg2TsCryptKSM_SwitchOddEvenFlag()

void TS2_Mpeg2TsCryptKSM_SwitchOddEvenFlag ( TS2_Mpeg2TsCryptKSM self)