This commit is contained in:
max10
2015-11-20 15:40:19 +01:00
parent 46f67aaef0
commit 8a10609125
6 changed files with 60 additions and 20 deletions

View File

@@ -38,6 +38,8 @@
static const char * FILENAME = "[ca_ci]"; static const char * FILENAME = "[ca_ci]";
static unsigned int LiveSlot = 0; static unsigned int LiveSlot = 0;
static bool CertChecked = false;
static bool Cert_OK = false;
static uint8_t NullPMT[50]={0x9F,0x80,0x32,0x2E,0x03,0x6E,0xA7,0x37,0x00,0x00,0x1B,0x15,0x7D,0x00,0x00,0x03,0x15,0x7E,0x00,0x00,0x03,0x15,0x7F,0x00, static uint8_t NullPMT[50]={0x9F,0x80,0x32,0x2E,0x03,0x6E,0xA7,0x37,0x00,0x00,0x1B,0x15,0x7D,0x00,0x00,0x03,0x15,0x7E,0x00,0x00,0x03,0x15,0x7F,0x00,
0x00,0x06,0x15,0x80,0x00,0x00,0x06,0x15,0x82,0x00,0x00,0x0B,0x08,0x7B,0x00,0x00,0x05,0x09,0x42,0x00,0x00,0x06,0x15,0x81,0x00,0x00}; 0x00,0x06,0x15,0x80,0x00,0x00,0x06,0x15,0x82,0x00,0x00,0x0B,0x08,0x7B,0x00,0x00,0x05,0x09,0x42,0x00,0x00,0x06,0x15,0x81,0x00,0x00};
@@ -1267,3 +1269,13 @@ bool cCA::SendNullPMT(tSlot* slot)
return true; return true;
} }
bool cCA::CheckCerts(void)
{
if(!CertChecked)
{
if (access(ROOT_CERT, F_OK) == 0 && access(ROOT_CERT, F_OK) == 0 && access(ROOT_CERT, F_OK) == 0)
Cert_OK = true;
CertChecked = true;
}
return Cert_OK;
}

View File

@@ -296,6 +296,7 @@ public:
unsigned int GetLiveSlot(void); unsigned int GetLiveSlot(void);
bool SendNullPMT(tSlot* slot); bool SendNullPMT(tSlot* slot);
bool CheckCerts(void);
void Test(int slot, CaIdVector caids); void Test(int slot, CaIdVector caids);
void DelTest(int slot); void DelTest(int slot);
/// Virtual destructor /// Virtual destructor

View File

