Origin commit data
------------------
Branch: master
Commit: 46f67aaef0
Author: max_10 <max_10@gmx.de>
Date: 2015-11-18 (Wed, 18 Nov 2015)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
max_10
2015-11-18 17:16:39 +01:00
parent a27ebe7d38
commit 2ddb9ae15d
3 changed files with 43 additions and 24 deletions

View File

@@ -193,7 +193,7 @@ static bool transmitData(tSlot* slot, unsigned char* d, int len)
return eDataError; return eDataError;
} }
#else #else
#if x_debug #if y_debug
printf("SendData with data (len %d) >\n", len); printf("SendData with data (len %d) >\n", len);
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
printf("%02x ", d[i]); printf("%02x ", d[i]);
@@ -234,10 +234,12 @@ static bool sendRCV(tSlot* slot)
send_data[2] = T_RCV; send_data[2] = T_RCV;
send_data[3] = 1; send_data[3] = 1;
send_data[4] = slot->connection_id; send_data[4] = slot->connection_id;
#if y_debug
printf("*** > T_RCV: "); printf("*** > T_RCV: ");
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
printf("%02x ", send_data[i]); printf("%02x ", send_data[i]);
printf("\n"); printf("\n");
#endif
write(slot->fd, send_data, 5); write(slot->fd, send_data, 5);
return true; return true;
} }
@@ -343,13 +345,11 @@ void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_
if (slot->receivedData == NULL) if (slot->receivedData == NULL)
{ {
printf("%s -> single package\n", FILENAME); printf("%s -> single package\n", FILENAME);
#if x_debug
printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length);
#if y_debug #if y_debug
printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length);
for (int i = 0; i < asn_data_length; i++) for (int i = 0; i < asn_data_length; i++)
printf("%02x ", data[i]); printf("%02x ", data[i]);
printf("\n"); printf("\n");
#endif
#endif #endif
/* to avoid illegal session number: only if > 0 */ /* to avoid illegal session number: only if > 0 */
if (asn_data_length) if (asn_data_length)
@@ -368,7 +368,7 @@ void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_
slot->receivedData = new_data_buffer; slot->receivedData = new_data_buffer;
memcpy(slot->receivedData + slot->receivedLen, data, asn_data_length); memcpy(slot->receivedData + slot->receivedLen, data, asn_data_length);
slot->receivedLen = new_data_length; slot->receivedLen = new_data_length;
#if x_debug #if y_debug
printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length); printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length);
for (int i = 0; i < slot->receivedLen; i++) for (int i = 0; i < slot->receivedLen; i++)
printf("%02x ", slot->receivedData[i]); printf("%02x ", slot->receivedData[i]);

View File

