mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
libdvbci: some manual code nicenings
Origin commit data
------------------
Branch: master
Commit: f67dc18443
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-11-07 (Sun, 07 Nov 2021)
Origin message was:
------------------
- libdvbci: some manual code nicenings
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -135,7 +135,6 @@ int descrambler_set_key(int index, int parity, unsigned char *data)
|
||||
|
||||
printf("Index: %d Parity: (%d) -> ", d.index, d.parity);
|
||||
hexdump(d.data, 32);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -172,7 +171,6 @@ int descrambler_set_pid(int index, int enable, int pid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool descrambler_open(void)
|
||||
{
|
||||
if (desc_fd > 0)
|
||||
|
@@ -52,8 +52,8 @@ static int pkcs_1_mgf1(const uint8_t *seed, unsigned long seedlen, uint8_t *mask
|
||||
}
|
||||
|
||||
static int pkcs_1_pss_encode(const uint8_t *msghash, unsigned int msghashlen,
|
||||
unsigned long saltlen, unsigned long modulus_bitlen,
|
||||
uint8_t *out, unsigned int outlen)
|
||||
unsigned long saltlen, unsigned long modulus_bitlen,
|
||||
uint8_t *out, unsigned int outlen)
|
||||
{
|
||||
unsigned char *DB, *mask, *salt, *hash;
|
||||
unsigned long x, y, hLen, modulus_len;
|
||||
@@ -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_CTX_free(ctx);
|
||||
|
||||
|
||||
len = BN_num_bytes(bn_dest);
|
||||
if (len > dest_len)
|
||||
{
|
||||
|
@@ -130,10 +130,12 @@ bool eDVBCIApplicationManagerSession::readBlist()
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
rc = fgetc(fd);
|
||||
if (rc == ',' || rc == EOF) break;
|
||||
if (rc == ',' || rc == EOF)
|
||||
break;
|
||||
cSid[i] = (char)rc;
|
||||
}
|
||||
if (rc == EOF) goto fin;
|
||||
if (rc == EOF)
|
||||
goto fin;
|
||||
if (i == 4)
|
||||
{
|
||||
Sid = (u16)strtol(cSid, NULL, 16);
|
||||
|
@@ -18,10 +18,7 @@ class eDVBCICAManagerSession: public eDVBCISession
|
||||
eDVBCICAManagerSession(eDVBCISlot *tslot);
|
||||
~eDVBCICAManagerSession();
|
||||
|
||||
const std::vector<uint16_t> &getCAIDs() const
|
||||
{
|
||||
return caids;
|
||||
}
|
||||
const std::vector<uint16_t> &getCAIDs() const { return caids; }
|
||||
int sendCAPMT(unsigned char *pmt, int len);
|
||||
};
|
||||
|
||||
|
@@ -340,7 +340,6 @@ static X509 *certificate_import_and_check(struct cert_ctx *ctx, const uint8_t *d
|
||||
return cert;
|
||||
}
|
||||
|
||||
|
||||
/* CI+ credentials */
|
||||
|
||||
#define MAX_ELEMENTS 33
|
||||
@@ -394,7 +393,6 @@ struct cc_ctrl_data
|
||||
RSA *rsa_device_key;
|
||||
};
|
||||
|
||||
|
||||
static struct element *element_get(struct cc_ctrl_data *cc_data, unsigned int id)
|
||||
{
|
||||
/* array index */
|
||||
@@ -964,20 +962,16 @@ static int data_get_handle_new(struct cc_ctrl_data *cc_data, unsigned int id)
|
||||
/* generate DHSK & AKH */
|
||||
check_dh_challenge(cc_data);
|
||||
break;
|
||||
|
||||
case 19: /* auth_nonce - triggers new dh keychallenge - invalidates DHSK & AKH */
|
||||
/* generate DHPH & Signature_A */
|
||||
restart_dh_challenge(cc_data);
|
||||
break;
|
||||
|
||||
case 21: /* Ns_module - triggers SAC key calculation */
|
||||
generate_ns_host(cc_data);
|
||||
generate_key_seed(cc_data);
|
||||
generate_SAK_SEK(cc_data->sak, cc_data->sek, cc_data->ks_host);
|
||||
break;
|
||||
|
||||
/* SAC data messages */
|
||||
|
||||
case 6: //CICAM_id
|
||||
case 12: //keyprecursor
|
||||
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
|
||||
check_new_key(cc_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s -> %s unhandled ID (%d)\n", FILENAME, __FUNCTION__, id);
|
||||
break;
|
||||
@@ -1218,7 +1211,7 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_data_req(eDVBCISlot *tslot,
|
||||
|
||||
void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_sync_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int
|
||||
#if y_debug
|
||||
len
|
||||
len
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -1406,7 +1399,6 @@ int eDVBCIContentControlManagerSession::receivedAPDU(const unsigned char *tag, c
|
||||
|
||||
int eDVBCIContentControlManagerSession::doAction()
|
||||
{
|
||||
|
||||
printf("%s > %s\n", FILENAME, __FUNCTION__);
|
||||
switch (state)
|
||||
{
|
||||
|
@@ -76,16 +76,16 @@ int eDVBCIResourceManagerSession::doAction()
|
||||
{
|
||||
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 (dummy)
|
||||
{0x00, 0x40, 0x00, 0x41}, // mmi
|
||||
{0x00, 0x24, 0x00, 0x41}, // date-time
|
||||
{0x00, 0x8c, 0x10, 0x01}, // content control
|
||||
{0x00, 0x8e, 0x10, 0x01} // cam upgrade (dummy)
|
||||
// {0x00, 0x10, 0x00, 0x41} // auth.
|
||||
{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 (dummy)
|
||||
{0x00, 0x40, 0x00, 0x41}, // mmi
|
||||
{0x00, 0x24, 0x00, 0x41}, // date-time
|
||||
{0x00, 0x8c, 0x10, 0x01}, // content control
|
||||
{0x00, 0x8e, 0x10, 0x01} // cam upgrade (dummy)
|
||||
// {0x00, 0x10, 0x00, 0x41} // auth.
|
||||
};
|
||||
sendAPDU(tag, data, sizeof(data));
|
||||
}
|
||||
@@ -93,14 +93,14 @@ int eDVBCIResourceManagerSession::doAction()
|
||||
{
|
||||
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.
|
||||
{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));
|
||||
}
|
||||
|
@@ -33,15 +33,7 @@ class eDVBCISession
|
||||
static void deleteSessions(const eDVBCISlot *slot);
|
||||
void sendSPDU(unsigned char tag, const void *data, int len, const void *apdu = 0, int alen = 0);
|
||||
|
||||
int poll()
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
action = doAction();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int poll() { if (action) { action = doAction(); return 1; } return 0; }
|
||||
enum { stateInCreation, stateBusy, stateInDeletion, stateStarted, statePrivate};
|
||||
|
||||
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);
|
||||
|
||||
int getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
int getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
int getState() { return state; }
|
||||
int getStatus() { return status; }
|
||||
|
||||
static int pollAll();
|
||||
};
|
||||
@@ -75,5 +61,4 @@ class eDVBCIHostControlSession: public eDVBCISession
|
||||
~eDVBCIHostControlSession();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user