- libdvbci: some manual code nicenings

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-11-07 00:57:01 +01:00
committed by Thilo Graf
parent c4d691348f
commit 077e6352af
7 changed files with 29 additions and 56 deletions

View File

@@ -135,7 +135,6 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
printf("Index: %d Parity: (%d) -> ", d.index, d.parity); printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
hexdump(d.data, 32); hexdump(d.data, 32);
} }
return 0; return 0;
} }
@@ -172,7 +171,6 @@ int descrambler_set_pid(int index, int enable, int pid)
return 0; return 0;
} }
bool descrambler_open(void) bool descrambler_open(void)
{ {
if (desc_fd > 0) if (desc_fd > 0)

View File

@@ -211,7 +211,6 @@ int dh_mod_exp(uint8_t *dest, int dest_len, uint8_t *base, int base_len, uint8_t
BN_mod_exp(bn_dest, bn_base, bn_exp, bn_mod, ctx); BN_mod_exp(bn_dest, bn_base, bn_exp, bn_mod, ctx);
BN_CTX_free(ctx); BN_CTX_free(ctx);
len = BN_num_bytes(bn_dest); len = BN_num_bytes(bn_dest);
if (len > dest_len) if (len > dest_len)
{ {

View File

@@ -130,10 +130,12 @@ bool eDVBCIApplicationManagerSession::readBlist()
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
rc = fgetc(fd); rc = fgetc(fd);
if (rc == ',' || rc == EOF) break; if (rc == ',' || rc == EOF)
break;
cSid[i] = (char)rc; cSid[i] = (char)rc;
} }
if (rc == EOF) goto fin; if (rc == EOF)
goto fin;
if (i == 4) if (i == 4)
{ {
Sid = (u16)strtol(cSid, NULL, 16); Sid = (u16)strtol(cSid, NULL, 16);

View File

@@ -18,10 +18,7 @@ class eDVBCICAManagerSession: public eDVBCISession
eDVBCICAManagerSession(eDVBCISlot *tslot); eDVBCICAManagerSession(eDVBCISlot *tslot);
~eDVBCICAManagerSession(); ~eDVBCICAManagerSession();
const std::vector<uint16_t> &getCAIDs() const const std::vector<uint16_t> &getCAIDs() const { return caids; }
{
return caids;
}
int sendCAPMT(unsigned char *pmt, int len); int sendCAPMT(unsigned char *pmt, int len);
}; };

View File

@@ -340,7 +340,6 @@ static X509 *certificate_import_and_check(struct cert_ctx *ctx, const uint8_t *d
return cert; return cert;
} }
/* CI+ credentials */ /* CI+ credentials */
#define MAX_ELEMENTS 33 #define MAX_ELEMENTS 33
@@ -394,7 +393,6 @@ struct cc_ctrl_data
RSA *rsa_device_key; RSA *rsa_device_key;
}; };
static struct element *element_get(struct cc_ctrl_data *cc_data, unsigned int id) static struct element *element_get(struct cc_ctrl_data *cc_data, unsigned int id)
{ {
/* array index */ /* array index */
@@ -964,20 +962,16 @@ static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
/* generate DHSK & AKH */ /* generate DHSK & AKH */
check_dh_challenge(cc_data); check_dh_challenge(cc_data);
break; break;
case 19: /* auth_nonce - triggers new dh keychallenge - invalidates DHSK & AKH */ case 19: /* auth_nonce - triggers new dh keychallenge - invalidates DHSK & AKH */
/* generate DHPH & Signature_A */ /* generate DHPH & Signature_A */
restart_dh_challenge(cc_data); restart_dh_challenge(cc_data);
break; break;
case 21: /* Ns_module - triggers SAC key calculation */ case 21: /* Ns_module - triggers SAC key calculation */
generate_ns_host(cc_data); generate_ns_host(cc_data);
generate_key_seed(cc_data); generate_key_seed(cc_data);
generate_SAK_SEK(cc_data->sak, cc_data->sek, cc_data->ks_host); generate_SAK_SEK(cc_data->sak, cc_data->sek, cc_data->ks_host);
break; break;
/* SAC data messages */ /* SAC data messages */
case 6: //CICAM_id case 6: //CICAM_id
case 12: //keyprecursor case 12: //keyprecursor
check_new_key(cc_data); check_new_key(cc_data);
@@ -989,7 +983,6 @@ static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
case 28: //key register case 28: //key register
check_new_key(cc_data); check_new_key(cc_data);
break; break;
default: default:
printf("%s -> %s unhandled ID (%d)\n", FILENAME, __FUNCTION__, id); printf("%s -> %s unhandled ID (%d)\n", FILENAME, __FUNCTION__, id);
break; break;
@@ -1406,7 +1399,6 @@ int eDVBCIContentControlManagerSession::receivedAPDU(const unsigned char *tag, c
int eDVBCIContentControlManagerSession::doAction() int eDVBCIContentControlManagerSession::doAction()
{ {
printf("%s > %s\n", FILENAME, __FUNCTION__); printf("%s > %s\n", FILENAME, __FUNCTION__);
switch (state) switch (state)
{ {

View File

@@ -33,15 +33,7 @@ class eDVBCISession
static void deleteSessions(const eDVBCISlot *slot); static void deleteSessions(const eDVBCISlot *slot);
void sendSPDU(unsigned char tag, const void *data, int len, const void *apdu = 0, int alen = 0); void sendSPDU(unsigned char tag, const void *data, int len, const void *apdu = 0, int alen = 0);
int poll() int poll() { if (action) { action = doAction(); return 1; } return 0; }
{
if (action)
{
action = doAction();
return 1;
}
return 0;
}
enum { stateInCreation, stateBusy, stateInDeletion, stateStarted, statePrivate}; enum { stateInCreation, stateBusy, stateInDeletion, stateStarted, statePrivate};
static int parseLengthField(const unsigned char *pkt, int &len); static int parseLengthField(const unsigned char *pkt, int &len);
@@ -49,14 +41,8 @@ class eDVBCISession
static void receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len); static void receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len);
int getState() int getState() { return state; }
{ int getStatus() { return status; }
return state;
}
int getStatus()
{
return status;
}
static int pollAll(); static int pollAll();
}; };
@@ -75,5 +61,4 @@ class eDVBCIHostControlSession: public eDVBCISession
~eDVBCIHostControlSession(); ~eDVBCIHostControlSession();
}; };
#endif #endif