⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nagra2-0501.cpp,old

📁 DVB-S的softcam源代码
💻 CPP,OLD
字号:
/* * Softcam plugin to VDR (C++) * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */// -- cN2Prov0501 ----------------------------------------------------------------extern bool g_north_america;#include "map57.h"class cN2Prov0501 : public cN2Prov {protected:  virtual bool NeedsCwSwap(void) { return true; }public:  cN2Prov0501(int Id, int Flags):cN2Prov(Id,Flags) {}   virtual bool Algo(int algo, const unsigned char *hd, unsigned char *hw);  };static cN2ProvLinkReg<cN2Prov0501,0x0501,N2FLAG_MECM|N2FLAG_INV> staticPL0501;bool cN2Prov0501::Algo(int algo, const unsigned char *hd, unsigned char *hw)
{
  if(algo==0x40) {
    memcpy(hw,hd,3);
    ExpandInput(hw);
    hw[0x18]|=1; hw[0x40]|=1;
    map.DoMap(0x3b,hw,80);
    RotateBytes(hw,64);
    RotateBytes(&hw[64],64);
    SHA_CTX ctx;
    SHA1_Init(&ctx);
    SHA1_Update(&ctx,hw,128);
    memset(hw,0,128);
    hw[0]=ctx.h3&0xFF;
    hw[1]=(ctx.h3>>8)&0xFF;
    return true;
    }
  else if(algo==0x60) { // map 4D/4E/57
	// Premiere and NA providers treat this differently (of course)
    if(g_north_america)
	{
		memcpy(hw,hd,5);
	}
	else
	{
		memset(hw,0,128);
		hw[0] = hd[0];
		hw[1] = hd[1];
		hw[2] = hd[2]&0xf8;
	}

    ExpandInput(hw);
    cBN bh;
    RotateBytes(hw,128);
    BN_bin2bn(hw,128,bh);
    /* MAP 4D */
    unsigned char residues[53];
    BN_set_bit(bh,0x3FF);
    BN_set_bit(bh,0);
    for(int i=0; i<53; i++) residues[i]=BN_mod_word(bh,primes[i]);
    /* MAP 4E */
    MakePrime(bh,residues);
    /* Do some byte jumbling */
    BN_bn2bin(bh,hw);
    RotateBytes(hw,128);
    BN_bin2bn(hw,128,bh);
    /* MAP 4E */
    MakePrime(bh,residues);
    BN_bn2bin(bh,hw);
    RotateBytes(hw,128);
    /* MAP 57 */
    map.DoMap(0x57,hw,128);
    //if(!aux.Map(0x57,hw,128,128)) return false;
    return true;
    }

  d(printf("N2Prov%04X: unknown MECM algo %02x\n",id,algo))
  return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -