SASC
DVBSoftCAM

cPlainKeyNagra Class Reference

#include <nagra.h>

Inheritance diagram for cPlainKeyNagra:

List of all members.

Public Member Functions

 cPlainKeyNagra (bool Super)
virtual bool Parse (const char *line)
 cPlainKeyNagra (bool Super)
virtual bool Parse (const char *line)

Static Public Member Functions

static bool IsBNKey (int kn)
static bool IsBNKey (int kn)

Protected Member Functions

virtual bool IsBNKey (void) const
virtual int IdSize (void)
virtual cString PrintKeyNr (void)
virtual bool IsBNKey (void) const
virtual int IdSize (void)
virtual cString PrintKeyNr (void)

Detailed Description

Definition at line 32 of file nagra.h.


Constructor & Destructor Documentation

cPlainKeyNagra::cPlainKeyNagra ( bool  Super)

Definition at line 52 of file nagra.c.

:cDualKey(Super,true)
{}
cPlainKeyNagra::cPlainKeyNagra ( bool  Super)

Member Function Documentation

virtual int cPlainKeyNagra::IdSize ( void  ) [inline, protected, virtual]

Reimplemented from cPlainKey.

Definition at line 38 of file nagra.h.

{ return 4; }
virtual int cPlainKeyNagra::IdSize ( void  ) [inline, protected, virtual]

Reimplemented from cPlainKey.

Definition at line 38 of file nagra.h.

{ return 4; }
bool cPlainKeyNagra::IsBNKey ( void  ) const [protected, virtual]

Implements cDualKey.

Definition at line 74 of file nagra.c.

References cPlainKey::keynr.

Referenced by Parse(), PrintKeyNr(), and cSystemNagra2::ProcessEMM().

{
  return IsBNKey(keynr);
}
bool cPlainKeyNagra::IsBNKey ( int  kn) [static]

Definition at line 56 of file nagra.c.

References C2MASK, MBC, N2_EMM_G_R, N2_EMM_S_R, N2_EMM_SEL, and N2_MAGIC.

{
  switch(kn & C2MASK) {
    // Nagra1
    case MBC('M','1'):
    case MBC('E','1'):
    case MBC('N','1'):
    case MBC('N','2'):
    // Nagra2
    case MBC(N2_MAGIC,N2_EMM_G_R):
    case MBC(N2_MAGIC,N2_EMM_S_R):
    case MBC(N2_MAGIC,N2_EMM_G_R|N2_EMM_SEL):
    case MBC(N2_MAGIC,N2_EMM_S_R|N2_EMM_SEL):
      return true;
    }
  return false;
}
virtual bool cPlainKeyNagra::IsBNKey ( void  ) const [protected, virtual]

Implements cDualKey.

static bool cPlainKeyNagra::IsBNKey ( int  kn) [static]
virtual bool cPlainKeyNagra::Parse ( const char *  line) [virtual]

Implements cPlainKey.

bool cPlainKeyNagra::Parse ( const char *  line) [virtual]

Implements cPlainKey.

Definition at line 104 of file nagra.c.

References ADDC3, Bin2Int, CheckNull(), GetChar(), GetHex(), IsBNKey(), cPlainKey::keynr, KEYSET, L_CORE_LOAD, L_GEN_WARN, MBC, N2_EMM_SEL, N2_MAGIC, PLAINLEN_NAGRA_B, PLAINLEN_NAGRA_BE, PLAINLEN_NAGRA_H, PLAINLEN_NAGRA_I, PLAINLEN_NAGRA_IE, PRINTF, cMutableKey::SetBinKey(), skipspace(), and cPlainKey::type.

