17 #ifndef _TS2_IEC_62455_H_
18 #define _TS2_IEC_62455_H_
28 #define TS2_KSM_TABLE80_ID 0x80
29 #define TS2_KSM_TABLE81_ID 0x81
31 #define TS2_KSM_PROTOCOL_VERSION_1 0x01
33 #define TS2_KSM_ENCRYPTED_PEK_SIZE 16
34 #define TS2_KSM_MAC_SIZE 12
35 #define TS2_KSM_CID_EXTENSION_SIZE 4
37 #define TS2_KSM_ALGO_IPSEC 0
38 #define TS2_KSM_ALGO_SRTP 1
39 #define TS2_KSM_ALGO_ISMACRYPT 2
40 #define TS2_KSM_ALGO_MPEG2_TS_CRYPT 7
42 #define TS2_KSM_FLAG_EVEN 0
43 #define TS2_KSM_FLAG_ODD 1
45 #define TS2_KSM_CONTENT_KEY_INDEX_DVB_CSA_64 0x00
46 #define TS2_KSM_CONTENT_KEY_INDEX_DES_56 0x01
47 #define TS2_KSM_CONTENT_KEY_INDEX_3DES_168 0x02
48 #define TS2_KSM_CONTENT_KEY_INDEX_3DES_112 0x03
49 #define TS2_KSM_CONTENT_KEY_INDEX_3DES_56 0x04
50 #define TS2_KSM_CONTENT_KEY_INDEX_AES_128 0x05
51 #define TS2_KSM_CONTENT_KEY_INDEX_M2_64 0x06
52 #define TS2_KSM_CONTENT_KEY_INDEX_AES_128_KDF 0x0F
54 #define TS2_KSM_CIPHER_MODE_ECB 0x00
55 #define TS2_KSM_CIPHER_MODE_CBC 0x01
56 #define TS2_KSM_CIPHER_MODE_CSA 0x02
58 #define TS2_KSM_FLAG_EVEN 0
59 #define TS2_KSM_FLAG_ODD 1
138 const ATX_Byte* encrypted_pek,
139 const ATX_Byte* cid_extension);
150 const ATX_Byte* cid_extension);
178 ATX_UInt32 crypto_period,
179 ATX_UInt8 odd_even_flag,
180 const ATX_Byte* enc_key_material,
181 const ATX_Byte* next_enc_key_material,
183 const ATX_Byte* next_iv,
186 const ATX_Byte* mac_key,
187 ATX_Size mac_key_size,
188 const ATX_Byte* access_criteria,
189 ATX_Size access_criteria_size,
203 ATX_DataBuffer** buffer);
207 ATX_Size buffer_size,
259 #define TS2_KSM_Flags_ProtocolVersion(flags) (((flags) & 0xF000) >> 12)
260 #define TS2_KSM_Flags_AccessCriteriaFlag(flags) (((flags) & 0x0100) >> 8)
261 #define TS2_KSM_Flags_TrafficProtectionProtocol(flags) (((flags) & 0x00E0) >> 5)
262 #define TS2_KSM_Flags_TrafficAuthenticationFlag(flags) (((flags) & 0x0010) >> 4)
263 #define TS2_KSM_Flags_NextTrafficKeyFlag(flags) (((flags) & 0x0008) >> 3)
264 #define TS2_KSM_Flags_TimestampFlag(flags) (((flags) & 0x0004) >> 2)
265 #define TS2_KSM_Flags_ProgrammeFlag(flags) (((flags) & 0x0002) >> 1)
266 #define TS2_KSM_Flags_ServiceFlag(flags) (((flags) & 0x0001) )
268 #define TS2_Mpeg2TsCryptKSM_ContentKeyIndex(m2ksm) ((((m2ksm)->info) & 0xF0) >> 4)
269 #define TS2_Mpeg2TsCryptKSM_OddEvenFlag(m2ksm) ((((m2ksm)->info) & 0x08) >> 3)
270 #define TS2_Mpeg2TsCryptKSM_CipherMode(m2ksm) ((((m2ksm)->info) & 0x07) )
272 #define TS2_GetKeyLifetimeInSecs(klf) (1 << (klf))
277 #define TS2_KSM_Destroy(KSM) \
279 TS2_KSM* __ksm = (KSM); \
280 if (__ksm && __ksm->Destroy) { \
281 __ksm->Destroy(__ksm); \