Changeset 4687 for trunk/reader-dre.c


Ignore:
Timestamp:
Feb 7, 2011, 7:30:45 PM (9 years ago)
Author:
lattjo
Message:

Use oscam DES functions!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-dre.c

    r4686 r4687  
    1 #include <openssl/des.h>
    2 
    31#include "globals.h"
    42#include "reader-common.h"
     
    64#define OK_RESPONSE 0x61
    75#define CMD_BYTE 0x59
    8 
    9 void DES_Decrypt(DES_cblock *data, const_DES_cblock *key)
    10 {
    11   DES_cblock out;
    12   DES_key_schedule schedule;
    13 
    14   DES_set_key_unchecked(key, &schedule);
    15   DES_ecb_encrypt(data, &out, &schedule, 0);
    16 
    17   memcpy(data, &out, 8);
    18 }
    196
    207static uchar xor (const uchar * cmd, int cmdlen)
     
    281268void DREover(unsigned char *ECMdata, unsigned char *DW)
    282269{
    283   unsigned char i, data[8], key[8];
    284270  if(ECMdata[2] >= (43+4) && ECMdata[40] == 0x3A && ECMdata[41] == 0x4B)
    285271  {
     272    int i;
     273    byte data[8], key[8];
     274
    286275    for(i = 0; i < 8; i++) key[i] = DESkeys[(ECMdata[42] & 0x0F) * 8 + i];
    287276
    288277    for(i = 0; i < 8; i++) data[i] = DW[i];
    289     DES_Decrypt(&data, &key);                             // even DW post-process
     278    des_decrypt(data, 8, key);                          // even DW post-process
    290279    for(i = 0; i < 8; i++) DW[i] = data[i];
    291280
    292281    for(i = 0; i < 8; i++) data[i] = DW[8+i];
    293     DES_Decrypt(&data, &key);                             // odd DW post-process
     282    des_decrypt(data, 8, key);                          // odd DW post-process
    294283    for(i = 0; i < 8; i++) DW[8+i] = data[i];
    295284  };
Note: See TracChangeset for help on using the changeset viewer.