|
SASC
DVBSoftCAM
|
Inheritance diagram for cCamCryptNagra:Public Member Functions | |
| cCamCryptNagra (void) | |
| void | SetCardData (unsigned int id, const unsigned char *bk, BIGNUM *exp) |
| void | SetCamMod (BIGNUM *m) |
| bool | HasCamMod (void) |
| bool | DecryptDT08 (const unsigned char *dt08, unsigned int irdid, cBN *irdmod, bool fakeid) |
| bool | MakeSessionKey (unsigned char *out, const unsigned char *in) |
| void | DecryptCW (unsigned char *cw, const unsigned char *ecw1, const unsigned char *ecw2) |
| cCamCryptNagra (void) | |
| void | SetCardData (unsigned int id, const unsigned char *bk, BIGNUM *exp) |
| void | SetCamMod (BIGNUM *m) |
| bool | HasCamMod (void) |
| bool | DecryptDT08 (const unsigned char *dt08, unsigned int irdid, cBN *irdmod, bool fakeid) |
| bool | MakeSessionKey (unsigned char *out, const unsigned char *in) |
| void | DecryptCW (unsigned char *cw, const unsigned char *ecw1, const unsigned char *ecw2) |
Definition at line 104 of file sc-nagra.c.
| cCamCryptNagra::cCamCryptNagra | ( | void | ) |
Definition at line 126 of file sc-nagra.c.
{
hasMod=false;
}
| cCamCryptNagra::cCamCryptNagra | ( | void | ) |
| void cCamCryptNagra::DecryptCW | ( | unsigned char * | cw, |
| const unsigned char * | ecw1, | ||
| const unsigned char * | ecw2 | ||
| ) |
Definition at line 233 of file sc-nagra.c.
References cIDEA::Decrypt().
Referenced by cSmartCardNagra::Decode().
| void cCamCryptNagra::DecryptCW | ( | unsigned char * | cw, |
| const unsigned char * | ecw1, | ||
| const unsigned char * | ecw2 | ||
| ) |
| bool cCamCryptNagra::DecryptDT08 | ( | const unsigned char * | dt08, |
| unsigned int | irdid, | ||
| cBN * | irdmod, | ||
| bool | fakeid | ||
| ) |
| bool cCamCryptNagra::DecryptDT08 | ( | const unsigned char * | dt08, |
| unsigned int | irdid, | ||
| cBN * | irdmod, | ||
| bool | fakeid | ||
| ) |
Definition at line 169 of file sc-nagra.c.
References BYTE4_BE, cIDEA::Decrypt(), L_SC_PROC, LDUMP, LOG, PRINTF, cBN::Put(), cRSA::RSA(), and cIDEA::SetDecKey().
{
if(LOG(L_SC_PROC)) {
unsigned char bb[64];
irdmod->Put(bb,sizeof(bb));
LDUMP(L_SC_PROC,bb,sizeof(bb),"DT08 decrypt IRDID: %08x IRDMOD:",irdid);
}
unsigned char buff[72];
if(rsa.RSA(buff,dt08+1,64,camExp,*irdmod)!=64) return false;
memcpy(buff+64,dt08+1+64,8);
buff[63]|=dt08[0]&0x80;
LDUMP(L_SC_PROC,buff,72,"DT08 after RSA");
unsigned char key[16];
InitKey(key,boxkey,irdid);
LDUMP(L_SC_PROC,key,16,"DT08 IDEA key");
IdeaKS dks;
idea.SetDecKey(key,&dks);
idea.Decrypt(buff,72,&dks,0);
LDUMP(L_SC_PROC,buff,72,"DT08 after IDEA");
memcpy(signature,buff,8);
LDUMP(L_SC_PROC,signature,8,"signature");
BYTE4_BE(buff ,0);
BYTE4_BE(buff+4,fakeid?0xFFFFFFFF:cardid);
Signature(buff,key,buff,72);
LDUMP(L_SC_PROC,buff,8,"check sig");
if(memcmp(signature,buff,8)) {
PRINTF(L_SC_PROC,"DT08 signature failed");
return false;
}
BN_bin2bn(buff+8,64,camMod);
hasMod=true;
return true;
}
| bool cCamCryptNagra::HasCamMod | ( | void | ) | [inline] |
Definition at line 120 of file sc-nagra.c.
{ return hasMod; }
| bool cCamCryptNagra::HasCamMod | ( | void | ) | [inline] |
Definition at line 120 of file sc-nagra.c.
Referenced by cSmartCardNagra::Init().
{ return hasMod; }
| bool cCamCryptNagra::MakeSessionKey | ( | unsigned char * | out, |
| const unsigned char * | in | ||
| ) |
| bool cCamCryptNagra::MakeSessionKey | ( | unsigned char * | out, |
| const unsigned char * | in | ||
| ) |
Definition at line 205 of file sc-nagra.c.
References L_SC_PROC, LDUMP, LOG, cBN::Put(), cRSA::RSA(), and cIDEA::SetDecKey().
{
if(!hasMod) return false;
if(LOG(L_SC_PROC)) {
unsigned char bb[64];
camMod.Put(bb,sizeof(bb));
LDUMP(L_SC_PROC,bb,sizeof(bb),"Sessionkey negotiation CAMMOD:");
}
//decrypt $2A data here and prepare $2B reply
if(rsa.RSA(out,camdata,64,camExp,camMod)!=64) return false;
LDUMP(L_SC_PROC,out,64,"CMD 2A/26 after RSA:");
unsigned char key[16], sess[16];
InitKey(key,signature,cardid);
LDUMP(L_SC_PROC,key,16,"first IDEA key: ");
Signature(sess,key,out,32);
memcpy(key,sess,8);
memcpy(key+8,sess,8);
LDUMP(L_SC_PROC,key,16,"second IDEA key:");
Signature(sess+8,key,out,32);
LDUMP(L_SC_PROC,sess,16,"SESSION KEY: ");
idea.SetDecKey(sess,&sessKey);
if(rsa.RSA(out,out,64,camExp,camMod)!=64) return false;
LDUMP(L_SC_PROC,out,64,"CMD 2B/27 data:");
return true;
}
| void cCamCryptNagra::SetCamMod | ( | BIGNUM * | m | ) |
| void cCamCryptNagra::SetCamMod | ( | BIGNUM * | m | ) |
Definition at line 143 of file sc-nagra.c.
Referenced by cSmartCardNagra::Init().
{
BN_copy(camMod,m);
memcpy(signature,boxkey,sizeof(signature));
hasMod=true;
}
| void cCamCryptNagra::SetCardData | ( | unsigned int | id, |
| const unsigned char * | bk, | ||
| BIGNUM * | exp | ||
| ) |
Definition at line 131 of file sc-nagra.c.
References id, L_SC_PROC, LDUMP, LOG, and cBN::Put().
Referenced by cSmartCardNagra::Init().
| void cCamCryptNagra::SetCardData | ( | unsigned int | id, |
| const unsigned char * | bk, | ||
| BIGNUM * | exp | ||
| ) |