Hi,
I'm trying to implement a new stream cipher algorithm in OpenSSL
(stream cipher Rabbit, see RFC 4503 -- in my previous email, there was
a mistake, I tiped 4509, really sorry). This new algorithm will be
used for testing purpose. I've written and added new lines in OpenSSL
0.9.8c. So far this algorithm works for encryption/decryption only
(not yet for SSL) -- with the argument 'openssl -enc -rabbit -in ...
-out ...'.
At present, I'm working on the code for the cipher test ('rabbittest'
- I adopted the codes from rc4test.c). The code has already been
working on encryption test (test 0...3). Unfortunately, it shows
errors when it tests the cipher length test.

D:\Projects\Openssl-0.9.8c\out32dll>rabbittest
test 0 ok
test 1 ok
test 2 ok
test 3 ok
test end processing .
error in Rabbit length processing
output: 8e 65
expect: 8e 00
error in Rabbit length processing
output: 8e 65 b4
expect: 8e 65 00
error in Rabbit length processing
output: 8e 65 b4 ff
expect: 8e 65 b4 00
error in Rabbit length processing
output: 8e 65 b4 ff 14
expect: 8e 65 b4 ff 00
...
...

I've checked the code many times, but I couldn't find the bug. Below
is the 'rabbittest' codes :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../e_os.h"

#ifdef OPENSSL_NO_RABBIT
int main(int argc, char *argv[])
{
   printf("No Rabbit support\n");
   return(0);
}
#else
#include <openssl/rabbit.h>

static unsigned char keys[7][30]={
        
{16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
        
{16,0xAC,0xC3,0x51,0xDC,0xF1,0x62,0xFC,0x3B,0xFE,0x36,0x3D,0x2E,0x29,0x13,0x28,0x91},
        
{16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
        
{16,0xAC,0xC3,0x51,0xDC,0xF1,0x62,0xFC,0x3B,0xFE,0x36,0x3D,0x2E,0x29,0x13,0x28,0x91},
        };

static unsigned char data_len[7]={31,31,31,31};
static unsigned char data[7][32]={
        
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
        
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
        
{0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,
      
0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF},
        
{0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,
      
0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF,0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF},
        {0},
        };

static unsigned char output[7][32]={
        
{0x02,0xF7,0x4A,0x1C,0x26,0x45,0x6B,0xF5,0xEC,0xD6,0xA5,0x36,0xF0,0x54,0x57,0xB1,
      
0xA7,0x8A,0xC6,0x89,0x47,0x6C,0x69,0x7B,0x39,0x0C,0x9C,0xC5,0x15,0xD8,0xE8,0x88},
        
{0x9C,0x51,0xE2,0x87,0x84,0xC3,0x7F,0xE9,0xA1,0x27,0xF6,0x3E,0xC8,0xF3,0x2D,0x3D,
      
0x19,0xFC,0x54,0x85,0xAA,0x53,0xBF,0x96,0x88,0x5B,0x40,0xF4,0x61,0xCD,0x76,0xF5},
        
{0x10,0xC3,0x1C,0x64,0xB6,0xEE,0xA6,0x1A,0xFE,0xE2,0xF3,0x4E,0x60,0xFF,0x9A,0x5E,
      
0xB5,0xBE,0x90,0xF1,0xD7,0xC7,0xA4,0x94,0x2B,0x38,0xCA,0xBD,0x85,0x73,0x25,0x67},
        
{0x8E,0x65,0xB4,0xFF,0x14,0x68,0xB2,0x06,0xB3,0x13,0xA0,0x46,0x58,0x58,0xE0,0xD2,
      
0x0B,0xC8,0x02,0xFD,0x3A,0xF8,0x72,0x79,0x9A,0x6F,0x16,0x8C,0xF1,0x66,0xBB,0x1A},
        {0},
        };

int main(int argc, char *argv[])
        {
        int err=0;
        unsigned int i, j;
        unsigned char *p;
        RABBIT_KEY key;
        unsigned char obuf[512];

        for (i=0; i<4; i++)
                {
                rabbit_key_setup(&key,/*keys[i][0],*/ &(keys[i][1]));
                memset(obuf,0x00,sizeof(obuf));
                rabbit(&key,&(data[i][0]),obuf,data_len[i]);
                if (memcmp(obuf,output[i],data_len[i]+1) != 0)
                        {
                        printf("error calculating Rabbit\n");
                        printf("output:");
                        for (j=0; j<data_len[i]+1U; j++)
                                printf(" %02x",obuf[j]);
                        printf("\n");
                        printf("expect:");
                        p= &(output[i][0]);
                        for (j=0; j<data_len[i]+1U; j++)
                                printf(" %02x",*(p++));
                        printf("\n");
                        err++;
                        }
                else
                        printf("test %d ok\n",i);
                }
        printf("test end processing\n");
        for (i=0; i<data_len[3]; i++)
                {
                rabbit_key_setup(&key,/*keys[3][0],*/ &(keys[3][1]));
                memset(obuf,0x00,sizeof(obuf));
                rabbit(&key,&(data[3][0]),obuf,i);
                if ((memcmp(obuf,output[3],i) != 0) || (obuf[i] != 0))
                        {
                        printf("\nerror in Rabbit length processing\n");
                        printf("output:");
                        for (j=0; j<i+1; j++)
                                printf(" %02x",obuf[j]);
                        printf("\n");
                        printf("expect:");
                        p= &(output[3][0]);
                        for (j=0; j<i; j++)
                                printf(" %02x",*(p++));
                        printf(" 00\n");
                        err++;
                        }
                else
                        {
                        printf(".");
                        fflush(stdout);
                        }
                }
        printf("\ndone\n");

#ifdef OPENSSL_SYS_NETWARE
   if (err) printf("ERROR: %d\n", err);
#endif
        EXIT(err);
        return(0);
        }
#endif


I would thank so much if you can help me to know what's the problem
with the codes and how I can solve it.

Best regards,

--Endhy
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to