mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
test c**
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
|
||||
static const char * FILENAME = "[ca_ci]";
|
||||
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,
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -296,6 +296,7 @@ public:
|
||||
|
||||
unsigned int GetLiveSlot(void);
|
||||
bool SendNullPMT(tSlot* slot);
|
||||
bool CheckCerts(void);
|
||||
void Test(int slot, CaIdVector caids);
|
||||
void DelTest(int slot);
|
||||
/// Virtual destructor
|
||||
|
@@ -773,9 +773,9 @@ static int restart_dh_challenge(struct cc_ctrl_data *cc_data)
|
||||
}
|
||||
|
||||
/* load certificates and device key */
|
||||
certificate_load_and_check(ctx, "/etc/pem/root.pem");
|
||||
ctx->cust_cert = certificate_load_and_check(ctx, "/etc/pem/customer.pem");
|
||||
ctx->device_cert = certificate_load_and_check(ctx, "/etc/pem/device.pem");
|
||||
certificate_load_and_check(ctx, ROOT_CERT);
|
||||
ctx->cust_cert = certificate_load_and_check(ctx, CUSTOMER_CERT);
|
||||
ctx->device_cert = certificate_load_and_check(ctx, DEVICE_CERT);
|
||||
|
||||
if (!ctx->cust_cert || !ctx->device_cert) {
|
||||
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))
|
||||
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) {
|
||||
fprintf(stderr, "cannot read private key\n");
|
||||
return -1;
|
||||
|
@@ -49,6 +49,7 @@ int eDVBCIResourceManagerSession::doAction()
|
||||
case stateStarted:
|
||||
{
|
||||
const unsigned char tag[3] = {0x9F, 0x80, 0x10}; // profile enquiry
|
||||
cCA::GetInstance()->CheckCerts();
|
||||
sendAPDU(tag);
|
||||
state = stateFirstProfileEnquiry;
|
||||
return 0;
|
||||
@@ -68,19 +69,38 @@ int eDVBCIResourceManagerSession::doAction()
|
||||
case stateProfileEnquiry:
|
||||
{
|
||||
const unsigned char tag[3] = {0x9F, 0x80, 0x11};
|
||||
if (cCA::GetInstance()->CheckCerts())
|
||||
{
|
||||
const unsigned char data[][4] =
|
||||
{
|
||||
{0x00, 0x01, 0x00, 0x41},
|
||||
{0x00, 0x02, 0x00, 0x41},
|
||||
{0x00, 0x02, 0x00, 0x43},
|
||||
{0x00, 0x03, 0x00, 0x41},
|
||||
{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},
|
||||
{0x00, 0x24, 0x00, 0x41},
|
||||
{0x00, 0x40, 0x00, 0x41}, // mmi
|
||||
{0x00, 0x24, 0x00, 0x41}, // date-time
|
||||
{0x00, 0x8c, 0x10, 0x01} // content control
|
||||
// {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;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -173,10 +173,13 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
|
||||
sessions[session_nb - 1] = new eDVBCIMMISession(slot);
|
||||
printf("MMI - create session\n");
|
||||
break;
|
||||
if (cCA::GetInstance()->CheckCerts())
|
||||
{
|
||||
case 0x008c1001:
|
||||
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
|
||||
printf("CC MANAGER\n");
|
||||
break;
|
||||
}
|
||||
case 0x00100041:
|
||||
// session=new eDVBCIAuthSession;
|
||||
printf("AuthSession\n");
|
||||
|
@@ -5,6 +5,10 @@
|
||||
|
||||
#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
|
||||
{
|
||||
static eDVBCISession* sessions[SLMS];
|
||||
|
Reference in New Issue
Block a user