Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Dec 1999 20:47:07 -0800
From:      "Ptacek" <ptacek@dashmail.net>
To:        <freebsd-questions@FreeBSD.ORG>, <freebsd-hackers@FreeBSD.ORG>
Subject:   DES routines?
Message-ID:  <001501bf4aa5$45e29640$502124d8@Ptacek>

next in thread | raw e-mail | index | archive | help
I am looking for some routines to perform DES encryption in electronic code
book mode.
I have found the ecb_cyrpt function, however when I try and use it the
buffer is not encrypted.
Am I missing something, do these functions not work, and is there a better
way of doing this?
Below I have included a basic test program I am using to try and get the
encryption working.

  Thanks for any help,
     - Chris
----------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <rpc/des_crypt.h>

int main()
{
   char testbuf[16] = {0x00,0x01,0x02,0x03,0x04,
                                 0x05,0x06,0x07,0x08,0x09,
                                 0x0a,0x0b,0x0c,0x0d,0x0e,
                                 0x0f} ;
   char testkey[8] = {0x01,0x02,0x03,0x04,
                      0x05,0x06,0x07,0x08} ;
   int status ;
   int i ;

   des_setparity(testkey) ;

   status = ecb_crypt(testkey, testbuf, 16, DES_HW | DES_ENCRYPT) ;

   printf("status=%d\n", status) ;
   for(i=0; i<16; i++)
   {
      printf("%02x ", (unsigned char)testbuf[i]) ;
   }
   exit(0) ;
}




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001501bf4aa5$45e29640$502124d8>