Main Page | Data Structures | File List | Data Fields | Globals

d3des.h

Go to the documentation of this file.
00001 /* d3des.h -
00002  *
00003  *  Headers and defines for d3des.c
00004  *  Graven Imagery, 1992.
00005  *
00006  * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
00007  *  (GEnie : OUTER; CIS : [71755,204])
00008  */
00009 
00010 #define D2_DES      /* include double-length support */
00011 #define D3_DES      /* include triple-length support */
00012 
00013 #ifdef D3_DES
00014 #ifndef D2_DES
00015 #define D2_DES      /* D2_DES is needed for D3_DES */
00016 #endif
00017 #endif
00018 
00019 #define EN0 0   /* MODE == encrypt */
00020 #define DE1 1   /* MODE == decrypt */
00021 
00022 /* A useful alias on 68000-ish machines, but NOT USED HERE. */
00023 
00024 typedef union {
00025     unsigned long blok[2];
00026     unsigned short word[4];
00027     unsigned char byte[8];
00028     } M68K;
00029 
00030 extern void d_deskey(unsigned char *, short);
00031 /*            hexkey[8]     MODE
00032  * Sets the internal key register according to the hexadecimal
00033  * key contained in the 8 bytes of hexkey, according to the DES,
00034  * for encryption or decryption according to MODE.
00035  */
00036 
00037 extern void usekey(unsigned long *);
00038 /*          cookedkey[32]
00039  * Loads the internal key register with the data in cookedkey.
00040  */
00041 
00042 extern void cpkey(unsigned long *);
00043 /*         cookedkey[32]
00044  * Copies the contents of the internal key register into the storage
00045  * located at &cookedkey[0].
00046  */
00047 
00048 extern void des(unsigned char *, unsigned char *);
00049 /*          from[8]       to[8]
00050  * Encrypts/Decrypts (according to the key currently loaded in the
00051  * internal key register) one block of eight bytes at address 'from'
00052  * into the block at address 'to'.  They can be the same.
00053  */
00054 
00055 #ifdef D2_DES
00056 
00057 #define desDkey(a,b)    des2key((a),(b))
00058 extern void des2key(unsigned char *, short);
00059 /*            hexkey[16]     MODE
00060  * Sets the internal key registerS according to the hexadecimal
00061  * keyS contained in the 16 bytes of hexkey, according to the DES,
00062  * for DOUBLE encryption or decryption according to MODE.
00063  * NOTE: this clobbers all three key registers!
00064  */
00065 
00066 extern void Ddes(unsigned char *, unsigned char *);
00067 /*          from[8]       to[8]
00068  * Encrypts/Decrypts (according to the keyS currently loaded in the
00069  * internal key registerS) one block of eight bytes at address 'from'
00070  * into the block at address 'to'.  They can be the same.
00071  */
00072 
00073 extern void D2des(unsigned char *, unsigned char *);
00074 /*          from[16]          to[16]
00075  * Encrypts/Decrypts (according to the keyS currently loaded in the
00076  * internal key registerS) one block of SIXTEEN bytes at address 'from'
00077  * into the block at address 'to'.  They can be the same.
00078  */
00079 
00080 extern void makekey(char *, unsigned char *);
00081 /*      *password,  single-length key[8]
00082  * With a double-length default key, this routine hashes a NULL-terminated
00083  * string into an eight-byte random-looking key, suitable for use with the
00084  * deskey() routine.
00085  */
00086 
00087 #define makeDkey(a,b)   make2key((a),(b))
00088 extern void make2key(char *, unsigned char *);
00089 /*      *password,  double-length key[16]
00090  * With a double-length default key, this routine hashes a NULL-terminated
00091  * string into a sixteen-byte random-looking key, suitable for use with the
00092  * des2key() routine.
00093  */
00094 
00095 #ifndef D3_DES  /* D2_DES only */
00096 
00097 #define useDkey(a)  use2key((a))
00098 #define cpDkey(a)   cp2key((a))
00099 
00100 extern void use2key(unsigned long *);
00101 /*          cookedkey[64]
00102  * Loads the internal key registerS with the data in cookedkey.
00103  * NOTE: this clobbers all three key registers!
00104  */
00105 
00106 extern void cp2key(unsigned long *);
00107 /*         cookedkey[64]
00108  * Copies the contents of the internal key registerS into the storage
00109  * located at &cookedkey[0].
00110  */
00111 
00112 #else   /* D3_DES too */
00113 
00114 #define useDkey(a)  use3key((a))
00115 #define cpDkey(a)   cp3key((a))
00116 
00117 extern void des3key(unsigned char *, short);
00118 /*            hexkey[24]     MODE
00119  * Sets the internal key registerS according to the hexadecimal
00120  * keyS contained in the 24 bytes of hexkey, according to the DES,
00121  * for DOUBLE encryption or decryption according to MODE.
00122  */
00123 
00124 extern void use3key(unsigned long *);
00125 /*          cookedkey[96]
00126  * Loads the 3 internal key registerS with the data in cookedkey.
00127  */
00128 
00129 extern void cp3key(unsigned long *);
00130 /*         cookedkey[96]
00131  * Copies the contents of the 3 internal key registerS into the storage
00132  * located at &cookedkey[0].
00133  */
00134 
00135 extern void make3key(char *, unsigned char *);
00136 /*      *password,  triple-length key[24]
00137  * With a triple-length default key, this routine hashes a NULL-terminated
00138  * string into a twenty-four-byte random-looking key, suitable for use with
00139  * the des3key() routine.
00140  */
00141 
00142 #endif  /* D3_DES */
00143 #endif  /* D2_DES */
00144 
00145 /* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery
00146  ********************************************************************/

Generated on Thu Jan 20 16:16:18 2005 for Axis smart-card FPGA authentication scheme by doxygen 1.3.6