@@ -23,6 +23,10 @@
#include "dvbci_ccmgr.h" #include "dvbci_ccmgr.h"
/* for some debug > set to 1 */
#define x_debug 0
#define y_debug 0
static const char * FILENAME = "[dvbci_ccmgr]"; static const char * FILENAME = "[dvbci_ccmgr]";
/* storage & load of authenticated data (HostID & DHSK & AKH) */ /* storage & load of authenticated data (HostID & DHSK & AKH) */
@@ -620,9 +624,9 @@ static int sac_crypt(uint8_t *dst, const uint8_t *src, unsigned int len, const u
AES_KEY key; AES_KEY key;
/* AES_ENCRYPT is '1' */ /* AES_ENCRYPT is '1' */
#if x_debug
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
#endif
if (encrypt) if (encrypt)
AES_set_encrypt_key(key_data, 128, &key); AES_set_encrypt_key(key_data, 128, &key);
else else
@@ -850,9 +854,9 @@ static void check_new_key(struct cc_ctrl_data *cc_data)
uint8_t *kp; uint8_t *kp;
uint8_t slot; uint8_t slot;
unsigned int i; unsigned int i;
#if x_debug
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
#endif
/* check for keyprecursor */ /* check for keyprecursor */
if (!element_valid(cc_data, 12)) if (!element_valid(cc_data, 12))
return; return;
@@ -885,7 +889,9 @@ static void check_new_key(struct cc_ctrl_data *cc_data)
static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id) static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
{ {
#if x_debug
printf("%s -> %s ID = (%d)\n", FILENAME, __FUNCTION__, id); printf("%s -> %s ID = (%d)\n", FILENAME, __FUNCTION__, id);
#endif
/* handle trigger events */ /* handle trigger events */
/* depends on new received items */ /* depends on new received items */
@@ -934,8 +940,9 @@ static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
static int data_req_handle_new(struct cc_ctrl_data *cc_data, unsigned int id) static int data_req_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
{ {
#if x_debug
printf("%s -> %s ID = (%d)\n", FILENAME, __FUNCTION__, id); printf("%s -> %s ID = (%d)\n", FILENAME, __FUNCTION__, id);
#endif
switch (id) { switch (id) {
case 22: /* AKH */ case 22: /* AKH */
{ {
@@ -962,9 +969,9 @@ static int data_get_loop(struct cc_ctrl_data *cc_data, const unsigned char *data
unsigned int i; unsigned int i;
int dt_id, dt_len; int dt_id, dt_len;
unsigned int pos = 0; unsigned int pos = 0;
#if x_debug
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
#endif
for (i = 0; i < items; i++) { for (i = 0; i < items; i++) {
if (pos + 3 > datalen) if (pos + 3 > datalen)
return 0; return 0;
@@ -975,9 +982,14 @@ static int data_get_loop(struct cc_ctrl_data *cc_data, const unsigned char *data
if (pos + dt_len > datalen) if (pos + dt_len > datalen)
return 0; return 0;
#if x_debug
printf("set element (%d) ", dt_id); printf("set element (%d) ", dt_id);
#if y_debug
hexdump(&data[pos], dt_len); hexdump(&data[pos], dt_len);
#else
printf("\n");
#endif
#endif
element_set(cc_data, dt_id, &data[pos], dt_len); element_set(cc_data, dt_id, &data[pos], dt_len);
data_get_handle_new(cc_data, dt_id); data_get_handle_new(cc_data, dt_id);
@@ -994,27 +1006,32 @@ static int data_req_loop(struct cc_ctrl_data *cc_data, unsigned char *dest, cons
unsigned int i; unsigned int i;
int pos = 0; int pos = 0;
int len; int len;
#if x_debug
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
#endif
if (items > datalen) if (items > datalen)
return -1; return -1;
for (i = 0; i < items; i++) { for (i = 0; i < items; i++) {
dt_id = *data++; dt_id = *data++;
#if x_debug
printf("req element %d\n", dt_id); printf("req element %d\n", dt_id);
#endif
data_req_handle_new(cc_data, dt_id); /* check if there is any action needed before we answer */ data_req_handle_new(cc_data, dt_id); /* check if there is any action needed before we answer */
len = element_get_req(cc_data, dest, dt_id); len = element_get_req(cc_data, dest, dt_id);
if (len == 0) { if (len == 0) {
printf("cannot get element %d\n", dt_id); printf("cannot get element %d\n", dt_id);
return -1; return -1;
} }
// #if x_debug
printf("element (%d) > ", dt_id); printf("element (%d) > ", dt_id);
#if y_debug
for (int ic = 0; ic < len; ic++) for (int ic = 0; ic < len; ic++)
printf("%02x ", dest[ic]); printf("%02x ", dest[ic]);
#endif
printf("\n"); printf("\n");
// #endif
pos += len; pos += len;
dest += len; dest += len;
} }
@@ -1138,8 +1155,9 @@ void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_sync_req(tSlot *tslot,
int pos = 0; int pos = 0;
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
#if y_debug
hexdump(data, len); hexdump(data, len);
#endif
serial = UINT32(data, 4); serial = UINT32(data, 4);
pos += BYTE32(&dest[pos], serial); pos += BYTE32(&dest[pos], serial);
@@ -1173,12 +1191,12 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_send(tSlot *tslot, cons
BYTE16(&data[6], pos - 8); /* len in header */ BYTE16(&data[6], pos - 8); /* len in header */
pos += sac_gen_auth(&data[pos], data, pos, cc_data->sak); pos += sac_gen_auth(&data[pos], data, pos, cc_data->sak);
// #if y_debug
printf("Data for encrypt > "); printf("Data for encrypt > ");
for (unsigned int i = 0; i < pos; i++) for (unsigned int i = 0; i < pos; i++)
printf("%02x ", data[i]); printf("%02x ", data[i]);
printf("\n"); printf("\n");
// #endif
sac_crypt(&data[8], &data[8], pos - 8, cc_data->sek, AES_ENCRYPT); sac_crypt(&data[8], &data[8], pos - 8, cc_data->sek, AES_ENCRYPT);
sendAPDU(tag, data, pos); sendAPDU(tag, data, pos);
@@ -1204,12 +1222,12 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_data_req(tSlot *tslot,
memcpy(tmp, data, 8); memcpy(tmp, data, 8);
sac_crypt(&tmp[8], &data[8], len - 8, cc_data->sek, AES_DECRYPT); sac_crypt(&tmp[8], &data[8], len - 8, cc_data->sek, AES_DECRYPT);
data = tmp; data = tmp;
// #if y_debug
printf("decryted > "); printf("decryted > ");
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
printf("%02x ", data[i]); printf("%02x ", data[i]);
printf("\n"); printf("\n");
// #endif
if (!sac_check_auth(data, len, cc_data->sak)) { if (!sac_check_auth(data, len, cc_data->sak)) {
fprintf(stderr, "check_auth of message failed\n"); fprintf(stderr, "check_auth of message failed\n");
return false; return false;
@@ -1277,9 +1295,10 @@ void eDVBCIContentControlManagerSession::ci_ccmgr_doClose(tSlot *tslot)
int eDVBCIContentControlManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCIContentControlManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)/CC %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]); printf("SESSION(%d)/CC %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
#if y_debug
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
printf("%02x ", ((const unsigned char*)data)[i]); printf("%02x ", ((const unsigned char*)data)[i]);
#endif
printf("\n"); printf("\n");
if ((tag[0] == 0x9f) && (tag[1] == 0x90)) { if ((tag[0] == 0x9f) && (tag[1] == 0x90)) {

View File

@@ -337,7 +337,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
alen = len; alen = len;
} }
printf("1. Call receivedAPDU tag = 0x%2x, len = %d\n", (int) stag, alen); //printf("1. Call receivedAPDU tag = 0x%2x, len = %d\n", (int) stag, alen);
if (session->receivedAPDU(stag, pkt, alen)) if (session->receivedAPDU(stag, pkt, alen))
session->action = 1; session->action = 1;