SASC-NG
DVBSoftCAM

cNagra Class Reference

#include <nagra.h>

Inheritance diagram for cNagra:

List of all members.

Public Member Functions

 cNagra (void)
virtual ~cNagra ()

Protected Member Functions

virtual void CreatePQ (const unsigned char *pk, BIGNUM *p, BIGNUM *q)=0
void ExpandPQ (BIGNUM *p, BIGNUM *q, const unsigned char *data, BIGNUM *e, BIGNUM *m)
void CreateRSAPair (const unsigned char *key, const unsigned char *data, BIGNUM *e, BIGNUM *m)

Protected Attributes

cRSA rsa
cBN pubExp

Detailed Description

Definition at line 48 of file nagra.h.


Constructor & Destructor Documentation

cNagra::cNagra ( void  )

Definition at line 202 of file nagra.c.

References pubExp.

{
  BN_set_word(pubExp,3);
}
virtual cNagra::~cNagra ( ) [inline, virtual]

Definition at line 58 of file nagra.h.

{};

Member Function Documentation

virtual void cNagra::CreatePQ ( const unsigned char *  pk,
BIGNUM *  p,
BIGNUM *  q 
) [protected, pure virtual]

Implemented in cNagra1, and cNagra2.

Referenced by CreateRSAPair().

void cNagra::CreateRSAPair ( const unsigned char *  key,
const unsigned char *  data,
BIGNUM *  e,
BIGNUM *  m 
) [protected]

Definition at line 207 of file nagra.c.

References CreatePQ(), and ExpandPQ().

Referenced by cNagra2::DecryptEMM(), cTestNagra::Process(), cSystemNagra::ProcessECM(), and cSystemNagra::ProcessEMM().

{
  // Calculate P and Q from data
  cBN p,q;
  CreatePQ(key,p,q);
  ExpandPQ(p,q,data,e,m);
}
void cNagra::ExpandPQ ( BIGNUM *  p,
BIGNUM *  q,
const unsigned char *  data,
BIGNUM *  e,
BIGNUM *  m 
) [protected]

Definition at line 215 of file nagra.c.

Referenced by CreateRSAPair().

{
  // Calculate N=P*Q (modulus)
  cBNctx ctx;
  BN_mul(m,p,q,ctx);
  if(data) BN_bin2bn(data,64,e); // set provided data as E1
  else {                         // else calculate the 'official' one
    // E = ( ( ( (P-1) * (Q-1) * 2) + 1) / 3)
    BN_sub_word(p,1);
    BN_sub_word(q,1);
    BN_mul(e,p,q,ctx);
    BN_mul_word(e,2);
    BN_add_word(e,1);
    BN_div_word(e,3);
    }
}

Member Data Documentation


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