{
  unsigned char sid[2];
  int len;
  if(GetChar(line,&type,1) && (len=GetHex(line,sid,2,false))) {
    type=toupper(type); id=Bin2Int(sid,len); 
    line=skipspace(line);
    bool ok;
    if(!strncasecmp(line,"NN",2)) {
      line=skipspace(line+2);
      unsigned char skeynr;
      if((ok=GetHex(line,&skeynr,1)))
        keynr=MBC(N2_MAGIC,skeynr);
      }
    else {
      bool tags;
      switch(toupper(*line)) {
        case 'E':
        case 'N': ok=GetChar(line,&keynr,2); tags=true; break;
        case 'M': ok=GetChar(line,&keynr,2); tags=false; break;
        case 'V': ok=GetChar(line,&keynr,1); tags=true; break;
        default:  {
                  unsigned char skeynr;
                  ok=GetHex(line,&skeynr,1); keynr=skeynr; tags=false; break;
                  }
        }
      if(ok) {
        int romnr, pk, keytype;
        GetTagDef(keynr,romnr,pk,keytype);
        line=skipspace(line);
        while(tags) {
          int r;
          if((r=ParseTag("ROM",line))>=0) {
            if(r>0 && r<=15) romnr=r;
            else PRINTF(L_CORE_LOAD,"nagrakey: ignoring bad ROM number %d",r);
            }
          else if((r=ParseTag("TYP",line))>=0) {
            if(r>=0 && r<=1) keytype=r;
            else PRINTF(L_CORE_LOAD,"nagrakey: ignoring bad key type %d",r);
            }
          else if((r=ParseTag("PK",line))>=0) {
            if(r>=0 && r<=2) pk=r;
            else PRINTF(L_CORE_LOAD,"nagrakey: ignoring bad PK key number %d",pk);
            }
          else {
            tags=false;
            if(pk!=0 && (keynr=='V' || keynr==MBC('N','2'))) {
              pk=0;
              PRINTF(L_CORE_LOAD,"nagrakey: auto-adjusting to PK0 for N2/V key");
              }
            if(romnr!=0 && keytype!=1) {
              keytype=1;
              PRINTF(L_CORE_LOAD,"nagrakey: auto-adjusting to TYP1 for ROM key");
              }
            }
          }
        if(IsBNKey() || keynr=='V') keynr=ADDC3(keynr,KEYSET(romnr,pk,keytype));
        }
      }

    unsigned char skey[PLAINLEN_NAGRA_BE];
    int keylen=PLAINLEN_NAGRA_BE;
    len=GetHex(line,skey,keylen,false);
    if(   (!IsBNKey() && (len==PLAINLEN_NAGRA_H || len==PLAINLEN_NAGRA_I || len==PLAINLEN_NAGRA_IE))
       || ( IsBNKey() && (len==PLAINLEN_NAGRA_B || len==PLAINLEN_NAGRA_BE)))
      keylen=len;
    if(len==keylen) {
      if((keynr=='V' || keynr==MBC(N2_MAGIC,0x03) || keynr==MBC(N2_MAGIC,(0x03|N2_EMM_SEL))) && CheckNull(skey,len))
        PRINTF(L_GEN_WARN,"nagrakey: FAKE verify keys will cause problems. Please remove them!");
      SetBinKey(skey,len);
      return true;
      }
    }
  return false;
}
cString cPlainKeyNagra::PrintKeyNr ( void  ) [protected, virtual]

Reimplemented from cPlainKey.

Definition at line 180 of file nagra.c.

References C2, C2MASK, IsBNKey(), k, cPlainKey::keynr, N2_MAGIC, PK, ROM, cString::sprintf(), and TYPE.

{
  if(C2(keynr)==N2_MAGIC)
    return cString::sprintf("NN %.2X",keynr&0xFF);
  int k=keynr & C2MASK;
  if(!IsBNKey() && k!='V')
    return cString::sprintf("%.2X",keynr);
  char nr[32];
  int q=0;
  if(IsBNKey()) nr[q++]=(keynr>>8) & 0xff;
  nr[q++]=keynr & 0xff;
  nr[q]=0;
  int romnr, pk, keytype;
  GetTagDef(keynr,romnr,pk,keytype);
  if(ROM(keynr) !=romnr  ) q+=snprintf(nr+q,sizeof(nr)-q," ROM%d",ROM(keynr));
  if(PK(keynr)  !=pk     ) q+=snprintf(nr+q,sizeof(nr)-q," PK%d",PK(keynr));
  if(TYPE(keynr)!=keytype) q+=snprintf(nr+q,sizeof(nr)-q," TYP%d",TYPE(keynr));
  return nr;
}
virtual cString cPlainKeyNagra::PrintKeyNr ( void  ) [protected, virtual]

Reimplemented from cPlainKey.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines