From 8f982b1de1ac9790f8c8e27835a7747c08d7291c Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 27 Dec 2007 22:00:19 +0100 Subject: [PATCH] release 0.8.1 --- HISTORY | 10 +++++ cam.c | 4 +- cam.h | 3 +- patches/vdr-1.4.x-sc7.diff | 8 ++-- sc.c | 7 +++- scsetup.h | 1 + systems/cardclient/camd.c | 75 +++++++++++++++++++++++-------------- systems/nagra/nagra2-7101.c | 47 +++++++++++++++++++++++ version.h | 4 +- 9 files changed, 120 insertions(+), 39 deletions(-) create mode 100644 systems/nagra/nagra2-7101.c diff --git a/HISTORY b/HISTORY index 2fcc38e..8e55d65 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,17 @@ VDR Plugin 'sc' Revision History -------------------------------- +06.07.2007: Version 0.8.1 +- Added Nagra2 7101 3DES support. +- Added a setup option to force tranfermode with digital audio. Another common + used patched for the vdr-core is made unnecessary by this option. +- Fixed camd33 EMM packet processing. +- Fixed recording device allocation (1.4.x). You have to update the VDR core + patch. Thanks to dingo35. +- Fixed compiling with VDR 1.5.0. + 22.06.2007: Version 0.8.0 +- Added Nagra2 0501 MECM support. - Added support for Nagra smartcards. Code is not well tested. Volunteers welcome. Timing is tricky, so you have to get cardreader clock AND -C parameter right. diff --git a/cam.c b/cam.c index 092071c..cb4321e 100644 --- a/cam.c +++ b/cam.c @@ -2419,7 +2419,7 @@ bool cDeCSA::Decrypt(unsigned char *data, int len, bool force) LBSTARTF(L_CORE_CSA); LBPUT("decrypting %3d packets (ccs=%3d cs=%3d %s)",ccs,ccs,cs,ccs>=cs?"OK ":"INC"); int n=decrypt_packets(keys[currIdx],range); - LBPUT(" -> %3d packets decrypted\n",n); + LBPUT(" -> %3d packets decrypted",n); if(n>0) return true; LBEND(); } @@ -2598,6 +2598,8 @@ void cScDvbDevice::Shutdown(void) void cScDvbDevice::Startup(void) { + if(ScSetup.ForceTransfer) + SetTransferModeForDolbyDigital(2); for(int n=cDevice::NumDevices(); --n>=0;) { cScDvbDevice *dev=dynamic_cast(cDevice::GetDevice(n)); if(dev) dev->LateInit(); diff --git a/cam.h b/cam.h index 8f80d44..752a64e 100644 --- a/cam.h +++ b/cam.h @@ -158,7 +158,8 @@ public: ~cScDvbDevice(); #if APIVERSNUM >= 10501 virtual bool HasCi(void); -#else +#endif +#if APIVERSNUM < 10500 virtual int ProvidesCa(const cChannel *Channel) const; #endif static void Capture(void); diff --git a/patches/vdr-1.4.x-sc7.diff b/patches/vdr-1.4.x-sc7.diff index b043a43..8ee66ef 100644 --- a/patches/vdr-1.4.x-sc7.diff +++ b/patches/vdr-1.4.x-sc7.diff @@ -24,7 +24,7 @@ diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/ci.c vdr-1.4.7-sc7/ci.c } diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/ci.h vdr-1.4.7-sc7/ci.h --- vdr-1.4.7-orig/ci.h 2006-08-12 11:43:31.000000000 +0200 -+++ vdr-1.4.7-sc7/ci.h 2007-05-13 18:41:42.000000000 +0200 ++++ vdr-1.4.7-sc7/ci.h 2007-06-24 19:46:39.000000000 +0200 @@ -85,10 +85,12 @@ class cCiCaProgramData : public cListObject { public: @@ -42,7 +42,7 @@ diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/ci.h vdr-1.4.7-sc7/ci.h class cCiTransportLayer; class cCiTransportConnection; -+#define VDR_IS_SC_PATCHED 401 ++#define VDR_IS_SC_PATCHED 402 + class cCiHandler { private: @@ -205,7 +205,7 @@ diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/device.h vdr-1.4.7-sc7/device.h diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/dvbdevice.c vdr-1.4.7-sc7/dvbdevice.c --- vdr-1.4.7-orig/dvbdevice.c 2007-02-24 12:10:14.000000000 +0100 -+++ vdr-1.4.7-sc7/dvbdevice.c 2007-05-13 18:04:04.000000000 +0200 ++++ vdr-1.4.7-sc7/dvbdevice.c 2007-06-24 19:42:24.000000000 +0200 @@ -419,7 +419,11 @@ dvb_frontend_info feinfo; if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0) { @@ -227,7 +227,7 @@ diff -urN -X ex.vdr-sc7 vdr-1.4.7-orig/dvbdevice.c vdr-1.4.7-sc7/dvbdevice.c - needsDetachReceivers = Ca() != Channel->Ca(); + if (Ca() >= CA_ENCRYPTED_MIN || Channel->Ca() >= CA_ENCRYPTED_MIN) { + if(Channel->Ca()Ca(); + } diff --git a/sc.c b/sc.c index 9444d89..382dcc2 100644 --- a/sc.c +++ b/sc.c @@ -69,7 +69,7 @@ #if !defined(VDR_IS_SC_PATCHED) #error You MUST patch the VDR core with the supplied patch. Next time read the README first. #endif -#if VDR_IS_SC_PATCHED<401 +#if VDR_IS_SC_PATCHED<402 #error Your VDR core is patched with an outdated patch version. Please upgrade to the supplied version. #endif #endif //APIVERSNUM >= 10500 @@ -951,6 +951,7 @@ cScSetup::cScSetup(void) ConcurrentFF = 0; memset(CaIgnore,0,sizeof(CaIgnore)); LocalPriority = 0; + ForceTransfer = 1; } void cScSetup::Check(void) @@ -967,6 +968,7 @@ void cScSetup::Check(void) PRINTF(L_CORE_LOAD,"** Key updates (AU) are %s",AutoUpdate?(AutoUpdate==1?"enabled (active CAIDs)":"enabled (all CAIDs)"):"DISABLED"); PRINTF(L_CORE_LOAD,"** Local systems %stake priority over cached remote",LocalPriority?"":"DON'T "); PRINTF(L_CORE_LOAD,"** Concurrent FF recordings are %sallowed",ConcurrentFF?"":"NOT "); + PRINTF(L_CORE_LOAD,"** %sorce transfermode with digital auido",ForceTransfer?"F":"DON'T f"); LBSTART(L_CORE_LOAD); LBPUT("** ScCaps are"); for(int i=0; iAdd(new cOptSel ("AutoUpdate" ,"Update keys (AU)" ,&ScSetup.AutoUpdate,3,logg)); ScOpts->Add(new cOptBool ("ConcurrentFF" ,"Concurrent FF streams",&ScSetup.ConcurrentFF)); + ScOpts->Add(new cOptBool ("ForceTranfer" ,"Force TransferMode" ,&ScSetup.ForceTransfer)); ScOpts->Add(new cOptBool ("LocalPriority","Prefer local systems" ,&ScSetup.LocalPriority)); ScOpts->Add(new cOptMInt ("ScCaps" ,"Active on DVB card" , ScSetup.ScCaps,MAXSCCAPS,0)); ScOpts->Add(new cOptMInt ("CaIgnore" ,"Ignore CAID" , ScSetup.CaIgnore,MAXCAIGN,2)); diff --git a/scsetup.h b/scsetup.h index 5790518..49b7ce5 100644 --- a/scsetup.h +++ b/scsetup.h @@ -32,6 +32,7 @@ public: int ConcurrentFF; int CaIgnore[MAXCAIGN]; int LocalPriority; + int ForceTransfer; public: cScSetup(void); void Check(void); diff --git a/systems/cardclient/camd.c b/systems/cardclient/camd.c index 56d6b4b..53df4eb 100644 --- a/systems/cardclient/camd.c +++ b/systems/cardclient/camd.c @@ -45,18 +45,16 @@ protected: cNetSocket so; bool emmProcessing; char username[11], password[11]; - int CAID; - unsigned char lastEmmReq[32]; // virtual bool Login(void); bool ParseKeyConfig(const char *config, int *num); bool ParseUserConfig(const char *config, int *num); virtual bool SendMsg(cNetSocket *so, const unsigned char *data, int len); virtual int RecvMsg(cNetSocket *so, unsigned char *data, int len, int to=-1); - void HandleEMMRequest(const unsigned char *buff, int len); + virtual void HandleEMMRequest(const unsigned char *buff, int len) {} + virtual bool CanHandleEMM(int SysId) { return false; } public: cCardClientCommon(const char *Name, bool ConReply, bool LogReply, bool DoAES, int MinMsgLen); - virtual bool CanHandle(unsigned short SysId); virtual bool Init(const char *config); virtual bool ProcessECM(const cEcmInfo *ecm, const unsigned char *source, unsigned char *cw); virtual bool ProcessEMM(int caSys, const unsigned char *source); @@ -68,8 +66,6 @@ cCardClientCommon::cCardClientCommon(const char *Name, bool ConReply, bool LogRe { conReply=ConReply; logReply=LogReply; doAES=DoAES; minMsgLen=MinMsgLen; emmProcessing=exclusive=false; - CAID=0; - memset(lastEmmReq,0,sizeof(lastEmmReq)); } bool cCardClientCommon::ParseUserConfig(const char *config, int *num) @@ -126,11 +122,6 @@ int cCardClientCommon::RecvMsg(cNetSocket *so, unsigned char *data, int len, int return n; } -bool cCardClientCommon::CanHandle(unsigned short SysId) -{ - return (emmProcessing && SysId==CAID) || cCardClient::CanHandle(SysId); -} - bool cCardClientCommon::Init(const char *config) { cMutexLock lock(this); @@ -178,25 +169,9 @@ bool cCardClientCommon::Login(void) return true; } -void cCardClientCommon::HandleEMMRequest(const unsigned char *buff, int len) -{ - if(len>=13 && buff[0]==0 && !CheckNull(buff,len) && memcmp(buff,lastEmmReq,13)) { - CAID=buff[1]*256+buff[2]; - ResetIdSet(); - SetCard(new cCardIrdeto(buff[6],&buff[3])); - AddProv(new cProviderIrdeto(0,&buff[7])); - AddProv(new cProviderIrdeto(2,&buff[10])); - memcpy(lastEmmReq,buff,13); - PRINTF(L_CC_LOGIN,"%s: CAID: %04x HexSerial: %02X%02X%02X, HexBase: %02X",name,CAID,buff[3],buff[4],buff[5],buff[6]); - PRINTF(L_CC_LOGIN,"%s: Provider00: %02X%02X%02X, Provider10: %02X%02X%02X",name,buff[7],buff[8],buff[9],buff[10],buff[11],buff[12]); - if(!emmAllowed) PRINTF(L_CC_EMM,"%s: EMM disabled from config",name); - emmProcessing=true; - } -} - bool cCardClientCommon::ProcessEMM(int caSys, const unsigned char *source) { - if(emmProcessing && emmAllowed) { + if(emmAllowed && CanHandleEMM(caSys)) { cMutexLock lock(this); if(MatchEMM(source)) { const int length=SCT_LEN(source); @@ -269,15 +244,57 @@ bool cCardClientCommon::ProcessECM(const cEcmInfo *ecm, const unsigned char *sou // -- cCardClientCamd33 -------------------------------------------------------- class cCardClientCamd33 : public cCardClientCommon { +private: + int CAID; + unsigned char lastEmmReq[32]; +protected: + virtual void HandleEMMRequest(const unsigned char *buff, int len); + virtual bool CanHandleEMM(int SysId); public: cCardClientCamd33(const char *Name); + virtual bool CanHandle(unsigned short SysId); }; static cCardClientLinkReg __camd33("Camd33"); cCardClientCamd33::cCardClientCamd33(const char *Name) :cCardClientCommon(Name,true,true,true,0) -{} +{ + CAID=0; + memset(lastEmmReq,0,sizeof(lastEmmReq)); +} + +bool cCardClientCamd33::CanHandle(unsigned short SysId) +{ + return CanHandleEMM(SysId) || cCardClient::CanHandle(SysId); +} + +bool cCardClientCamd33::CanHandleEMM(int SysId) +{ + return (emmProcessing && SysId==CAID); +} + +void cCardClientCamd33::HandleEMMRequest(const unsigned char *buff, int len) +{ + if(len>=13 && buff[0]==0 && !CheckNull(buff,len) && memcmp(buff,lastEmmReq,13)) { + emmProcessing=false; + CAID=buff[1]*256+buff[2]; + ResetIdSet(); + switch(CAID>>8) { + case 0x17: + case 0x06: + SetCard(new cCardIrdeto(buff[6],&buff[3])); + AddProv(new cProviderIrdeto(0,&buff[7])); + AddProv(new cProviderIrdeto(2,&buff[10])); + memcpy(lastEmmReq,buff,13); + PRINTF(L_CC_LOGIN,"%s: CAID: %04x HexSerial: %02X%02X%02X, HexBase: %02X",name,CAID,buff[3],buff[4],buff[5],buff[6]); + PRINTF(L_CC_LOGIN,"%s: Provider00: %02X%02X%02X, Provider10: %02X%02X%02X",name,buff[7],buff[8],buff[9],buff[10],buff[11],buff[12]); + if(!emmAllowed) PRINTF(L_CC_EMM,"%s: EMM disabled from config",name); + emmProcessing=true; + break; + } + } +} // -- cCardClientCardd --------------------------------------------------------- diff --git a/systems/nagra/nagra2-7101.c b/systems/nagra/nagra2-7101.c new file mode 100644 index 0000000..695150d --- /dev/null +++ b/systems/nagra/nagra2-7101.c @@ -0,0 +1,47 @@ +/* + * 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 + */ + +// -- cN2Prov7101 ---------------------------------------------------------------- + +class cN2Prov7101 : public cN2Prov { +public: + cN2Prov7101(int Id, int Flags):cN2Prov(Id,Flags) {} + virtual bool PostProcAU(int id, unsigned char *data); + }; + +static cN2ProvLinkReg staticPL7101; + +bool cN2Prov7101::PostProcAU(int id, unsigned char *data) +{ + if(data[1]==0x01) { + cPlainKey *pk; + if(!(pk=keys.FindKey('N',id,MBC(N2_MAGIC,0x30),16))) { + PRINTF(L_SYS_EMM,"missing %04x NN 30 3DES key (16 bytes)",id); + return false; + } + unsigned char dkey[16]; + pk->Get(dkey); + DES_key_schedule ks1, ks2; + DES_key_sched((DES_cblock *)&dkey[0],&ks1); + DES_key_sched((DES_cblock *)&dkey[8],&ks2); + DES_ecb2_encrypt(DES_CAST(&data[7]),DES_CAST(&data[7]),&ks1,&ks2,DES_DECRYPT); + DES_ecb2_encrypt(DES_CAST(&data[7+8]),DES_CAST(&data[7+8]),&ks1,&ks2,DES_DECRYPT); + } + return true; +} diff --git a/version.h b/version.h index 5c4ba1b..2c18ad9 100644 --- a/version.h +++ b/version.h @@ -21,8 +21,8 @@ #define ___VERSION_H // all release versions must end with 0xFF !! -#define SCVERSNUM 0x000800FF -#define SCVERSION "0.8.0" +#define SCVERSNUM 0x000801FF +#define SCVERSION "0.8.1" extern const char *ScVersion; -- 2.39.5