|
SASC
DVBSoftCAM
|
#include <crypto.h>
Inheritance diagram for cDes:Public Member Functions | |
| cDes (const unsigned char *pc1=0, const unsigned char *pc2=0) | |
| virtual | ~cDes () |
| void | Des (unsigned char *data, const unsigned char *key, int mode) const |
| cDes (const unsigned char *pc1=0, const unsigned char *pc2=0) | |
| virtual | ~cDes () |
| void | Des (unsigned char *data, const unsigned char *key, int mode) const |
Protected Member Functions | |
| virtual unsigned int | Mod (unsigned int R, unsigned int key7) const |
| void | Permute (unsigned char *data, const unsigned char *P, int n) const |
| virtual unsigned int | Mod (unsigned int R, unsigned int key7) const |
| void | Permute (unsigned char *data, const unsigned char *P, int n) const |
Protected Attributes | |
| static const unsigned char | LS [] = { 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1 } |
| const unsigned char * | PC1 |
| const unsigned char * | PC2 |
| unsigned char | E [48] |
| unsigned char | P [32] |
Static Protected Attributes | |
| static const unsigned char | S [][64] |
| cDes::cDes | ( | const unsigned char * | pc1 = 0, |
| const unsigned char * | pc2 = 0 |
||
| ) |
| cDes::cDes | ( | const unsigned char * | pc1 = 0, |
| const unsigned char * | pc2 = 0 |
||
| ) |
| void cDes::Des | ( | unsigned char * | data, |
| const unsigned char * | key, | ||
| int | mode | ||
| ) | const |
Definition at line 364 of file crypto.c.
References BYTE4_BE, DES_FP, DES_IP, DES_MOD, DES_PC1, DES_RIGHT, DESHASH, DESROUND, i, LS, Mod(), PC1, Permute(), rol28, ror28, and UINT32_BE.
Referenced by cNagraDES::Crypt(), cViaccess::Decode(), cNagraDES::Decrypt(), cViaccess::Hash(), cSeca2ProvNL::PostCW(), cSeca2ProvFR::PostCW(), cSeca2ProvSSE::PostSSE(), and cSeca2ProvFR::SignatureMod().
{
unsigned char mkey[8];
if(mode&DES_PC1) {
memcpy(mkey,key,sizeof(mkey));
Permute(mkey,PC1,56);
key=mkey;
}
if(mode&DES_IP) Permute(data,IP,64);
unsigned int C=UINT32_BE(key ) >> 4;
unsigned int D=UINT32_BE(key+3) & 0xfffffffL;
unsigned int L=UINT32_BE(data );
unsigned int R=UINT32_BE(data+4);
if(!(mode&DES_RIGHT)) {
for(int i=15; i>=0; i--) {
C=rol28(C,LS[15-i]); D=rol28(D,LS[15-i]);
unsigned int T=R;
if(mode&DES_MOD) T=Mod(T,key[7]); // apply costum mod e.g. Viaccess
DESROUND(C,D,T);
DESHASH(T);
T^=L; L=R; R=T;
}
}
else {
for(int i=15; i>=0; i--) {
unsigned int T=R;
if(mode&DES_MOD) T=Mod(T,key[7]); // apply costum mod e.g. Viaccess
DESROUND(C,D,T);
DESHASH(T);
T^=L; L=R; R=T;
C=ror28(C,LS[i]); D=ror28(D,LS[i]);
}
}
BYTE4_BE(data ,R);
BYTE4_BE(data+4,L);
if(mode&DES_FP) Permute(data,FP,64);
}
| void cDes::Des | ( | unsigned char * | data, |
| const unsigned char * | key, | ||
| int | mode | ||
| ) | const |
| virtual unsigned int cDes::Mod | ( | unsigned int | R, |
| unsigned int | key7 | ||
| ) | const [inline, protected, virtual] |
| virtual unsigned int cDes::Mod | ( | unsigned int | R, |
| unsigned int | key7 | ||
| ) | const [inline, protected, virtual] |
| void cDes::Permute | ( | unsigned char * | data, |
| const unsigned char * | P, | ||
| int | n | ||
| ) | const [protected] |
| void cDes::Permute | ( | unsigned char * | data, |
| const unsigned char * | P, | ||
| int | n | ||
| ) | const [protected] |
static const unsigned char cDes::LS = { 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1 } [protected] |
Definition at line 68 of file crypto.h.
Referenced by cCwDes::CwDes(), and Des().
const unsigned char * cDes::PC1 [protected] |
const unsigned char * cDes::PC2 [protected] |