@@ -773,9 +773,9 @@ static int restart_dh_challenge(struct cc_ctrl_data *cc_data)
} }
/* load certificates and device key */ /* load certificates and device key */
certificate_load_and_check(ctx, "/etc/pem/root.pem"); certificate_load_and_check(ctx, ROOT_CERT);
ctx->cust_cert = certificate_load_and_check(ctx, "/etc/pem/customer.pem"); ctx->cust_cert = certificate_load_and_check(ctx, CUSTOMER_CERT);
ctx->device_cert = certificate_load_and_check(ctx, "/etc/pem/device.pem"); ctx->device_cert = certificate_load_and_check(ctx, DEVICE_CERT);
if (!ctx->cust_cert || !ctx->device_cert) { if (!ctx->cust_cert || !ctx->device_cert) {
fprintf(stderr, "cannot loader certificates\n"); fprintf(stderr, "cannot loader certificates\n");
@@ -792,7 +792,7 @@ static int restart_dh_challenge(struct cc_ctrl_data *cc_data)
if (!element_set_hostid_from_certificate(cc_data, 5, ctx->device_cert)) if (!element_set_hostid_from_certificate(cc_data, 5, ctx->device_cert))
fprintf(stderr, "cannot set hostid in elements\n"); fprintf(stderr, "cannot set hostid in elements\n");
cc_data->rsa_device_key = rsa_privatekey_open("/etc/pem/device.pem"); cc_data->rsa_device_key = rsa_privatekey_open(DEVICE_CERT);
if (!cc_data->rsa_device_key) { if (!cc_data->rsa_device_key) {
fprintf(stderr, "cannot read private key\n"); fprintf(stderr, "cannot read private key\n");
return -1; return -1;

View File

@@ -49,6 +49,7 @@ int eDVBCIResourceManagerSession::doAction()
case stateStarted: case stateStarted:
{ {
const unsigned char tag[3] = {0x9F, 0x80, 0x10}; // profile enquiry const unsigned char tag[3] = {0x9F, 0x80, 0x10}; // profile enquiry
cCA::GetInstance()->CheckCerts();
sendAPDU(tag); sendAPDU(tag);
state = stateFirstProfileEnquiry; state = stateFirstProfileEnquiry;
return 0; return 0;
@@ -68,19 +69,38 @@ int eDVBCIResourceManagerSession::doAction()
case stateProfileEnquiry: case stateProfileEnquiry:
{ {
const unsigned char tag[3] = {0x9F, 0x80, 0x11}; const unsigned char tag[3] = {0x9F, 0x80, 0x11};
const unsigned char data[][4] = if (cCA::GetInstance()->CheckCerts())
{ {
{0x00, 0x01, 0x00, 0x41}, const unsigned char data[][4] =
{0x00, 0x02, 0x00, 0x41}, {
{0x00, 0x02, 0x00, 0x43}, {0x00, 0x01, 0x00, 0x41}, // resource
{0x00, 0x03, 0x00, 0x41}, {0x00, 0x02, 0x00, 0x41}, // application V1
// {0x00, 0x20, 0x00, 0x41}, // host control {0x00, 0x02, 0x00, 0x43}, // application V3
{0x00, 0x40, 0x00, 0x41}, {0x00, 0x03, 0x00, 0x41}, // conditional access
{0x00, 0x24, 0x00, 0x41}, // {0x00, 0x20, 0x00, 0x41}, // host control
{0x00, 0x8c, 0x10, 0x01} // content control {0x00, 0x40, 0x00, 0x41}, // mmi
// {0x00, 0x10, 0x00, 0x41} // auth. {0x00, 0x24, 0x00, 0x41}, // date-time
}; {0x00, 0x8c, 0x10, 0x01} // content control
sendAPDU(tag, data, sizeof(data)); // {0x00, 0x10, 0x00, 0x41} // auth.
};
sendAPDU(tag, data, sizeof(data));
}
else
{
const unsigned char data[][4] =
{
{0x00, 0x01, 0x00, 0x41}, // resource
{0x00, 0x02, 0x00, 0x41}, // application V1
{0x00, 0x02, 0x00, 0x43}, // application V3
{0x00, 0x03, 0x00, 0x41}, // conditional access
// {0x00, 0x20, 0x00, 0x41}, // host control
{0x00, 0x40, 0x00, 0x41}, // mmi
{0x00, 0x24, 0x00, 0x41} // date-time
// {0x00, 0x10, 0x00, 0x41} // auth.
};
sendAPDU(tag, data, sizeof(data));
}
//sendAPDU(tag, data, sizeof(data));
state = stateFinal; state = stateFinal;
return 0; return 0;
} }

View File

@@ -173,10 +173,13 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
sessions[session_nb - 1] = new eDVBCIMMISession(slot); sessions[session_nb - 1] = new eDVBCIMMISession(slot);
printf("MMI - create session\n"); printf("MMI - create session\n");
break; break;
case 0x008c1001: if (cCA::GetInstance()->CheckCerts())
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot); {
printf("CC MANAGER\n"); case 0x008c1001:
break; sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
printf("CC MANAGER\n");
break;
}
case 0x00100041: case 0x00100041:
// session=new eDVBCIAuthSession; // session=new eDVBCIAuthSession;
printf("AuthSession\n"); printf("AuthSession\n");

View File

@@ -5,6 +5,10 @@
#define SLMS 256 #define SLMS 256
#define ROOT_CERT "/etc/pem/root.pem"
#define CUSTOMER_CERT "/etc/pem/customer.pem"
#define DEVICE_CERT "/etc/pem/device.pem"
class eDVBCISession class eDVBCISession
{ {
static eDVBCISession* sessions[SLMS]; static eDVBCISession* sessions[SLMS];