int mecmAddr[2];
int mecmKeyId;
//
- virtual bool Algo(int algo, unsigned char *hd, const unsigned char *ed, unsigned char *hw);
+ virtual bool Algo(int algo, const unsigned char *hd, unsigned char *hw);
+ virtual void DynamicHD(unsigned char *hd, const unsigned char *ed);
virtual bool RomInit(void);
virtual void Stepper(void);
virtual void TimerHandler(unsigned int num);
desSize=16; hwMapper=0;
}
-bool cN2Prov0101::Algo(int algo, unsigned char *hd, const unsigned char *ed, unsigned char *hw)
+void cN2Prov0101::DynamicHD(unsigned char *hd, const unsigned char *ed)
+{
+ hd[5]=ed[5];
+ hd[6]=(ed[7]&0xEF) | ((ed[6]&0x40)>>2);
+ hd[7]=ed[8];
+ hd[8]=(ed[9]&0x7F) | ((ed[6]&0x20)<<2);
+ hd[9]=ed[6]&0x80;
+}
+
+bool cN2Prov0101::Algo(int algo, const unsigned char *hd, unsigned char *hw)
{
if(algo!=0x40 && algo!=0x60) {
PRINTF(L_SYS_ECM,"%04X: unknown MECM algo %02x",id,algo);
return false;
}
- // dynamic expand
- hd[5]=ed[5];
- hd[6]=(ed[7]&0xEF) | ((ed[6]&0x40)>>2);
- hd[7]=ed[8];
- hd[8]=(ed[9]&0x7F) | ((ed[6]&0x20)<<2);
- hd[9]=ed[6]&0x80;
memcpy(hw,hd,seedSize);
ExpandInput(hw);
bool RomCallbacks(void);
void AddRomCallbacks(void);
protected:
- virtual bool Algo(int algo, unsigned char *hd, const unsigned char *ed, unsigned char *hw);
+ virtual bool Algo(int algo, const unsigned char *hd, unsigned char *hw);
virtual bool NeedsCwSwap(void) { return true; }
virtual bool RomInit(void);
virtual void TimerHandler(unsigned int num);
hwMapper=0;
}
-bool cN2Prov0501::Algo(int algo, unsigned char *hd, const unsigned char *ed, unsigned char *hw)
+bool cN2Prov0501::Algo(int algo, const unsigned char *hd, unsigned char *hw)
{
if(algo==0x60) {
hw[0]=hd[0];
hd[2]=cw[15];
hd[3]=cw[6];
hd[4]=cw[7];
+ DynamicHD(hd,ed);
if(keyValid && !memcmp(seed,hd,seedSize)) { // key cached
memcpy(buf,cwkey,8);
}
else { // key not cached
memset(hw,0,sizeof(hw));
- if(!Algo(algo,hd,ed,hw)) return false;
+ if(!Algo(algo,hd,hw)) return false;
memcpy(&hw[128],hw,64);
RotateBytes(&hw[64],128);
SHA1(&hw[64],128,buf);
int id, flags, seedSize;
cIDEA idea;
//
- virtual bool Algo(int algo, unsigned char *hd, const unsigned char *ed, unsigned char *hw) { return false; }
+ virtual bool Algo(int algo, const unsigned char *hd, unsigned char *hw) { return false; }
+ virtual void DynamicHD(unsigned char *hd, const unsigned char *ed) {}
virtual bool NeedsCwSwap(void) { return false; }
void ExpandInput(unsigned char *hw);
public: