SASC-NG
DVBSoftCAM

cRC6 Class Reference

#include <crypto.h>

Inheritance diagram for cRC6:

List of all members.

Public Member Functions

void SetKey (const unsigned char *Key, int len)
void Decrypt (unsigned char *data)
void Decrypt (const unsigned char *in, unsigned char *out)

Detailed Description

Definition at line 143 of file crypto.h.


Member Function Documentation

void cRC6::Decrypt ( unsigned char *  data)

Definition at line 490 of file crypto.c.

Referenced by cCmd0cCrypt::Decrypt().

void cRC6::Decrypt ( const unsigned char *  in,
unsigned char *  out 
)

Definition at line 495 of file crypto.c.

References b, i, RC6_MAX, and RC6_ROUNDS.

{
  unsigned int *l=(unsigned int *)in;
  unsigned int a, b, c, d;
  a=l[0]-key[RC6_MAX-2];
  b=l[1];
  c=l[2]-key[RC6_MAX-1];
  d=l[3];
  for(int i=RC6_ROUNDS; i>0; i--) {
    unsigned int t=a;
    unsigned int u=b;
    a=d; d=c; b=t; c=u;
    u=rol((d*(2*d+1)),5);
    t=rol((b*(2*b+1)),5);
    c=ror(c-key[2*i+1],t)^u;
    a=ror(a-key[2*i  ],u)^t;
    }
  l=(unsigned int *)out;
  l[0]=a;
  l[1]=b-key[0];
  l[2]=c;
  l[3]=d-key[1];
}
void cRC6::SetKey ( const unsigned char *  Key,
int  len 
)

Definition at line 475 of file crypto.c.

References AUTOARRAY, b, i, j, RC6_MAX, RC6_P32, and RC6_Q32.

Referenced by cCmd0cCrypt::SetKey().

{
  key[0]=RC6_P32;
  for(int v=1; v<RC6_MAX; v++) key[v]=key[v-1]+RC6_Q32;
  len/=4;
  unsigned int a=0, b=0, *l=AUTOARRAY(unsigned int,len);
  memcpy(l,Key,len*4);
  for(int i=0,j=0,v=3*(len>RC6_MAX ? len : RC6_MAX) ; v>0; v--) {
    a=key[i]=rol(key[i]+a+b,3);
    b=  l[j]=rol(  l[j]+a+b,a+b);
    i++; i%=RC6_MAX;
    j++; j%=len;
    }
}

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