SASC-NG
DVBSoftCAM

crypto.c File Reference

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "crypto.h"
#include "helper.h"
#include "log.h"
#include "support/i_cbc.c"
#include "support/i_ecb.c"
#include "support/i_skey.c"
#include "support/aes_core.c"

Go to the source code of this file.

Defines

#define shiftin(V, R, n)   ((V<<1)+(((R)>>(n))&1))
#define rol28(V, n)   ((V<<(n) ^ V>>(28-(n)))&0xfffffffL)
#define ror28(V, n)   ((V>>(n) ^ V<<(28-(n)))&0xfffffffL)
#define hash(T)   ((T&0x0000ffffL) | ((T>>8)&0x00ff0000L) | ((T<<8)&0xff000000L))
#define DESROUND(C, D, T)
#define DESHASH(T)   { if(mode&DES_HASH) T=hash(T); }
#define RC6_WORDSIZE   32
#define RC6_P32   0xB7E15163L
#define RC6_Q32   0x9E3779B9L

Functions

void RotateBytes (unsigned char *out, const unsigned char *in, int n)
void RotateBytes (unsigned char *in, int n)

Define Documentation

#define DESHASH (   T)    { if(mode&DES_HASH) T=hash(T); }

Definition at line 340 of file crypto.c.

Referenced by cDes::Des().

#define DESROUND (   C,
  D,
  T 
)
Value:
{ \
   unsigned int s=0; \
   for(int j=7, k=0; j>=0; j--) { \
     unsigned int v=0, K=0; \
     for(int t=5; t>=0; t--, k++) { \
       v=shiftin(v,T,E[k]); \
       if(PC2[k]<29) K=shiftin(K,C,28-PC2[k]); \
       else          K=shiftin(K,D,56-PC2[k]); \
       } \
     s=(s<<4) + S[7-j][v^K]; \
     } \
   T=0; \
   for(int j=31; j>=0; j--) T=shiftin(T,s,P[j]); \
   }

Definition at line 325 of file crypto.c.

Referenced by cDes::Des().

#define hash (   T)    ((T&0x0000ffffL) | ((T>>8)&0x00ff0000L) | ((T<<8)&0xff000000L))
#define RC6_P32   0xB7E15163L

Definition at line 460 of file crypto.c.

Referenced by cRC6::SetKey().

#define RC6_Q32   0x9E3779B9L

Definition at line 461 of file crypto.c.

Referenced by cRC6::SetKey().

#define RC6_WORDSIZE   32

Definition at line 459 of file crypto.c.

#define rol28 (   V,
  n 
)    ((V<<(n) ^ V>>(28-(n)))&0xfffffffL)

Definition at line 307 of file crypto.c.

Referenced by cDes::Des().

#define ror28 (   V,
  n 
)    ((V>>(n) ^ V<<(28-(n)))&0xfffffffL)

Definition at line 308 of file crypto.c.

Referenced by cDes::Des().

#define shiftin (   V,
  R,
  n 
)    ((V<<1)+(((R)>>(n))&1))

Definition at line 306 of file crypto.c.

Referenced by cDes::Permute().


Function Documentation

void RotateBytes ( unsigned char *  out,
const unsigned char *  in,
int  n 
)

Definition at line 30 of file crypto.c.

{
  if(n>0) {
    out+=n;
    do { *(--out)=*(in++); } while(--n);
    }
}
void RotateBytes ( unsigned char *  in,
int  n 
)

Definition at line 38 of file crypto.c.

Referenced by cN2Prov0101::Algo(), cNagra1::CreatePQ(), cNagraDES::Crypt(), cNagraDES::Decrypt(), cNagra2::DecryptECM(), cNagra2::DecryptEMM(), cNagra1::DecryptEMM(), cCryptoworks::DecryptRSA(), cBN::GetLE(), cN2Prov::MECM(), cSystemNagra::ProcessECM(), and cBN::PutLE().

{
  if(n>1) {
    unsigned char *e=in+n-1;
    do {
      unsigned char temp=*in;
      *in++=*e;
      *e-- =temp;
      } while(in<e);
    }
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines