diff options
| author | markus <> | 2002-09-05 12:51:52 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:52 +0000 |
| commit | 5514995a9d5ed91db089875adb509c7781357c0e (patch) | |
| tree | 2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/des | |
| parent | fd9566423b542798f5c8b06e68101a9ea5bb9885 (diff) | |
| download | openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2 openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/des')
| -rw-r--r-- | src/lib/libcrypto/des/VERSION | 1 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/asm/des686.pl | 22 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/asm/readme | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/cbc3_enc.c | 54 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/des-lib.com | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/des.c | 220 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/des3s.cpp | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/des_opts.c | 264 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/des_ver.h | 11 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/dess.cpp | 20 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/destest.c | 410 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/read2pwd.c | 77 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/read_pwd.c | 218 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/rpc_enc.c | 25 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/rpw.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/des/speed.c | 117 |
16 files changed, 777 insertions, 682 deletions
diff --git a/src/lib/libcrypto/des/VERSION b/src/lib/libcrypto/des/VERSION index f62d8bdac0..c7d01542bc 100644 --- a/src/lib/libcrypto/des/VERSION +++ b/src/lib/libcrypto/des/VERSION | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | Fixed the weak key values which were wrong :-( | ||
| 1 | Defining SIGACTION causes sigaction() to be used instead of signal(). | 2 | Defining SIGACTION causes sigaction() to be used instead of signal(). |
| 2 | SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it | 3 | SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it |
| 3 | can cause problems. This should hopefully not affect normal | 4 | can cause problems. This should hopefully not affect normal |
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl index cf1a82fb5c..d3ad5d5edd 100644 --- a/src/lib/libcrypto/des/asm/des686.pl +++ b/src/lib/libcrypto/des/asm/des686.pl | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/local/bin/perl |
| 2 | 2 | ||
| 3 | $prog="des686.pl"; | 3 | $prog="des686.pl"; |
| 4 | 4 | ||
| @@ -46,19 +46,19 @@ EOF | |||
| 46 | $L="edi"; | 46 | $L="edi"; |
| 47 | $R="esi"; | 47 | $R="esi"; |
| 48 | 48 | ||
| 49 | &des_encrypt("des_encrypt",1); | 49 | &DES_encrypt("DES_encrypt1",1); |
| 50 | &des_encrypt("des_encrypt2",0); | 50 | &DES_encrypt("DES_encrypt2",0); |
| 51 | 51 | ||
| 52 | &des_encrypt3("des_encrypt3",1); | 52 | &DES_encrypt3("DES_encrypt3",1); |
| 53 | &des_encrypt3("des_decrypt3",0); | 53 | &DES_encrypt3("DES_decrypt3",0); |
| 54 | 54 | ||
| 55 | &file_end(); | 55 | &file_end(); |
| 56 | 56 | ||
| 57 | sub des_encrypt | 57 | sub DES_encrypt |
| 58 | { | 58 | { |
| 59 | local($name,$do_ip)=@_; | 59 | local($name,$do_ip)=@_; |
| 60 | 60 | ||
| 61 | &function_begin($name,"EXTRN _des_SPtrans:DWORD"); | 61 | &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); |
| 62 | 62 | ||
| 63 | &comment(""); | 63 | &comment(""); |
| 64 | &comment("Load the 2 words"); | 64 | &comment("Load the 2 words"); |
| @@ -94,11 +94,11 @@ sub des_encrypt | |||
| 94 | { | 94 | { |
| 95 | &comment(""); | 95 | &comment(""); |
| 96 | &comment("Round $i"); | 96 | &comment("Round $i"); |
| 97 | &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); | 97 | &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); |
| 98 | 98 | ||
| 99 | &comment(""); | 99 | &comment(""); |
| 100 | &comment("Round ".sprintf("%d",$i+1)); | 100 | &comment("Round ".sprintf("%d",$i+1)); |
| 101 | &D_ENCRYPT($R,$L,($i+1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); | 101 | &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); |
| 102 | } | 102 | } |
| 103 | &jmp(&label("end")); | 103 | &jmp(&label("end")); |
| 104 | 104 | ||
| @@ -108,10 +108,10 @@ sub des_encrypt | |||
| 108 | { | 108 | { |
| 109 | &comment(""); | 109 | &comment(""); |
| 110 | &comment("Round $i"); | 110 | &comment("Round $i"); |
| 111 | &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); | 111 | &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); |
| 112 | &comment(""); | 112 | &comment(""); |
| 113 | &comment("Round ".sprintf("%d",$i-1)); | 113 | &comment("Round ".sprintf("%d",$i-1)); |
| 114 | &D_ENCRYPT($R,$L,($i-1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); | 114 | &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | &set_label("end"); | 117 | &set_label("end"); |
diff --git a/src/lib/libcrypto/des/asm/readme b/src/lib/libcrypto/des/asm/readme index f8529d9307..1beafe253b 100644 --- a/src/lib/libcrypto/des/asm/readme +++ b/src/lib/libcrypto/des/asm/readme | |||
| @@ -8,7 +8,7 @@ assembler for the inner DES routines in libdes :-). | |||
| 8 | 8 | ||
| 9 | The file to implement in assembler is des_enc.c. Replace the following | 9 | The file to implement in assembler is des_enc.c. Replace the following |
| 10 | 4 functions | 10 | 4 functions |
| 11 | des_encrypt(DES_LONG data[2],des_key_schedule ks, int encrypt); | 11 | des_encrypt1(DES_LONG data[2],des_key_schedule ks, int encrypt); |
| 12 | des_encrypt2(DES_LONG data[2],des_key_schedule ks, int encrypt); | 12 | des_encrypt2(DES_LONG data[2],des_key_schedule ks, int encrypt); |
| 13 | des_encrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3); | 13 | des_encrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3); |
| 14 | des_decrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3); | 14 | des_decrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3); |
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c index 92a78b05d6..b5db4e14f7 100644 --- a/src/lib/libcrypto/des/cbc3_enc.c +++ b/src/lib/libcrypto/des/cbc3_enc.c | |||
| @@ -58,42 +58,42 @@ | |||
| 58 | 58 | ||
| 59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
| 60 | 60 | ||
| 61 | /* HAS BUGS? DON'T USE - this is only present for use in des.c */ | 61 | /* HAS BUGS! DON'T USE - this is only present for use in des.c */ |
| 62 | void des_3cbc_encrypt(input, output, length, ks1, ks2, iv1, iv2, enc) | 62 | void DES_3cbc_encrypt(DES_cblock *input, DES_cblock *output, long length, |
| 63 | des_cblock (*input); | 63 | DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock *iv1, |
| 64 | des_cblock (*output); | 64 | DES_cblock *iv2, int enc) |
| 65 | long length; | ||
| 66 | des_key_schedule ks1; | ||
| 67 | des_key_schedule ks2; | ||
| 68 | des_cblock (*iv1); | ||
| 69 | des_cblock (*iv2); | ||
| 70 | int enc; | ||
| 71 | { | 65 | { |
| 72 | int off=((int)length-1)/8; | 66 | int off=((int)length-1)/8; |
| 73 | long l8=((length+7)/8)*8; | 67 | long l8=((length+7)/8)*8; |
| 74 | des_cblock niv1,niv2; | 68 | DES_cblock niv1,niv2; |
| 75 | 69 | ||
| 76 | if (enc == DES_ENCRYPT) | 70 | if (enc == DES_ENCRYPT) |
| 77 | { | 71 | { |
| 78 | des_cbc_encrypt(input,output,length,ks1,iv1,enc); | 72 | DES_cbc_encrypt((unsigned char*)input, |
| 79 | if (length >= sizeof(des_cblock)) | 73 | (unsigned char*)output,length,&ks1,iv1,enc); |
| 80 | memcpy(niv1,output[off],sizeof(des_cblock)); | 74 | if (length >= sizeof(DES_cblock)) |
| 81 | des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); | 75 | memcpy(niv1,output[off],sizeof(DES_cblock)); |
| 82 | des_cbc_encrypt(output,output,l8,ks1,iv2, enc); | 76 | DES_cbc_encrypt((unsigned char*)output, |
| 83 | if (length >= sizeof(des_cblock)) | 77 | (unsigned char*)output,l8,&ks2,iv1,!enc); |
| 84 | memcpy(niv2,output[off],sizeof(des_cblock)); | 78 | DES_cbc_encrypt((unsigned char*)output, |
| 79 | (unsigned char*)output,l8,&ks1,iv2,enc); | ||
| 80 | if (length >= sizeof(DES_cblock)) | ||
| 81 | memcpy(niv2,output[off],sizeof(DES_cblock)); | ||
| 85 | } | 82 | } |
| 86 | else | 83 | else |
| 87 | { | 84 | { |
| 88 | if (length >= sizeof(des_cblock)) | 85 | if (length >= sizeof(DES_cblock)) |
| 89 | memcpy(niv2,input[off],sizeof(des_cblock)); | 86 | memcpy(niv2,input[off],sizeof(DES_cblock)); |
| 90 | des_cbc_encrypt(input,output,l8,ks1,iv2,enc); | 87 | DES_cbc_encrypt((unsigned char*)input, |
| 91 | des_cbc_encrypt(output,output,l8,ks2,iv1,!enc); | 88 | (unsigned char*)output,l8,&ks1,iv2,enc); |
| 92 | if (length >= sizeof(des_cblock)) | 89 | DES_cbc_encrypt((unsigned char*)output, |
| 93 | memcpy(niv1,output[off],sizeof(des_cblock)); | 90 | (unsigned char*)output,l8,&ks2,iv1,!enc); |
| 94 | des_cbc_encrypt(output,output,length,ks1,iv1, enc); | 91 | if (length >= sizeof(DES_cblock)) |
| 92 | memcpy(niv1,output[off],sizeof(DES_cblock)); | ||
| 93 | DES_cbc_encrypt((unsigned char*)output, | ||
| 94 | (unsigned char*)output,length,&ks1,iv1,enc); | ||
| 95 | } | 95 | } |
| 96 | memcpy(*iv1,niv1,sizeof(des_cblock)); | 96 | memcpy(*iv1,niv1,sizeof(DES_cblock)); |
| 97 | memcpy(*iv2,niv2,sizeof(des_cblock)); | 97 | memcpy(*iv2,niv2,sizeof(DES_cblock)); |
| 98 | } | 98 | } |
| 99 | 99 | ||
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com index 2aea7a0dea..fc2c35a1ce 100644 --- a/src/lib/libcrypto/des/des-lib.com +++ b/src/lib/libcrypto/des/des-lib.com | |||
| @@ -846,8 +846,8 @@ $ ENDIF | |||
| 846 | $! | 846 | $! |
| 847 | $! Set Up Initial CC Definitions, Possibly With User Ones | 847 | $! Set Up Initial CC Definitions, Possibly With User Ones |
| 848 | $! | 848 | $! |
| 849 | $ CCDEFS = "VMS=1" | 849 | $ CCDEFS = "" |
| 850 | $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS | 850 | $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS |
| 851 | $ CCEXTRAFLAGS = "" | 851 | $ CCEXTRAFLAGS = "" |
| 852 | $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS | 852 | $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS |
| 853 | $ CCDISABLEWARNINGS = "" | 853 | $ CCDISABLEWARNINGS = "" |
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c index c1e5005474..d8c846b23d 100644 --- a/src/lib/libcrypto/des/des.c +++ b/src/lib/libcrypto/des/des.c | |||
| @@ -58,17 +58,26 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #ifndef MSDOS | 61 | #include <string.h> |
| 62 | #include <openssl/opensslconf.h> | ||
| 63 | #ifndef OPENSSL_SYS_MSDOS | ||
| 64 | #ifndef OPENSSL_SYS_VMS | ||
| 65 | #include OPENSSL_UNISTD | ||
| 66 | #else /* OPENSSL_SYS_VMS */ | ||
| 67 | #ifdef __DECC | ||
| 62 | #include <unistd.h> | 68 | #include <unistd.h> |
| 63 | #else | 69 | #else /* not __DECC */ |
| 70 | #include <math.h> | ||
| 71 | #endif /* __DECC */ | ||
| 72 | #endif /* OPENSSL_SYS_VMS */ | ||
| 73 | #else /* OPENSSL_SYS_MSDOS */ | ||
| 64 | #include <io.h> | 74 | #include <io.h> |
| 65 | #define RAND | ||
| 66 | #endif | 75 | #endif |
| 67 | 76 | ||
| 68 | #include <time.h> | 77 | #include <time.h> |
| 69 | #include "des_ver.h" | 78 | #include "des_ver.h" |
| 70 | 79 | ||
| 71 | #ifdef VMS | 80 | #ifdef OPENSSL_SYS_VMS |
| 72 | #include <types.h> | 81 | #include <types.h> |
| 73 | #include <stat.h> | 82 | #include <stat.h> |
| 74 | #else | 83 | #else |
| @@ -77,21 +86,10 @@ | |||
| 77 | #endif | 86 | #endif |
| 78 | #include <sys/stat.h> | 87 | #include <sys/stat.h> |
| 79 | #endif | 88 | #endif |
| 80 | #if defined(NOCONST) | 89 | #include <openssl/des.h> |
| 81 | #define const | 90 | #include <openssl/rand.h> |
| 82 | #endif | 91 | #include <openssl/ui_compat.h> |
| 83 | #include "des.h" | ||
| 84 | |||
| 85 | #if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) | ||
| 86 | #include <string.h> | ||
| 87 | #endif | ||
| 88 | 92 | ||
| 89 | #ifdef RAND | ||
| 90 | #define random rand | ||
| 91 | #define srandom(s) srand(s) | ||
| 92 | #endif | ||
| 93 | |||
| 94 | #ifndef NOPROTO | ||
| 95 | void usage(void); | 93 | void usage(void); |
| 96 | void doencryption(void); | 94 | void doencryption(void); |
| 97 | int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp); | 95 | int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp); |
| @@ -99,21 +97,10 @@ void uufwriteEnd(FILE *fp); | |||
| 99 | int uufread(unsigned char *out,int size,unsigned int num,FILE *fp); | 97 | int uufread(unsigned char *out,int size,unsigned int num,FILE *fp); |
| 100 | int uuencode(unsigned char *in,int num,unsigned char *out); | 98 | int uuencode(unsigned char *in,int num,unsigned char *out); |
| 101 | int uudecode(unsigned char *in,int num,unsigned char *out); | 99 | int uudecode(unsigned char *in,int num,unsigned char *out); |
| 102 | void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, | 100 | void DES_3cbc_encrypt(DES_cblock *input,DES_cblock *output,long length, |
| 103 | des_key_schedule sk1,des_key_schedule sk2, | 101 | DES_key_schedule sk1,DES_key_schedule sk2, |
| 104 | des_cblock *ivec1,des_cblock *ivec2,int enc); | 102 | DES_cblock *ivec1,DES_cblock *ivec2,int enc); |
| 105 | #else | 103 | #ifdef OPENSSL_SYS_VMS |
| 106 | void usage(); | ||
| 107 | void doencryption(); | ||
| 108 | int uufwrite(); | ||
| 109 | void uufwriteEnd(); | ||
| 110 | int uufread(); | ||
| 111 | int uuencode(); | ||
| 112 | int uudecode(); | ||
| 113 | void des_3cbc_encrypt(); | ||
| 114 | #endif | ||
| 115 | |||
| 116 | #ifdef VMS | ||
| 117 | #define EXIT(a) exit(a&0x10000000L) | 104 | #define EXIT(a) exit(a&0x10000000L) |
| 118 | #else | 105 | #else |
| 119 | #define EXIT(a) exit(a) | 106 | #define EXIT(a) exit(a) |
| @@ -133,14 +120,12 @@ int uubufnum=0; | |||
| 133 | #define OUTUUBUF (65*100) | 120 | #define OUTUUBUF (65*100) |
| 134 | unsigned char b[OUTUUBUF]; | 121 | unsigned char b[OUTUUBUF]; |
| 135 | unsigned char bb[300]; | 122 | unsigned char bb[300]; |
| 136 | des_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; | 123 | DES_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
| 137 | char cksumname[200]=""; | 124 | char cksumname[200]=""; |
| 138 | 125 | ||
| 139 | int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error; | 126 | int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error; |
| 140 | 127 | ||
| 141 | int main(argc, argv) | 128 | int main(int argc, char **argv) |
| 142 | int argc; | ||
| 143 | char **argv; | ||
| 144 | { | 129 | { |
| 145 | int i; | 130 | int i; |
| 146 | struct stat ins,outs; | 131 | struct stat ins,outs; |
| @@ -168,12 +153,14 @@ char **argv; | |||
| 168 | case 'c': | 153 | case 'c': |
| 169 | cflag=1; | 154 | cflag=1; |
| 170 | strncpy(cksumname,p,200); | 155 | strncpy(cksumname,p,200); |
| 156 | cksumname[sizeof(cksumname)-1]='\0'; | ||
| 171 | p+=strlen(cksumname); | 157 | p+=strlen(cksumname); |
| 172 | break; | 158 | break; |
| 173 | case 'C': | 159 | case 'C': |
| 174 | cflag=1; | 160 | cflag=1; |
| 175 | longk=1; | 161 | longk=1; |
| 176 | strncpy(cksumname,p,200); | 162 | strncpy(cksumname,p,200); |
| 163 | cksumname[sizeof(cksumname)-1]='\0'; | ||
| 177 | p+=strlen(cksumname); | 164 | p+=strlen(cksumname); |
| 178 | break; | 165 | break; |
| 179 | case 'e': | 166 | case 'e': |
| @@ -205,6 +192,7 @@ char **argv; | |||
| 205 | case 'u': | 192 | case 'u': |
| 206 | uflag=1; | 193 | uflag=1; |
| 207 | strncpy(uuname,p,200); | 194 | strncpy(uuname,p,200); |
| 195 | uuname[sizeof(uuname)-1]='\0'; | ||
| 208 | p+=strlen(uuname); | 196 | p+=strlen(uuname); |
| 209 | break; | 197 | break; |
| 210 | case 'h': | 198 | case 'h': |
| @@ -274,12 +262,12 @@ char **argv; | |||
| 274 | #endif | 262 | #endif |
| 275 | if ( (in != NULL) && | 263 | if ( (in != NULL) && |
| 276 | (out != NULL) && | 264 | (out != NULL) && |
| 277 | #ifndef MSDOS | 265 | #ifndef OPENSSL_SYS_MSDOS |
| 278 | (stat(in,&ins) != -1) && | 266 | (stat(in,&ins) != -1) && |
| 279 | (stat(out,&outs) != -1) && | 267 | (stat(out,&outs) != -1) && |
| 280 | (ins.st_dev == outs.st_dev) && | 268 | (ins.st_dev == outs.st_dev) && |
| 281 | (ins.st_ino == outs.st_ino)) | 269 | (ins.st_ino == outs.st_ino)) |
| 282 | #else /* MSDOS */ | 270 | #else /* OPENSSL_SYS_MSDOS */ |
| 283 | (strcmp(in,out) == 0)) | 271 | (strcmp(in,out) == 0)) |
| 284 | #endif | 272 | #endif |
| 285 | { | 273 | { |
| @@ -314,7 +302,7 @@ char **argv; | |||
| 314 | EXIT(5); | 302 | EXIT(5); |
| 315 | } | 303 | } |
| 316 | 304 | ||
| 317 | #ifdef MSDOS | 305 | #ifdef OPENSSL_SYS_MSDOS |
| 318 | /* This should set the file to binary mode. */ | 306 | /* This should set the file to binary mode. */ |
| 319 | { | 307 | { |
| 320 | #include <fcntl.h> | 308 | #include <fcntl.h> |
| @@ -331,33 +319,33 @@ char **argv; | |||
| 331 | EXIT(0); | 319 | EXIT(0); |
| 332 | } | 320 | } |
| 333 | 321 | ||
| 334 | void usage() | 322 | void usage(void) |
| 335 | { | 323 | { |
| 336 | char **u; | 324 | char **u; |
| 337 | static const char *Usage[]={ | 325 | static const char *Usage[]={ |
| 338 | "des <options> [input-file [output-file]]", | 326 | "des <options> [input-file [output-file]]", |
| 339 | "options:", | 327 | "options:", |
| 340 | "-v : des(1) version number", | 328 | "-v : des(1) version number", |
| 341 | "-e : encrypt using sunOS compatible user key to DES key conversion.", | 329 | "-e : encrypt using SunOS compatible user key to DES key conversion.", |
| 342 | "-E : encrypt ", | 330 | "-E : encrypt ", |
| 343 | "-d : decrypt using sunOS compatible user key to DES key conversion.", | 331 | "-d : decrypt using SunOS compatible user key to DES key conversion.", |
| 344 | "-D : decrypt ", | 332 | "-D : decrypt ", |
| 345 | "-c[ckname] : generate a cbc_cksum using sunOS compatible user key to", | 333 | "-c[ckname] : generate a cbc_cksum using SunOS compatible user key to", |
| 346 | " DES key conversion and output to ckname (stdout default,", | 334 | " DES key conversion and output to ckname (stdout default,", |
| 347 | " stderr if data being output on stdout). The checksum is", | 335 | " stderr if data being output on stdout). The checksum is", |
| 348 | " generated before encryption and after decryption if used", | 336 | " generated before encryption and after decryption if used", |
| 349 | " in conjunction with -[eEdD].", | 337 | " in conjunction with -[eEdD].", |
| 350 | "-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].", | 338 | "-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].", |
| 351 | "-k key : use key 'key'", | 339 | "-k key : use key 'key'", |
| 352 | "-h : the key that is entered will be a hexidecimal number", | 340 | "-h : the key that is entered will be a hexadecimal number", |
| 353 | " that is used directly as the des key", | 341 | " that is used directly as the des key", |
| 354 | "-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]", | 342 | "-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]", |
| 355 | " (uuname is the filename to put in the uuencode header).", | 343 | " (uuname is the filename to put in the uuencode header).", |
| 356 | "-b : encrypt using DES in ecb encryption mode, the defaut is cbc mode.", | 344 | "-b : encrypt using DES in ecb encryption mode, the default is cbc mode.", |
| 357 | "-3 : encrypt using tripple DES encryption. This uses 2 keys", | 345 | "-3 : encrypt using triple DES encryption. This uses 2 keys", |
| 358 | " generated from the input key. If the input key is less", | 346 | " generated from the input key. If the input key is less", |
| 359 | " than 8 characters long, this is equivelent to normal", | 347 | " than 8 characters long, this is equivalent to normal", |
| 360 | " encryption. Default is tripple cbc, -b makes it tripple ecb.", | 348 | " encryption. Default is triple cbc, -b makes it triple ecb.", |
| 361 | NULL | 349 | NULL |
| 362 | }; | 350 | }; |
| 363 | for (u=(char **)Usage; *u; u++) | 351 | for (u=(char **)Usage; *u; u++) |
| @@ -369,31 +357,29 @@ NULL | |||
| 369 | EXIT(1); | 357 | EXIT(1); |
| 370 | } | 358 | } |
| 371 | 359 | ||
| 372 | void doencryption() | 360 | void doencryption(void) |
| 373 | { | 361 | { |
| 374 | #ifdef _LIBC | 362 | #ifdef _LIBC |
| 375 | extern int srandom(); | ||
| 376 | extern int random(); | ||
| 377 | extern unsigned long time(); | 363 | extern unsigned long time(); |
| 378 | #endif | 364 | #endif |
| 379 | 365 | ||
| 380 | register int i; | 366 | register int i; |
| 381 | des_key_schedule ks,ks2; | 367 | DES_key_schedule ks,ks2; |
| 382 | unsigned char iv[8],iv2[8]; | 368 | DES_cblock iv,iv2; |
| 383 | char *p; | 369 | char *p; |
| 384 | int num=0,j,k,l,rem,ll,len,last,ex=0; | 370 | int num=0,j,k,l,rem,ll,len,last,ex=0; |
| 385 | des_cblock kk,k2; | 371 | DES_cblock kk,k2; |
| 386 | FILE *O; | 372 | FILE *O; |
| 387 | int Exit=0; | 373 | int Exit=0; |
| 388 | #ifndef MSDOS | 374 | #ifndef OPENSSL_SYS_MSDOS |
| 389 | static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8]; | 375 | static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8]; |
| 390 | #else | 376 | #else |
| 391 | static unsigned char *buf=NULL,*obuf=NULL; | 377 | static unsigned char *buf=NULL,*obuf=NULL; |
| 392 | 378 | ||
| 393 | if (buf == NULL) | 379 | if (buf == NULL) |
| 394 | { | 380 | { |
| 395 | if ( (( buf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL) || | 381 | if ( (( buf=OPENSSL_malloc(BUFSIZE+8)) == NULL) || |
| 396 | ((obuf=(unsigned char *)Malloc(BUFSIZE+8)) == NULL)) | 382 | ((obuf=OPENSSL_malloc(BUFSIZE+8)) == NULL)) |
| 397 | { | 383 | { |
| 398 | fputs("Not enough memory\n",stderr); | 384 | fputs("Not enough memory\n",stderr); |
| 399 | Exit=10; | 385 | Exit=10; |
| @@ -440,19 +426,19 @@ void doencryption() | |||
| 440 | else | 426 | else |
| 441 | k2[i-8]=k; | 427 | k2[i-8]=k; |
| 442 | } | 428 | } |
| 443 | des_set_key((C_Block *)k2,ks2); | 429 | DES_set_key_unchecked(&k2,&ks2); |
| 444 | memset(k2,0,sizeof(k2)); | 430 | memset(k2,0,sizeof(k2)); |
| 445 | } | 431 | } |
| 446 | else if (longk || flag3) | 432 | else if (longk || flag3) |
| 447 | { | 433 | { |
| 448 | if (flag3) | 434 | if (flag3) |
| 449 | { | 435 | { |
| 450 | des_string_to_2keys(key,(C_Block *)kk,(C_Block *)k2); | 436 | DES_string_to_2keys(key,&kk,&k2); |
| 451 | des_set_key((C_Block *)k2,ks2); | 437 | DES_set_key_unchecked(&k2,&ks2); |
| 452 | memset(k2,0,sizeof(k2)); | 438 | memset(k2,0,sizeof(k2)); |
| 453 | } | 439 | } |
| 454 | else | 440 | else |
| 455 | des_string_to_key(key,(C_Block *)kk); | 441 | DES_string_to_key(key,&kk); |
| 456 | } | 442 | } |
| 457 | else | 443 | else |
| 458 | for (i=0; i<KEYSIZ; i++) | 444 | for (i=0; i<KEYSIZ; i++) |
| @@ -470,7 +456,7 @@ void doencryption() | |||
| 470 | kk[i]=key[i]|0x80; | 456 | kk[i]=key[i]|0x80; |
| 471 | } | 457 | } |
| 472 | 458 | ||
| 473 | des_set_key((C_Block *)kk,ks); | 459 | DES_set_key_unchecked(&kk,&ks); |
| 474 | memset(key,0,sizeof(key)); | 460 | memset(key,0,sizeof(key)); |
| 475 | memset(kk,0,sizeof(kk)); | 461 | memset(kk,0,sizeof(kk)); |
| 476 | /* woops - A bug that does not showup under unix :-( */ | 462 | /* woops - A bug that does not showup under unix :-( */ |
| @@ -498,9 +484,8 @@ void doencryption() | |||
| 498 | len=l-rem; | 484 | len=l-rem; |
| 499 | if (feof(DES_IN)) | 485 | if (feof(DES_IN)) |
| 500 | { | 486 | { |
| 501 | srandom((unsigned int)time(NULL)); | ||
| 502 | for (i=7-rem; i>0; i--) | 487 | for (i=7-rem; i>0; i--) |
| 503 | buf[l++]=random()&0xff; | 488 | RAND_pseudo_bytes(buf + l++, 1); |
| 504 | buf[l++]=rem; | 489 | buf[l++]=rem; |
| 505 | ex=1; | 490 | ex=1; |
| 506 | len+=rem; | 491 | len+=rem; |
| @@ -510,8 +495,8 @@ void doencryption() | |||
| 510 | 495 | ||
| 511 | if (cflag) | 496 | if (cflag) |
| 512 | { | 497 | { |
| 513 | des_cbc_cksum((C_Block *)buf,(C_Block *)cksum, | 498 | DES_cbc_cksum(buf,&cksum, |
| 514 | (long)len,ks,(C_Block *)cksum); | 499 | (long)len,&ks,&cksum); |
| 515 | if (!eflag) | 500 | if (!eflag) |
| 516 | { | 501 | { |
| 517 | if (feof(DES_IN)) break; | 502 | if (feof(DES_IN)) break; |
| @@ -521,34 +506,34 @@ void doencryption() | |||
| 521 | 506 | ||
| 522 | if (bflag && !flag3) | 507 | if (bflag && !flag3) |
| 523 | for (i=0; i<l; i+=8) | 508 | for (i=0; i<l; i+=8) |
| 524 | des_ecb_encrypt( | 509 | DES_ecb_encrypt( |
| 525 | (des_cblock *)&(buf[i]), | 510 | (DES_cblock *)&(buf[i]), |
| 526 | (des_cblock *)&(obuf[i]), | 511 | (DES_cblock *)&(obuf[i]), |
| 527 | ks,do_encrypt); | 512 | &ks,do_encrypt); |
| 528 | else if (flag3 && bflag) | 513 | else if (flag3 && bflag) |
| 529 | for (i=0; i<l; i+=8) | 514 | for (i=0; i<l; i+=8) |
| 530 | des_ecb2_encrypt( | 515 | DES_ecb2_encrypt( |
| 531 | (des_cblock *)&(buf[i]), | 516 | (DES_cblock *)&(buf[i]), |
| 532 | (des_cblock *)&(obuf[i]), | 517 | (DES_cblock *)&(obuf[i]), |
| 533 | ks,ks2,do_encrypt); | 518 | &ks,&ks2,do_encrypt); |
| 534 | else if (flag3 && !bflag) | 519 | else if (flag3 && !bflag) |
| 535 | { | 520 | { |
| 536 | char tmpbuf[8]; | 521 | char tmpbuf[8]; |
| 537 | 522 | ||
| 538 | if (rem) memcpy(tmpbuf,&(buf[l]), | 523 | if (rem) memcpy(tmpbuf,&(buf[l]), |
| 539 | (unsigned int)rem); | 524 | (unsigned int)rem); |
| 540 | des_3cbc_encrypt( | 525 | DES_3cbc_encrypt( |
| 541 | (des_cblock *)buf,(des_cblock *)obuf, | 526 | (DES_cblock *)buf,(DES_cblock *)obuf, |
| 542 | (long)l,ks,ks2,(des_cblock *)iv, | 527 | (long)l,ks,ks2,&iv, |
| 543 | (des_cblock *)iv2,do_encrypt); | 528 | &iv2,do_encrypt); |
| 544 | if (rem) memcpy(&(buf[l]),tmpbuf, | 529 | if (rem) memcpy(&(buf[l]),tmpbuf, |
| 545 | (unsigned int)rem); | 530 | (unsigned int)rem); |
| 546 | } | 531 | } |
| 547 | else | 532 | else |
| 548 | { | 533 | { |
| 549 | des_cbc_encrypt( | 534 | DES_cbc_encrypt( |
| 550 | (des_cblock *)buf,(des_cblock *)obuf, | 535 | buf,obuf, |
| 551 | (long)l,ks,(des_cblock *)iv,do_encrypt); | 536 | (long)l,&ks,&iv,do_encrypt); |
| 552 | if (l >= 8) memcpy(iv,&(obuf[l-8]),8); | 537 | if (l >= 8) memcpy(iv,&(obuf[l-8]),8); |
| 553 | } | 538 | } |
| 554 | if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); | 539 | if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); |
| @@ -600,28 +585,28 @@ void doencryption() | |||
| 600 | 585 | ||
| 601 | if (bflag && !flag3) | 586 | if (bflag && !flag3) |
| 602 | for (i=0; i<l; i+=8) | 587 | for (i=0; i<l; i+=8) |
| 603 | des_ecb_encrypt( | 588 | DES_ecb_encrypt( |
| 604 | (des_cblock *)&(buf[i]), | 589 | (DES_cblock *)&(buf[i]), |
| 605 | (des_cblock *)&(obuf[i]), | 590 | (DES_cblock *)&(obuf[i]), |
| 606 | ks,do_encrypt); | 591 | &ks,do_encrypt); |
| 607 | else if (flag3 && bflag) | 592 | else if (flag3 && bflag) |
| 608 | for (i=0; i<l; i+=8) | 593 | for (i=0; i<l; i+=8) |
| 609 | des_ecb2_encrypt( | 594 | DES_ecb2_encrypt( |
| 610 | (des_cblock *)&(buf[i]), | 595 | (DES_cblock *)&(buf[i]), |
| 611 | (des_cblock *)&(obuf[i]), | 596 | (DES_cblock *)&(obuf[i]), |
| 612 | ks,ks2,do_encrypt); | 597 | &ks,&ks2,do_encrypt); |
| 613 | else if (flag3 && !bflag) | 598 | else if (flag3 && !bflag) |
| 614 | { | 599 | { |
| 615 | des_3cbc_encrypt( | 600 | DES_3cbc_encrypt( |
| 616 | (des_cblock *)buf,(des_cblock *)obuf, | 601 | (DES_cblock *)buf,(DES_cblock *)obuf, |
| 617 | (long)l,ks,ks2,(des_cblock *)iv, | 602 | (long)l,ks,ks2,&iv, |
| 618 | (des_cblock *)iv2,do_encrypt); | 603 | &iv2,do_encrypt); |
| 619 | } | 604 | } |
| 620 | else | 605 | else |
| 621 | { | 606 | { |
| 622 | des_cbc_encrypt( | 607 | DES_cbc_encrypt( |
| 623 | (des_cblock *)buf,(des_cblock *)obuf, | 608 | buf,obuf, |
| 624 | (long)l,ks,(des_cblock *)iv,do_encrypt); | 609 | (long)l,&ks,&iv,do_encrypt); |
| 625 | if (l >= 8) memcpy(iv,&(buf[l-8]),8); | 610 | if (l >= 8) memcpy(iv,&(buf[l-8]),8); |
| 626 | } | 611 | } |
| 627 | 612 | ||
| @@ -646,9 +631,9 @@ void doencryption() | |||
| 646 | l=l-8+last; | 631 | l=l-8+last; |
| 647 | } | 632 | } |
| 648 | i=0; | 633 | i=0; |
| 649 | if (cflag) des_cbc_cksum((C_Block *)obuf, | 634 | if (cflag) DES_cbc_cksum(obuf, |
| 650 | (C_Block *)cksum,(long)l/8*8,ks, | 635 | (DES_cblock *)cksum,(long)l/8*8,&ks, |
| 651 | (C_Block *)cksum); | 636 | (DES_cblock *)cksum); |
| 652 | while (i != l) | 637 | while (i != l) |
| 653 | { | 638 | { |
| 654 | j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT); | 639 | j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT); |
| @@ -683,8 +668,8 @@ void doencryption() | |||
| 683 | problems: | 668 | problems: |
| 684 | memset(buf,0,sizeof(buf)); | 669 | memset(buf,0,sizeof(buf)); |
| 685 | memset(obuf,0,sizeof(obuf)); | 670 | memset(obuf,0,sizeof(obuf)); |
| 686 | memset(ks,0,sizeof(ks)); | 671 | memset(&ks,0,sizeof(ks)); |
| 687 | memset(ks2,0,sizeof(ks2)); | 672 | memset(&ks2,0,sizeof(ks2)); |
| 688 | memset(iv,0,sizeof(iv)); | 673 | memset(iv,0,sizeof(iv)); |
| 689 | memset(iv2,0,sizeof(iv2)); | 674 | memset(iv2,0,sizeof(iv2)); |
| 690 | memset(kk,0,sizeof(kk)); | 675 | memset(kk,0,sizeof(kk)); |
| @@ -696,15 +681,8 @@ problems: | |||
| 696 | if (Exit) EXIT(Exit); | 681 | if (Exit) EXIT(Exit); |
| 697 | } | 682 | } |
| 698 | 683 | ||
| 699 | int uufwrite(data, size, num, fp) | 684 | /* We ignore this parameter but it should be > ~50 I believe */ |
| 700 | unsigned char *data; | 685 | int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp) |
| 701 | int size; | ||
| 702 | unsigned int num; | ||
| 703 | FILE *fp; | ||
| 704 | |||
| 705 | /* We ignore this parameter but it should be > ~50 I believe */ | ||
| 706 | |||
| 707 | |||
| 708 | { | 686 | { |
| 709 | int i,j,left,rem,ret=num; | 687 | int i,j,left,rem,ret=num; |
| 710 | static int start=1; | 688 | static int start=1; |
| @@ -757,8 +735,7 @@ FILE *fp; | |||
| 757 | return(ret); | 735 | return(ret); |
| 758 | } | 736 | } |
| 759 | 737 | ||
| 760 | void uufwriteEnd(fp) | 738 | void uufwriteEnd(FILE *fp) |
| 761 | FILE *fp; | ||
| 762 | { | 739 | { |
| 763 | int j; | 740 | int j; |
| 764 | static const char *end=" \nend\n"; | 741 | static const char *end=" \nend\n"; |
| @@ -774,11 +751,8 @@ FILE *fp; | |||
| 774 | fwrite(end,1,strlen(end),fp); | 751 | fwrite(end,1,strlen(end),fp); |
| 775 | } | 752 | } |
| 776 | 753 | ||
| 777 | int uufread(out, size, num, fp) | 754 | /* int size: should always be > ~ 60; I actually ignore this parameter :-) */ |
| 778 | unsigned char *out; | 755 | int uufread(unsigned char *out, int size, unsigned int num, FILE *fp) |
| 779 | int size; /* should always be > ~ 60; I actually ignore this parameter :-) */ | ||
| 780 | unsigned int num; | ||
| 781 | FILE *fp; | ||
| 782 | { | 756 | { |
| 783 | int i,j,tot; | 757 | int i,j,tot; |
| 784 | static int done=0; | 758 | static int done=0; |
| @@ -850,10 +824,7 @@ FILE *fp; | |||
| 850 | *((c)++)=(unsigned char)(((l) )&0xff)) | 824 | *((c)++)=(unsigned char)(((l) )&0xff)) |
| 851 | 825 | ||
| 852 | 826 | ||
| 853 | int uuencode(in, num, out) | 827 | int uuencode(unsigned char *in, int num, unsigned char *out) |
| 854 | unsigned char *in; | ||
| 855 | int num; | ||
| 856 | unsigned char *out; | ||
| 857 | { | 828 | { |
| 858 | int j,i,n,tot=0; | 829 | int j,i,n,tot=0; |
| 859 | DES_LONG l; | 830 | DES_LONG l; |
| @@ -883,10 +854,7 @@ unsigned char *out; | |||
| 883 | return(tot); | 854 | return(tot); |
| 884 | } | 855 | } |
| 885 | 856 | ||
| 886 | int uudecode(in, num, out) | 857 | int uudecode(unsigned char *in, int num, unsigned char *out) |
| 887 | unsigned char *in; | ||
| 888 | int num; | ||
| 889 | unsigned char *out; | ||
| 890 | { | 858 | { |
| 891 | int j,i,k; | 859 | int j,i,k; |
| 892 | unsigned int n=0,space=0; | 860 | unsigned int n=0,space=0; |
diff --git a/src/lib/libcrypto/des/des3s.cpp b/src/lib/libcrypto/des/des3s.cpp index 9aff6494d9..02d527c057 100644 --- a/src/lib/libcrypto/des/des3s.cpp +++ b/src/lib/libcrypto/des/des3s.cpp | |||
| @@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc) | |||
| 32 | 32 | ||
| 33 | #include <stdio.h> | 33 | #include <stdio.h> |
| 34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
| 35 | #include "des.h" | 35 | #include <openssl/des.h> |
| 36 | 36 | ||
| 37 | void main(int argc,char *argv[]) | 37 | void main(int argc,char *argv[]) |
| 38 | { | 38 | { |
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c index fdf0fbf461..79278b920e 100644 --- a/src/lib/libcrypto/des/des_opts.c +++ b/src/lib/libcrypto/des/des_opts.c | |||
| @@ -59,19 +59,19 @@ | |||
| 59 | /* define PART1, PART2, PART3 or PART4 to build only with a few of the options. | 59 | /* define PART1, PART2, PART3 or PART4 to build only with a few of the options. |
| 60 | * This is for machines with 64k code segment size restrictions. */ | 60 | * This is for machines with 64k code segment size restrictions. */ |
| 61 | 61 | ||
| 62 | #ifndef MSDOS | 62 | #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) |
| 63 | #define TIMES | 63 | #define TIMES |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #include <stdio.h> | 66 | #include <stdio.h> |
| 67 | #ifndef MSDOS | 67 | #ifndef OPENSSL_SYS_MSDOS |
| 68 | #include <unistd.h> | 68 | #include <openssl/e_os2.h> |
| 69 | #include OPENSSL_UNISTD | ||
| 69 | #else | 70 | #else |
| 70 | #include <io.h> | 71 | #include <io.h> |
| 71 | extern void exit(); | 72 | extern void exit(); |
| 72 | #endif | 73 | #endif |
| 73 | #include <signal.h> | 74 | #include <signal.h> |
| 74 | #ifndef VMS | ||
| 75 | #ifndef _IRIX | 75 | #ifndef _IRIX |
| 76 | #include <time.h> | 76 | #include <time.h> |
| 77 | #endif | 77 | #endif |
| @@ -79,25 +79,27 @@ extern void exit(); | |||
| 79 | #include <sys/types.h> | 79 | #include <sys/types.h> |
| 80 | #include <sys/times.h> | 80 | #include <sys/times.h> |
| 81 | #endif | 81 | #endif |
| 82 | #else /* VMS */ | 82 | |
| 83 | #include <types.h> | 83 | /* Depending on the VMS version, the tms structure is perhaps defined. |
| 84 | struct tms { | 84 | The __TMS macro will show if it was. If it wasn't defined, we should |
| 85 | time_t tms_utime; | 85 | undefine TIMES, since that tells the rest of the program how things |
| 86 | time_t tms_stime; | 86 | should be handled. -- Richard Levitte */ |
| 87 | time_t tms_uchild; /* I dunno... */ | 87 | #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) |
| 88 | time_t tms_uchildsys; /* so these names are a guess :-) */ | 88 | #undef TIMES |
| 89 | } | ||
| 90 | #endif | 89 | #endif |
| 90 | |||
| 91 | #ifndef TIMES | 91 | #ifndef TIMES |
| 92 | #include <sys/timeb.h> | 92 | #include <sys/timeb.h> |
| 93 | #endif | 93 | #endif |
| 94 | 94 | ||
| 95 | #ifdef sun | 95 | |
| 96 | #if defined(sun) || defined(__ultrix) | ||
| 97 | #define _POSIX_SOURCE | ||
| 96 | #include <limits.h> | 98 | #include <limits.h> |
| 97 | #include <sys/param.h> | 99 | #include <sys/param.h> |
| 98 | #endif | 100 | #endif |
| 99 | 101 | ||
| 100 | #include "des.h" | 102 | #include <openssl/des.h> |
| 101 | #include "spr.h" | 103 | #include "spr.h" |
| 102 | 104 | ||
| 103 | #define DES_DEFAULT_OPTIONS | 105 | #define DES_DEFAULT_OPTIONS |
| @@ -116,10 +118,10 @@ struct tms { | |||
| 116 | #undef DES_RISC2 | 118 | #undef DES_RISC2 |
| 117 | #undef DES_PTR | 119 | #undef DES_PTR |
| 118 | #undef D_ENCRYPT | 120 | #undef D_ENCRYPT |
| 119 | #define des_encrypt des_encrypt_u4_cisc_idx | 121 | #define DES_encrypt1 des_encrypt_u4_cisc_idx |
| 120 | #define des_encrypt2 des_encrypt2_u4_cisc_idx | 122 | #define DES_encrypt2 des_encrypt2_u4_cisc_idx |
| 121 | #define des_encrypt3 des_encrypt3_u4_cisc_idx | 123 | #define DES_encrypt3 des_encrypt3_u4_cisc_idx |
| 122 | #define des_decrypt3 des_decrypt3_u4_cisc_idx | 124 | #define DES_decrypt3 des_decrypt3_u4_cisc_idx |
| 123 | #undef HEADER_DES_LOCL_H | 125 | #undef HEADER_DES_LOCL_H |
| 124 | #include "des_enc.c" | 126 | #include "des_enc.c" |
| 125 | 127 | ||
| @@ -128,14 +130,14 @@ struct tms { | |||
| 128 | #undef DES_RISC2 | 130 | #undef DES_RISC2 |
| 129 | #undef DES_PTR | 131 | #undef DES_PTR |
| 130 | #undef D_ENCRYPT | 132 | #undef D_ENCRYPT |
| 131 | #undef des_encrypt | 133 | #undef DES_encrypt1 |
| 132 | #undef des_encrypt2 | 134 | #undef DES_encrypt2 |
| 133 | #undef des_encrypt3 | 135 | #undef DES_encrypt3 |
| 134 | #undef des_decrypt3 | 136 | #undef DES_decrypt3 |
| 135 | #define des_encrypt des_encrypt_u16_cisc_idx | 137 | #define DES_encrypt1 des_encrypt_u16_cisc_idx |
| 136 | #define des_encrypt2 des_encrypt2_u16_cisc_idx | 138 | #define DES_encrypt2 des_encrypt2_u16_cisc_idx |
| 137 | #define des_encrypt3 des_encrypt3_u16_cisc_idx | 139 | #define DES_encrypt3 des_encrypt3_u16_cisc_idx |
| 138 | #define des_decrypt3 des_decrypt3_u16_cisc_idx | 140 | #define DES_decrypt3 des_decrypt3_u16_cisc_idx |
| 139 | #undef HEADER_DES_LOCL_H | 141 | #undef HEADER_DES_LOCL_H |
| 140 | #include "des_enc.c" | 142 | #include "des_enc.c" |
| 141 | 143 | ||
| @@ -144,14 +146,14 @@ struct tms { | |||
| 144 | #undef DES_RISC2 | 146 | #undef DES_RISC2 |
| 145 | #undef DES_PTR | 147 | #undef DES_PTR |
| 146 | #undef D_ENCRYPT | 148 | #undef D_ENCRYPT |
| 147 | #undef des_encrypt | 149 | #undef DES_encrypt1 |
| 148 | #undef des_encrypt2 | 150 | #undef DES_encrypt2 |
| 149 | #undef des_encrypt3 | 151 | #undef DES_encrypt3 |
| 150 | #undef des_decrypt3 | 152 | #undef DES_decrypt3 |
| 151 | #define des_encrypt des_encrypt_u4_risc1_idx | 153 | #define DES_encrypt1 des_encrypt_u4_risc1_idx |
| 152 | #define des_encrypt2 des_encrypt2_u4_risc1_idx | 154 | #define DES_encrypt2 des_encrypt2_u4_risc1_idx |
| 153 | #define des_encrypt3 des_encrypt3_u4_risc1_idx | 155 | #define DES_encrypt3 des_encrypt3_u4_risc1_idx |
| 154 | #define des_decrypt3 des_decrypt3_u4_risc1_idx | 156 | #define DES_decrypt3 des_decrypt3_u4_risc1_idx |
| 155 | #undef HEADER_DES_LOCL_H | 157 | #undef HEADER_DES_LOCL_H |
| 156 | #include "des_enc.c" | 158 | #include "des_enc.c" |
| 157 | 159 | ||
| @@ -164,14 +166,14 @@ struct tms { | |||
| 164 | #define DES_RISC2 | 166 | #define DES_RISC2 |
| 165 | #undef DES_PTR | 167 | #undef DES_PTR |
| 166 | #undef D_ENCRYPT | 168 | #undef D_ENCRYPT |
| 167 | #undef des_encrypt | 169 | #undef DES_encrypt1 |
| 168 | #undef des_encrypt2 | 170 | #undef DES_encrypt2 |
| 169 | #undef des_encrypt3 | 171 | #undef DES_encrypt3 |
| 170 | #undef des_decrypt3 | 172 | #undef DES_decrypt3 |
| 171 | #define des_encrypt des_encrypt_u4_risc2_idx | 173 | #define DES_encrypt1 des_encrypt_u4_risc2_idx |
| 172 | #define des_encrypt2 des_encrypt2_u4_risc2_idx | 174 | #define DES_encrypt2 des_encrypt2_u4_risc2_idx |
| 173 | #define des_encrypt3 des_encrypt3_u4_risc2_idx | 175 | #define DES_encrypt3 des_encrypt3_u4_risc2_idx |
| 174 | #define des_decrypt3 des_decrypt3_u4_risc2_idx | 176 | #define DES_decrypt3 des_decrypt3_u4_risc2_idx |
| 175 | #undef HEADER_DES_LOCL_H | 177 | #undef HEADER_DES_LOCL_H |
| 176 | #include "des_enc.c" | 178 | #include "des_enc.c" |
| 177 | 179 | ||
| @@ -180,14 +182,14 @@ struct tms { | |||
| 180 | #undef DES_RISC2 | 182 | #undef DES_RISC2 |
| 181 | #undef DES_PTR | 183 | #undef DES_PTR |
| 182 | #undef D_ENCRYPT | 184 | #undef D_ENCRYPT |
| 183 | #undef des_encrypt | 185 | #undef DES_encrypt1 |
| 184 | #undef des_encrypt2 | 186 | #undef DES_encrypt2 |
| 185 | #undef des_encrypt3 | 187 | #undef DES_encrypt3 |
| 186 | #undef des_decrypt3 | 188 | #undef DES_decrypt3 |
| 187 | #define des_encrypt des_encrypt_u16_risc1_idx | 189 | #define DES_encrypt1 des_encrypt_u16_risc1_idx |
| 188 | #define des_encrypt2 des_encrypt2_u16_risc1_idx | 190 | #define DES_encrypt2 des_encrypt2_u16_risc1_idx |
| 189 | #define des_encrypt3 des_encrypt3_u16_risc1_idx | 191 | #define DES_encrypt3 des_encrypt3_u16_risc1_idx |
| 190 | #define des_decrypt3 des_decrypt3_u16_risc1_idx | 192 | #define DES_decrypt3 des_decrypt3_u16_risc1_idx |
| 191 | #undef HEADER_DES_LOCL_H | 193 | #undef HEADER_DES_LOCL_H |
| 192 | #include "des_enc.c" | 194 | #include "des_enc.c" |
| 193 | 195 | ||
| @@ -196,14 +198,14 @@ struct tms { | |||
| 196 | #define DES_RISC2 | 198 | #define DES_RISC2 |
| 197 | #undef DES_PTR | 199 | #undef DES_PTR |
| 198 | #undef D_ENCRYPT | 200 | #undef D_ENCRYPT |
| 199 | #undef des_encrypt | 201 | #undef DES_encrypt1 |
| 200 | #undef des_encrypt2 | 202 | #undef DES_encrypt2 |
| 201 | #undef des_encrypt3 | 203 | #undef DES_encrypt3 |
| 202 | #undef des_decrypt3 | 204 | #undef DES_decrypt3 |
| 203 | #define des_encrypt des_encrypt_u16_risc2_idx | 205 | #define DES_encrypt1 des_encrypt_u16_risc2_idx |
| 204 | #define des_encrypt2 des_encrypt2_u16_risc2_idx | 206 | #define DES_encrypt2 des_encrypt2_u16_risc2_idx |
| 205 | #define des_encrypt3 des_encrypt3_u16_risc2_idx | 207 | #define DES_encrypt3 des_encrypt3_u16_risc2_idx |
| 206 | #define des_decrypt3 des_decrypt3_u16_risc2_idx | 208 | #define DES_decrypt3 des_decrypt3_u16_risc2_idx |
| 207 | #undef HEADER_DES_LOCL_H | 209 | #undef HEADER_DES_LOCL_H |
| 208 | #include "des_enc.c" | 210 | #include "des_enc.c" |
| 209 | 211 | ||
| @@ -216,14 +218,14 @@ struct tms { | |||
| 216 | #undef DES_RISC2 | 218 | #undef DES_RISC2 |
| 217 | #define DES_PTR | 219 | #define DES_PTR |
| 218 | #undef D_ENCRYPT | 220 | #undef D_ENCRYPT |
| 219 | #undef des_encrypt | 221 | #undef DES_encrypt1 |
| 220 | #undef des_encrypt2 | 222 | #undef DES_encrypt2 |
| 221 | #undef des_encrypt3 | 223 | #undef DES_encrypt3 |
| 222 | #undef des_decrypt3 | 224 | #undef DES_decrypt3 |
| 223 | #define des_encrypt des_encrypt_u4_cisc_ptr | 225 | #define DES_encrypt1 des_encrypt_u4_cisc_ptr |
| 224 | #define des_encrypt2 des_encrypt2_u4_cisc_ptr | 226 | #define DES_encrypt2 des_encrypt2_u4_cisc_ptr |
| 225 | #define des_encrypt3 des_encrypt3_u4_cisc_ptr | 227 | #define DES_encrypt3 des_encrypt3_u4_cisc_ptr |
| 226 | #define des_decrypt3 des_decrypt3_u4_cisc_ptr | 228 | #define DES_decrypt3 des_decrypt3_u4_cisc_ptr |
| 227 | #undef HEADER_DES_LOCL_H | 229 | #undef HEADER_DES_LOCL_H |
| 228 | #include "des_enc.c" | 230 | #include "des_enc.c" |
| 229 | 231 | ||
| @@ -232,14 +234,14 @@ struct tms { | |||
| 232 | #undef DES_RISC2 | 234 | #undef DES_RISC2 |
| 233 | #define DES_PTR | 235 | #define DES_PTR |
| 234 | #undef D_ENCRYPT | 236 | #undef D_ENCRYPT |
| 235 | #undef des_encrypt | 237 | #undef DES_encrypt1 |
| 236 | #undef des_encrypt2 | 238 | #undef DES_encrypt2 |
| 237 | #undef des_encrypt3 | 239 | #undef DES_encrypt3 |
| 238 | #undef des_decrypt3 | 240 | #undef DES_decrypt3 |
| 239 | #define des_encrypt des_encrypt_u16_cisc_ptr | 241 | #define DES_encrypt1 des_encrypt_u16_cisc_ptr |
| 240 | #define des_encrypt2 des_encrypt2_u16_cisc_ptr | 242 | #define DES_encrypt2 des_encrypt2_u16_cisc_ptr |
| 241 | #define des_encrypt3 des_encrypt3_u16_cisc_ptr | 243 | #define DES_encrypt3 des_encrypt3_u16_cisc_ptr |
| 242 | #define des_decrypt3 des_decrypt3_u16_cisc_ptr | 244 | #define DES_decrypt3 des_decrypt3_u16_cisc_ptr |
| 243 | #undef HEADER_DES_LOCL_H | 245 | #undef HEADER_DES_LOCL_H |
| 244 | #include "des_enc.c" | 246 | #include "des_enc.c" |
| 245 | 247 | ||
| @@ -248,14 +250,14 @@ struct tms { | |||
| 248 | #undef DES_RISC2 | 250 | #undef DES_RISC2 |
| 249 | #define DES_PTR | 251 | #define DES_PTR |
| 250 | #undef D_ENCRYPT | 252 | #undef D_ENCRYPT |
| 251 | #undef des_encrypt | 253 | #undef DES_encrypt1 |
| 252 | #undef des_encrypt2 | 254 | #undef DES_encrypt2 |
| 253 | #undef des_encrypt3 | 255 | #undef DES_encrypt3 |
| 254 | #undef des_decrypt3 | 256 | #undef DES_decrypt3 |
| 255 | #define des_encrypt des_encrypt_u4_risc1_ptr | 257 | #define DES_encrypt1 des_encrypt_u4_risc1_ptr |
| 256 | #define des_encrypt2 des_encrypt2_u4_risc1_ptr | 258 | #define DES_encrypt2 des_encrypt2_u4_risc1_ptr |
| 257 | #define des_encrypt3 des_encrypt3_u4_risc1_ptr | 259 | #define DES_encrypt3 des_encrypt3_u4_risc1_ptr |
| 258 | #define des_decrypt3 des_decrypt3_u4_risc1_ptr | 260 | #define DES_decrypt3 des_decrypt3_u4_risc1_ptr |
| 259 | #undef HEADER_DES_LOCL_H | 261 | #undef HEADER_DES_LOCL_H |
| 260 | #include "des_enc.c" | 262 | #include "des_enc.c" |
| 261 | 263 | ||
| @@ -268,14 +270,14 @@ struct tms { | |||
| 268 | #define DES_RISC2 | 270 | #define DES_RISC2 |
| 269 | #define DES_PTR | 271 | #define DES_PTR |
| 270 | #undef D_ENCRYPT | 272 | #undef D_ENCRYPT |
| 271 | #undef des_encrypt | 273 | #undef DES_encrypt1 |
| 272 | #undef des_encrypt2 | 274 | #undef DES_encrypt2 |
| 273 | #undef des_encrypt3 | 275 | #undef DES_encrypt3 |
| 274 | #undef des_decrypt3 | 276 | #undef DES_decrypt3 |
| 275 | #define des_encrypt des_encrypt_u4_risc2_ptr | 277 | #define DES_encrypt1 des_encrypt_u4_risc2_ptr |
| 276 | #define des_encrypt2 des_encrypt2_u4_risc2_ptr | 278 | #define DES_encrypt2 des_encrypt2_u4_risc2_ptr |
| 277 | #define des_encrypt3 des_encrypt3_u4_risc2_ptr | 279 | #define DES_encrypt3 des_encrypt3_u4_risc2_ptr |
| 278 | #define des_decrypt3 des_decrypt3_u4_risc2_ptr | 280 | #define DES_decrypt3 des_decrypt3_u4_risc2_ptr |
| 279 | #undef HEADER_DES_LOCL_H | 281 | #undef HEADER_DES_LOCL_H |
| 280 | #include "des_enc.c" | 282 | #include "des_enc.c" |
| 281 | 283 | ||
| @@ -284,14 +286,14 @@ struct tms { | |||
| 284 | #undef DES_RISC2 | 286 | #undef DES_RISC2 |
| 285 | #define DES_PTR | 287 | #define DES_PTR |
| 286 | #undef D_ENCRYPT | 288 | #undef D_ENCRYPT |
| 287 | #undef des_encrypt | 289 | #undef DES_encrypt1 |
| 288 | #undef des_encrypt2 | 290 | #undef DES_encrypt2 |
| 289 | #undef des_encrypt3 | 291 | #undef DES_encrypt3 |
| 290 | #undef des_decrypt3 | 292 | #undef DES_decrypt3 |
| 291 | #define des_encrypt des_encrypt_u16_risc1_ptr | 293 | #define DES_encrypt1 des_encrypt_u16_risc1_ptr |
| 292 | #define des_encrypt2 des_encrypt2_u16_risc1_ptr | 294 | #define DES_encrypt2 des_encrypt2_u16_risc1_ptr |
| 293 | #define des_encrypt3 des_encrypt3_u16_risc1_ptr | 295 | #define DES_encrypt3 des_encrypt3_u16_risc1_ptr |
| 294 | #define des_decrypt3 des_decrypt3_u16_risc1_ptr | 296 | #define DES_decrypt3 des_decrypt3_u16_risc1_ptr |
| 295 | #undef HEADER_DES_LOCL_H | 297 | #undef HEADER_DES_LOCL_H |
| 296 | #include "des_enc.c" | 298 | #include "des_enc.c" |
| 297 | 299 | ||
| @@ -300,14 +302,14 @@ struct tms { | |||
| 300 | #define DES_RISC2 | 302 | #define DES_RISC2 |
| 301 | #define DES_PTR | 303 | #define DES_PTR |
| 302 | #undef D_ENCRYPT | 304 | #undef D_ENCRYPT |
| 303 | #undef des_encrypt | 305 | #undef DES_encrypt1 |
| 304 | #undef des_encrypt2 | 306 | #undef DES_encrypt2 |
| 305 | #undef des_encrypt3 | 307 | #undef DES_encrypt3 |
| 306 | #undef des_decrypt3 | 308 | #undef DES_decrypt3 |
| 307 | #define des_encrypt des_encrypt_u16_risc2_ptr | 309 | #define DES_encrypt1 des_encrypt_u16_risc2_ptr |
| 308 | #define des_encrypt2 des_encrypt2_u16_risc2_ptr | 310 | #define DES_encrypt2 des_encrypt2_u16_risc2_ptr |
| 309 | #define des_encrypt3 des_encrypt3_u16_risc2_ptr | 311 | #define DES_encrypt3 des_encrypt3_u16_risc2_ptr |
| 310 | #define des_decrypt3 des_decrypt3_u16_risc2_ptr | 312 | #define DES_decrypt3 des_decrypt3_u16_risc2_ptr |
| 311 | #undef HEADER_DES_LOCL_H | 313 | #undef HEADER_DES_LOCL_H |
| 312 | #include "des_enc.c" | 314 | #include "des_enc.c" |
| 313 | 315 | ||
| @@ -317,11 +319,7 @@ struct tms { | |||
| 317 | #ifndef HZ | 319 | #ifndef HZ |
| 318 | # ifndef CLK_TCK | 320 | # ifndef CLK_TCK |
| 319 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ | 321 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ |
| 320 | # ifndef VMS | 322 | # define HZ 100.0 |
| 321 | # define HZ 100.0 | ||
| 322 | # else /* VMS */ | ||
| 323 | # define HZ 100.0 | ||
| 324 | # endif | ||
| 325 | # else /* _BSD_CLK_TCK_ */ | 323 | # else /* _BSD_CLK_TCK_ */ |
| 326 | # define HZ ((double)_BSD_CLK_TCK_) | 324 | # define HZ ((double)_BSD_CLK_TCK_) |
| 327 | # endif | 325 | # endif |
| @@ -333,12 +331,7 @@ struct tms { | |||
| 333 | #define BUFSIZE ((long)1024) | 331 | #define BUFSIZE ((long)1024) |
| 334 | long run=0; | 332 | long run=0; |
| 335 | 333 | ||
| 336 | #ifndef NOPROTO | ||
| 337 | double Time_F(int s); | 334 | double Time_F(int s); |
| 338 | #else | ||
| 339 | double Time_F(); | ||
| 340 | #endif | ||
| 341 | |||
| 342 | #ifdef SIGALRM | 335 | #ifdef SIGALRM |
| 343 | #if defined(__STDC__) || defined(sgi) | 336 | #if defined(__STDC__) || defined(sgi) |
| 344 | #define SIGRETTYPE void | 337 | #define SIGRETTYPE void |
| @@ -346,14 +339,8 @@ double Time_F(); | |||
| 346 | #define SIGRETTYPE int | 339 | #define SIGRETTYPE int |
| 347 | #endif | 340 | #endif |
| 348 | 341 | ||
| 349 | #ifndef NOPROTO | ||
| 350 | SIGRETTYPE sig_done(int sig); | 342 | SIGRETTYPE sig_done(int sig); |
| 351 | #else | 343 | SIGRETTYPE sig_done(int sig) |
| 352 | SIGRETTYPE sig_done(); | ||
| 353 | #endif | ||
| 354 | |||
| 355 | SIGRETTYPE sig_done(sig) | ||
| 356 | int sig; | ||
| 357 | { | 344 | { |
| 358 | signal(SIGALRM,sig_done); | 345 | signal(SIGALRM,sig_done); |
| 359 | run=0; | 346 | run=0; |
| @@ -366,8 +353,7 @@ int sig; | |||
| 366 | #define START 0 | 353 | #define START 0 |
| 367 | #define STOP 1 | 354 | #define STOP 1 |
| 368 | 355 | ||
| 369 | double Time_F(s) | 356 | double Time_F(int s) |
| 370 | int s; | ||
| 371 | { | 357 | { |
| 372 | double ret; | 358 | double ret; |
| 373 | #ifdef TIMES | 359 | #ifdef TIMES |
| @@ -415,7 +401,7 @@ int s; | |||
| 415 | for (count=0,run=1; COND(cb); count++) \ | 401 | for (count=0,run=1; COND(cb); count++) \ |
| 416 | { \ | 402 | { \ |
| 417 | unsigned long d[2]; \ | 403 | unsigned long d[2]; \ |
| 418 | func(d,&(sch[0]),DES_ENCRYPT); \ | 404 | func(d,&sch,DES_ENCRYPT); \ |
| 419 | } \ | 405 | } \ |
| 420 | tm[index]=Time_F(STOP); \ | 406 | tm[index]=Time_F(STOP); \ |
| 421 | fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \ | 407 | fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \ |
| @@ -425,16 +411,14 @@ int s; | |||
| 425 | fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ | 411 | fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ |
| 426 | tm[index]*8,1.0e6/tm[index]); | 412 | tm[index]*8,1.0e6/tm[index]); |
| 427 | 413 | ||
| 428 | int main(argc,argv) | 414 | int main(int argc, char **argv) |
| 429 | int argc; | ||
| 430 | char **argv; | ||
| 431 | { | 415 | { |
| 432 | long count; | 416 | long count; |
| 433 | static unsigned char buf[BUFSIZE]; | 417 | static unsigned char buf[BUFSIZE]; |
| 434 | static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; | 418 | static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; |
| 435 | static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; | 419 | static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; |
| 436 | static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; | 420 | static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; |
| 437 | des_key_schedule sch,sch2,sch3; | 421 | DES_key_schedule sch,sch2,sch3; |
| 438 | double d,tm[16],max=0; | 422 | double d,tm[16],max=0; |
| 439 | int rank[16]; | 423 | int rank[16]; |
| 440 | char *str[16]; | 424 | char *str[16]; |
| @@ -450,17 +434,17 @@ char **argv; | |||
| 450 | } | 434 | } |
| 451 | 435 | ||
| 452 | #ifndef TIMES | 436 | #ifndef TIMES |
| 453 | fprintf(stderr,"To get the most acurate results, try to run this\n"); | 437 | fprintf(stderr,"To get the most accurate results, try to run this\n"); |
| 454 | fprintf(stderr,"program when this computer is idle.\n"); | 438 | fprintf(stderr,"program when this computer is idle.\n"); |
| 455 | #endif | 439 | #endif |
| 456 | 440 | ||
| 457 | des_set_key((C_Block *)key,sch); | 441 | DES_set_key_unchecked(&key,&sch); |
| 458 | des_set_key((C_Block *)key2,sch2); | 442 | DES_set_key_unchecked(&key2,&sch2); |
| 459 | des_set_key((C_Block *)key3,sch3); | 443 | DES_set_key_unchecked(&key3,&sch3); |
| 460 | 444 | ||
| 461 | #ifndef SIGALRM | 445 | #ifndef SIGALRM |
| 462 | fprintf(stderr,"First we calculate the approximate speed ...\n"); | 446 | fprintf(stderr,"First we calculate the approximate speed ...\n"); |
| 463 | des_set_key((C_Block *)key,sch); | 447 | DES_set_key_unchecked(&key,sch); |
| 464 | count=10; | 448 | count=10; |
| 465 | do { | 449 | do { |
| 466 | long i; | 450 | long i; |
| @@ -469,7 +453,7 @@ char **argv; | |||
| 469 | count*=2; | 453 | count*=2; |
| 470 | Time_F(START); | 454 | Time_F(START); |
| 471 | for (i=count; i; i--) | 455 | for (i=count; i; i--) |
| 472 | des_encrypt(data,&(sch[0]),DES_ENCRYPT); | 456 | DES_encrypt1(data,&(sch[0]),DES_ENCRYPT); |
| 473 | d=Time_F(STOP); | 457 | d=Time_F(STOP); |
| 474 | } while (d < 3.0); | 458 | } while (d < 3.0); |
| 475 | ca=count; | 459 | ca=count; |
| @@ -614,7 +598,7 @@ char **argv; | |||
| 614 | break; | 598 | break; |
| 615 | } | 599 | } |
| 616 | exit(0); | 600 | exit(0); |
| 617 | #if defined(LINT) || defined(MSDOS) | 601 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) |
| 618 | return(0); | 602 | return(0); |
| 619 | #endif | 603 | #endif |
| 620 | } | 604 | } |
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h index 7041a9271d..0fa94d5368 100644 --- a/src/lib/libcrypto/des/des_ver.h +++ b/src/lib/libcrypto/des/des_ver.h | |||
| @@ -56,5 +56,12 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | extern char *DES_version; /* SSLeay version string */ | 59 | #include <openssl/e_os2.h> |
| 60 | extern char *libdes_version; /* old libdes version string */ | 60 | |
| 61 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO | ||
| 62 | # undef OPENSSL_EXTERN | ||
| 63 | # define OPENSSL_EXTERN OPENSSL_EXPORT | ||
| 64 | #endif | ||
| 65 | |||
| 66 | OPENSSL_EXTERN char *DES_version; /* SSLeay version string */ | ||
| 67 | OPENSSL_EXTERN char *libdes_version; /* old libdes version string */ | ||
diff --git a/src/lib/libcrypto/des/dess.cpp b/src/lib/libcrypto/des/dess.cpp index 7fb5987314..5549bab90a 100644 --- a/src/lib/libcrypto/des/dess.cpp +++ b/src/lib/libcrypto/des/dess.cpp | |||
| @@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc) | |||
| 32 | 32 | ||
| 33 | #include <stdio.h> | 33 | #include <stdio.h> |
| 34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
| 35 | #include "des.h" | 35 | #include <openssl/des.h> |
| 36 | 36 | ||
| 37 | void main(int argc,char *argv[]) | 37 | void main(int argc,char *argv[]) |
| 38 | { | 38 | { |
| @@ -45,19 +45,19 @@ void main(int argc,char *argv[]) | |||
| 45 | { | 45 | { |
| 46 | for (i=0; i<1000; i++) /**/ | 46 | for (i=0; i<1000; i++) /**/ |
| 47 | { | 47 | { |
| 48 | des_encrypt(&data[0],key,1); | 48 | des_encrypt1(&data[0],key,1); |
| 49 | GetTSC(s1); | 49 | GetTSC(s1); |
| 50 | des_encrypt(&data[0],key,1); | 50 | des_encrypt1(&data[0],key,1); |
| 51 | des_encrypt(&data[0],key,1); | 51 | des_encrypt1(&data[0],key,1); |
| 52 | des_encrypt(&data[0],key,1); | 52 | des_encrypt1(&data[0],key,1); |
| 53 | GetTSC(e1); | 53 | GetTSC(e1); |
| 54 | GetTSC(s2); | 54 | GetTSC(s2); |
| 55 | des_encrypt(&data[0],key,1); | 55 | des_encrypt1(&data[0],key,1); |
| 56 | des_encrypt(&data[0],key,1); | 56 | des_encrypt1(&data[0],key,1); |
| 57 | des_encrypt(&data[0],key,1); | 57 | des_encrypt1(&data[0],key,1); |
| 58 | des_encrypt(&data[0],key,1); | 58 | des_encrypt1(&data[0],key,1); |
| 59 | GetTSC(e2); | 59 | GetTSC(e2); |
| 60 | des_encrypt(&data[0],key,1); | 60 | des_encrypt1(&data[0],key,1); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | printf("des %d %d (%d)\n", | 63 | printf("des %d %d (%d)\n", |
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c index 620c13ba6f..58e8c35dcb 100644 --- a/src/lib/libcrypto/des/destest.c +++ b/src/lib/libcrypto/des/destest.c | |||
| @@ -56,21 +56,37 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #if defined(WIN32) || defined(WIN16) || defined(WINDOWS) | 59 | #include <stdio.h> |
| 60 | #ifndef MSDOS | 60 | #include <stdlib.h> |
| 61 | #define MSDOS | 61 | |
| 62 | #include <openssl/e_os2.h> | ||
| 63 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WINDOWS) | ||
| 64 | #ifndef OPENSSL_SYS_MSDOS | ||
| 65 | #define OPENSSL_SYS_MSDOS | ||
| 62 | #endif | 66 | #endif |
| 63 | #endif | 67 | #endif |
| 64 | 68 | ||
| 65 | #include <stdio.h> | 69 | #ifndef OPENSSL_SYS_MSDOS |
| 66 | #include <stdlib.h> | 70 | #if !defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VMS_DECC) |
| 67 | #ifndef MSDOS | 71 | #include OPENSSL_UNISTD |
| 68 | #include <unistd.h> | 72 | #endif |
| 69 | #else | 73 | #else |
| 70 | #include <io.h> | 74 | #include <io.h> |
| 71 | #endif | 75 | #endif |
| 72 | #include <string.h> | 76 | #include <string.h> |
| 73 | #include "des.h" | 77 | |
| 78 | #ifdef OPENSSL_NO_DES | ||
| 79 | int main(int argc, char *argv[]) | ||
| 80 | { | ||
| 81 | printf("No DES support\n"); | ||
| 82 | return(0); | ||
| 83 | } | ||
| 84 | #else | ||
| 85 | #include <openssl/des.h> | ||
| 86 | |||
| 87 | #if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT) | ||
| 88 | #define crypt(c,s) (des_crypt((c),(s))) | ||
| 89 | #endif | ||
| 74 | 90 | ||
| 75 | /* tisk tisk - the test keys don't all have odd parity :-( */ | 91 | /* tisk tisk - the test keys don't all have odd parity :-( */ |
| 76 | /* test data */ | 92 | /* test data */ |
| @@ -219,13 +235,13 @@ static unsigned char cipher_ecb2[NUM_TESTS-1][8]={ | |||
| 219 | {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; | 235 | {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; |
| 220 | 236 | ||
| 221 | static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; | 237 | static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; |
| 222 | static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; | 238 | static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86}; |
| 223 | static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; | 239 | static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; |
| 224 | static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; | 240 | static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; |
| 225 | /* Changed the following text constant to binary so it will work on ebcdic | 241 | /* Changed the following text constant to binary so it will work on ebcdic |
| 226 | * machines :-) */ | 242 | * machines :-) */ |
| 227 | /* static char cbc_data[40]="7654321 Now is the time for \0001"; */ | 243 | /* static char cbc_data[40]="7654321 Now is the time for \0001"; */ |
| 228 | static char cbc_data[40]={ | 244 | static unsigned char cbc_data[40]={ |
| 229 | 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20, | 245 | 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20, |
| 230 | 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74, | 246 | 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74, |
| 231 | 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20, | 247 | 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20, |
| @@ -239,12 +255,24 @@ static unsigned char cbc_ok[32]={ | |||
| 239 | 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, | 255 | 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, |
| 240 | 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; | 256 | 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; |
| 241 | 257 | ||
| 258 | #ifdef SCREW_THE_PARITY | ||
| 259 | #error "SCREW_THE_PARITY is not ment to be defined." | ||
| 260 | #error "Original vectors are preserved for reference only." | ||
| 261 | static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; | ||
| 242 | static unsigned char xcbc_ok[32]={ | 262 | static unsigned char xcbc_ok[32]={ |
| 243 | 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, | 263 | 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, |
| 244 | 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, | 264 | 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, |
| 245 | 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, | 265 | 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, |
| 246 | 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, | 266 | 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, |
| 247 | }; | 267 | }; |
| 268 | #else | ||
| 269 | static unsigned char xcbc_ok[32]={ | ||
| 270 | 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29, | ||
| 271 | 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1, | ||
| 272 | 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53, | ||
| 273 | 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4, | ||
| 274 | }; | ||
| 275 | #endif | ||
| 248 | 276 | ||
| 249 | static unsigned char cbc3_ok[32]={ | 277 | static unsigned char cbc3_ok[32]={ |
| 250 | 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, | 278 | 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, |
| @@ -294,49 +322,95 @@ static unsigned char ofb_cipher[24]= | |||
| 294 | 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 | 322 | 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 |
| 295 | }; | 323 | }; |
| 296 | 324 | ||
| 297 | DES_LONG cbc_cksum_ret=0xB462FEF7L; | 325 | static DES_LONG cbc_cksum_ret=0xB462FEF7L; |
| 298 | unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; | 326 | static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; |
| 299 | 327 | ||
| 300 | #ifndef NOPROTO | ||
| 301 | static char *pt(unsigned char *p); | 328 | static char *pt(unsigned char *p); |
| 302 | static int cfb_test(int bits, unsigned char *cfb_cipher); | 329 | static int cfb_test(int bits, unsigned char *cfb_cipher); |
| 303 | static int cfb64_test(unsigned char *cfb_cipher); | 330 | static int cfb64_test(unsigned char *cfb_cipher); |
| 304 | static int ede_cfb64_test(unsigned char *cfb_cipher); | 331 | static int ede_cfb64_test(unsigned char *cfb_cipher); |
| 305 | #else | 332 | int main(int argc, char *argv[]) |
| 306 | static char *pt(); | ||
| 307 | static int cfb_test(); | ||
| 308 | static int cfb64_test(); | ||
| 309 | static int ede_cfb64_test(); | ||
| 310 | #endif | ||
| 311 | |||
| 312 | int main(argc,argv) | ||
| 313 | int argc; | ||
| 314 | char *argv[]; | ||
| 315 | { | 333 | { |
| 316 | int i,j,err=0; | 334 | int i,j,err=0; |
| 317 | des_cblock in,out,outin,iv3; | 335 | des_cblock in,out,outin,iv3,iv2; |
| 318 | des_key_schedule ks,ks2,ks3; | 336 | des_key_schedule ks,ks2,ks3; |
| 319 | unsigned char cbc_in[40]; | 337 | unsigned char cbc_in[40]; |
| 320 | unsigned char cbc_out[40]; | 338 | unsigned char cbc_out[40]; |
| 321 | DES_LONG cs; | 339 | DES_LONG cs; |
| 322 | unsigned char qret[4][4],cret[8]; | 340 | unsigned char cret[8]; |
| 323 | DES_LONG lqret[4]; | 341 | #ifdef _CRAY |
| 342 | struct { | ||
| 343 | int a:32; | ||
| 344 | int b:32; | ||
| 345 | } lqret[2]; | ||
| 346 | #else | ||
| 347 | DES_LONG lqret[4]; | ||
| 348 | #endif | ||
| 324 | int num; | 349 | int num; |
| 325 | char *str; | 350 | char *str; |
| 326 | 351 | ||
| 352 | #ifndef OPENSSL_NO_DESCBCM | ||
| 353 | printf("Doing cbcm\n"); | ||
| 354 | if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) | ||
| 355 | { | ||
| 356 | printf("Key error %d\n",j); | ||
| 357 | err=1; | ||
| 358 | } | ||
| 359 | if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0) | ||
| 360 | { | ||
| 361 | printf("Key error %d\n",j); | ||
| 362 | err=1; | ||
| 363 | } | ||
| 364 | if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0) | ||
| 365 | { | ||
| 366 | printf("Key error %d\n",j); | ||
| 367 | err=1; | ||
| 368 | } | ||
| 369 | memset(cbc_out,0,40); | ||
| 370 | memset(cbc_in,0,40); | ||
| 371 | i=strlen((char *)cbc_data)+1; | ||
| 372 | /* i=((i+7)/8)*8; */ | ||
| 373 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | ||
| 374 | memset(iv2,'\0',sizeof iv2); | ||
| 375 | |||
| 376 | DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2, | ||
| 377 | DES_ENCRYPT); | ||
| 378 | DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3, | ||
| 379 | &iv3,&iv2,DES_ENCRYPT); | ||
| 380 | /* if (memcmp(cbc_out,cbc3_ok, | ||
| 381 | (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) | ||
| 382 | { | ||
| 383 | printf("des_ede3_cbc_encrypt encrypt error\n"); | ||
| 384 | err=1; | ||
| 385 | } | ||
| 386 | */ | ||
| 387 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | ||
| 388 | memset(iv2,'\0',sizeof iv2); | ||
| 389 | DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); | ||
| 390 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) | ||
| 391 | { | ||
| 392 | int n; | ||
| 393 | |||
| 394 | printf("des_ede3_cbcm_encrypt decrypt error\n"); | ||
| 395 | for(n=0 ; n < i ; ++n) | ||
| 396 | printf(" %02x",cbc_data[n]); | ||
| 397 | printf("\n"); | ||
| 398 | for(n=0 ; n < i ; ++n) | ||
| 399 | printf(" %02x",cbc_in[n]); | ||
| 400 | printf("\n"); | ||
| 401 | err=1; | ||
| 402 | } | ||
| 403 | #endif | ||
| 404 | |||
| 327 | printf("Doing ecb\n"); | 405 | printf("Doing ecb\n"); |
| 328 | for (i=0; i<NUM_TESTS; i++) | 406 | for (i=0; i<NUM_TESTS; i++) |
| 329 | { | 407 | { |
| 330 | if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0) | 408 | DES_set_key_unchecked(&key_data[i],&ks); |
| 331 | { | ||
| 332 | printf("Key error %2d:%d\n",i+1,j); | ||
| 333 | err=1; | ||
| 334 | } | ||
| 335 | memcpy(in,plain_data[i],8); | 409 | memcpy(in,plain_data[i],8); |
| 336 | memset(out,0,8); | 410 | memset(out,0,8); |
| 337 | memset(outin,0,8); | 411 | memset(outin,0,8); |
| 338 | des_ecb_encrypt((C_Block *)in,(C_Block *)out,ks,DES_ENCRYPT); | 412 | des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT); |
| 339 | des_ecb_encrypt((C_Block *)out,(C_Block *)outin,ks,DES_DECRYPT); | 413 | des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT); |
| 340 | 414 | ||
| 341 | if (memcmp(out,cipher_data[i],8) != 0) | 415 | if (memcmp(out,cipher_data[i],8) != 0) |
| 342 | { | 416 | { |
| @@ -357,28 +431,14 @@ char *argv[]; | |||
| 357 | printf("Doing ede ecb\n"); | 431 | printf("Doing ede ecb\n"); |
| 358 | for (i=0; i<(NUM_TESTS-1); i++) | 432 | for (i=0; i<(NUM_TESTS-1); i++) |
| 359 | { | 433 | { |
| 360 | if ((j=des_key_sched((C_Block *)(key_data[i]),ks)) != 0) | 434 | DES_set_key_unchecked(&key_data[i],&ks); |
| 361 | { | 435 | DES_set_key_unchecked(&key_data[i+1],&ks2); |
| 362 | err=1; | 436 | DES_set_key_unchecked(&key_data[i+2],&ks3); |
| 363 | printf("Key error %2d:%d\n",i+1,j); | ||
| 364 | } | ||
| 365 | if ((j=des_key_sched((C_Block *)(key_data[i+1]),ks2)) != 0) | ||
| 366 | { | ||
| 367 | printf("Key error %2d:%d\n",i+2,j); | ||
| 368 | err=1; | ||
| 369 | } | ||
| 370 | if ((j=des_key_sched((C_Block *)(key_data[i+2]),ks3)) != 0) | ||
| 371 | { | ||
| 372 | printf("Key error %2d:%d\n",i+3,j); | ||
| 373 | err=1; | ||
| 374 | } | ||
| 375 | memcpy(in,plain_data[i],8); | 437 | memcpy(in,plain_data[i],8); |
| 376 | memset(out,0,8); | 438 | memset(out,0,8); |
| 377 | memset(outin,0,8); | 439 | memset(outin,0,8); |
| 378 | des_ecb2_encrypt((C_Block *)in,(C_Block *)out,ks,ks2, | 440 | des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT); |
| 379 | DES_ENCRYPT); | 441 | des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT); |
| 380 | des_ecb2_encrypt((C_Block *)out,(C_Block *)outin,ks,ks2, | ||
| 381 | DES_DECRYPT); | ||
| 382 | 442 | ||
| 383 | if (memcmp(out,cipher_ecb2[i],8) != 0) | 443 | if (memcmp(out,cipher_ecb2[i],8) != 0) |
| 384 | { | 444 | { |
| @@ -397,7 +457,7 @@ char *argv[]; | |||
| 397 | #endif | 457 | #endif |
| 398 | 458 | ||
| 399 | printf("Doing cbc\n"); | 459 | printf("Doing cbc\n"); |
| 400 | if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) | 460 | if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) |
| 401 | { | 461 | { |
| 402 | printf("Key error %d\n",j); | 462 | printf("Key error %d\n",j); |
| 403 | err=1; | 463 | err=1; |
| @@ -405,16 +465,17 @@ char *argv[]; | |||
| 405 | memset(cbc_out,0,40); | 465 | memset(cbc_out,0,40); |
| 406 | memset(cbc_in,0,40); | 466 | memset(cbc_in,0,40); |
| 407 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 467 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 408 | des_ncbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, | 468 | des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, |
| 409 | (long)strlen((char *)cbc_data)+1,ks, | 469 | &iv3,DES_ENCRYPT); |
| 410 | (C_Block *)iv3,DES_ENCRYPT); | ||
| 411 | if (memcmp(cbc_out,cbc_ok,32) != 0) | 470 | if (memcmp(cbc_out,cbc_ok,32) != 0) |
| 471 | { | ||
| 412 | printf("cbc_encrypt encrypt error\n"); | 472 | printf("cbc_encrypt encrypt error\n"); |
| 473 | err=1; | ||
| 474 | } | ||
| 413 | 475 | ||
| 414 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 476 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 415 | des_ncbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, | 477 | des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, |
| 416 | (long)strlen((char *)cbc_data)+1,ks, | 478 | &iv3,DES_DECRYPT); |
| 417 | (C_Block *)iv3,DES_DECRYPT); | ||
| 418 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0) | 479 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0) |
| 419 | { | 480 | { |
| 420 | printf("cbc_encrypt decrypt error\n"); | 481 | printf("cbc_encrypt decrypt error\n"); |
| @@ -423,7 +484,7 @@ char *argv[]; | |||
| 423 | 484 | ||
| 424 | #ifndef LIBDES_LIT | 485 | #ifndef LIBDES_LIT |
| 425 | printf("Doing desx cbc\n"); | 486 | printf("Doing desx cbc\n"); |
| 426 | if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) | 487 | if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) |
| 427 | { | 488 | { |
| 428 | printf("Key error %d\n",j); | 489 | printf("Key error %d\n",j); |
| 429 | err=1; | 490 | err=1; |
| @@ -431,19 +492,16 @@ char *argv[]; | |||
| 431 | memset(cbc_out,0,40); | 492 | memset(cbc_out,0,40); |
| 432 | memset(cbc_in,0,40); | 493 | memset(cbc_in,0,40); |
| 433 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 494 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 434 | des_xcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, | 495 | des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, |
| 435 | (long)strlen((char *)cbc_data)+1,ks, | 496 | &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT); |
| 436 | (C_Block *)iv3, | ||
| 437 | (C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_ENCRYPT); | ||
| 438 | if (memcmp(cbc_out,xcbc_ok,32) != 0) | 497 | if (memcmp(cbc_out,xcbc_ok,32) != 0) |
| 439 | { | 498 | { |
| 440 | printf("des_xcbc_encrypt encrypt error\n"); | 499 | printf("des_xcbc_encrypt encrypt error\n"); |
| 500 | err=1; | ||
| 441 | } | 501 | } |
| 442 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 502 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 443 | des_xcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, | 503 | des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, |
| 444 | (long)strlen((char *)cbc_data)+1,ks, | 504 | &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT); |
| 445 | (C_Block *)iv3, | ||
| 446 | (C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_DECRYPT); | ||
| 447 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) | 505 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) |
| 448 | { | 506 | { |
| 449 | printf("des_xcbc_encrypt decrypt error\n"); | 507 | printf("des_xcbc_encrypt decrypt error\n"); |
| @@ -452,17 +510,17 @@ char *argv[]; | |||
| 452 | #endif | 510 | #endif |
| 453 | 511 | ||
| 454 | printf("Doing ede cbc\n"); | 512 | printf("Doing ede cbc\n"); |
| 455 | if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) | 513 | if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) |
| 456 | { | 514 | { |
| 457 | printf("Key error %d\n",j); | 515 | printf("Key error %d\n",j); |
| 458 | err=1; | 516 | err=1; |
| 459 | } | 517 | } |
| 460 | if ((j=des_key_sched((C_Block *)cbc2_key,ks2)) != 0) | 518 | if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0) |
| 461 | { | 519 | { |
| 462 | printf("Key error %d\n",j); | 520 | printf("Key error %d\n",j); |
| 463 | err=1; | 521 | err=1; |
| 464 | } | 522 | } |
| 465 | if ((j=des_key_sched((C_Block *)cbc3_key,ks3)) != 0) | 523 | if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0) |
| 466 | { | 524 | { |
| 467 | printf("Key error %d\n",j); | 525 | printf("Key error %d\n",j); |
| 468 | err=1; | 526 | err=1; |
| @@ -473,46 +531,60 @@ char *argv[]; | |||
| 473 | /* i=((i+7)/8)*8; */ | 531 | /* i=((i+7)/8)*8; */ |
| 474 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 532 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 475 | 533 | ||
| 476 | des_ede3_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, | 534 | des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3, |
| 477 | 16L,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT); | 535 | DES_ENCRYPT); |
| 478 | des_ede3_cbc_encrypt((C_Block *)&(cbc_data[16]), | 536 | des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3, |
| 479 | (C_Block *)&(cbc_out[16]), | 537 | &iv3,DES_ENCRYPT); |
| 480 | (long)i-16,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT); | ||
| 481 | if (memcmp(cbc_out,cbc3_ok, | 538 | if (memcmp(cbc_out,cbc3_ok, |
| 482 | (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) | 539 | (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) |
| 483 | { | 540 | { |
| 541 | int n; | ||
| 542 | |||
| 484 | printf("des_ede3_cbc_encrypt encrypt error\n"); | 543 | printf("des_ede3_cbc_encrypt encrypt error\n"); |
| 544 | for(n=0 ; n < i ; ++n) | ||
| 545 | printf(" %02x",cbc_out[n]); | ||
| 546 | printf("\n"); | ||
| 547 | for(n=0 ; n < i ; ++n) | ||
| 548 | printf(" %02x",cbc3_ok[n]); | ||
| 549 | printf("\n"); | ||
| 485 | err=1; | 550 | err=1; |
| 486 | } | 551 | } |
| 487 | 552 | ||
| 488 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); | 553 | memcpy(iv3,cbc_iv,sizeof(cbc_iv)); |
| 489 | des_ede3_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, | 554 | des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT); |
| 490 | (long)i,ks,ks2,ks3,(C_Block *)iv3,DES_DECRYPT); | 555 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) |
| 491 | if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0) | ||
| 492 | { | 556 | { |
| 557 | int n; | ||
| 558 | |||
| 493 | printf("des_ede3_cbc_encrypt decrypt error\n"); | 559 | printf("des_ede3_cbc_encrypt decrypt error\n"); |
| 560 | for(n=0 ; n < i ; ++n) | ||
| 561 | printf(" %02x",cbc_data[n]); | ||
| 562 | printf("\n"); | ||
| 563 | for(n=0 ; n < i ; ++n) | ||
| 564 | printf(" %02x",cbc_in[n]); | ||
| 565 | printf("\n"); | ||
| 494 | err=1; | 566 | err=1; |
| 495 | } | 567 | } |
| 496 | 568 | ||
| 497 | #ifndef LIBDES_LIT | 569 | #ifndef LIBDES_LIT |
| 498 | printf("Doing pcbc\n"); | 570 | printf("Doing pcbc\n"); |
| 499 | if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0) | 571 | if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) |
| 500 | { | 572 | { |
| 501 | printf("Key error %d\n",j); | 573 | printf("Key error %d\n",j); |
| 502 | err=1; | 574 | err=1; |
| 503 | } | 575 | } |
| 504 | memset(cbc_out,0,40); | 576 | memset(cbc_out,0,40); |
| 505 | memset(cbc_in,0,40); | 577 | memset(cbc_in,0,40); |
| 506 | des_pcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out, | 578 | des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, |
| 507 | (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_ENCRYPT); | 579 | &cbc_iv,DES_ENCRYPT); |
| 508 | if (memcmp(cbc_out,pcbc_ok,32) != 0) | 580 | if (memcmp(cbc_out,pcbc_ok,32) != 0) |
| 509 | { | 581 | { |
| 510 | printf("pcbc_encrypt encrypt error\n"); | 582 | printf("pcbc_encrypt encrypt error\n"); |
| 511 | err=1; | 583 | err=1; |
| 512 | } | 584 | } |
| 513 | des_pcbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in, | 585 | des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv, |
| 514 | (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_DECRYPT); | 586 | DES_DECRYPT); |
| 515 | if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0) | 587 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) |
| 516 | { | 588 | { |
| 517 | printf("pcbc_encrypt decrypt error\n"); | 589 | printf("pcbc_encrypt decrypt error\n"); |
| 518 | err=1; | 590 | err=1; |
| @@ -536,7 +608,7 @@ char *argv[]; | |||
| 536 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 608 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 537 | for (i=0; i<sizeof(plain); i++) | 609 | for (i=0; i<sizeof(plain); i++) |
| 538 | des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]), | 610 | des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]), |
| 539 | 8,(long)1,ks,(C_Block *)cfb_tmp,DES_ENCRYPT); | 611 | 8,1,ks,&cfb_tmp,DES_ENCRYPT); |
| 540 | if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0) | 612 | if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0) |
| 541 | { | 613 | { |
| 542 | printf("cfb_encrypt small encrypt error\n"); | 614 | printf("cfb_encrypt small encrypt error\n"); |
| @@ -546,7 +618,7 @@ char *argv[]; | |||
| 546 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 618 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 547 | for (i=0; i<sizeof(plain); i++) | 619 | for (i=0; i<sizeof(plain); i++) |
| 548 | des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]), | 620 | des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]), |
| 549 | 8,(long)1,ks,(C_Block *)cfb_tmp,DES_DECRYPT); | 621 | 8,1,ks,&cfb_tmp,DES_DECRYPT); |
| 550 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) | 622 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) |
| 551 | { | 623 | { |
| 552 | printf("cfb_encrypt small decrypt error\n"); | 624 | printf("cfb_encrypt small decrypt error\n"); |
| @@ -559,10 +631,9 @@ char *argv[]; | |||
| 559 | printf("done\n"); | 631 | printf("done\n"); |
| 560 | 632 | ||
| 561 | printf("Doing ofb\n"); | 633 | printf("Doing ofb\n"); |
| 562 | des_key_sched((C_Block *)ofb_key,ks); | 634 | DES_set_key_checked(&ofb_key,&ks); |
| 563 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 635 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 564 | des_ofb_encrypt(plain,ofb_buf1,64,(long)sizeof(plain)/8,ks, | 636 | des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); |
| 565 | (C_Block *)ofb_tmp); | ||
| 566 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) | 637 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) |
| 567 | { | 638 | { |
| 568 | printf("ofb_encrypt encrypt error\n"); | 639 | printf("ofb_encrypt encrypt error\n"); |
| @@ -575,8 +646,7 @@ ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]); | |||
| 575 | err=1; | 646 | err=1; |
| 576 | } | 647 | } |
| 577 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 648 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 578 | des_ofb_encrypt(ofb_buf1,ofb_buf2,64,(long)sizeof(ofb_buf1)/8,ks, | 649 | des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp); |
| 579 | (C_Block *)ofb_tmp); | ||
| 580 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) | 650 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) |
| 581 | { | 651 | { |
| 582 | printf("ofb_encrypt decrypt error\n"); | 652 | printf("ofb_encrypt decrypt error\n"); |
| @@ -590,15 +660,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 590 | } | 660 | } |
| 591 | 661 | ||
| 592 | printf("Doing ofb64\n"); | 662 | printf("Doing ofb64\n"); |
| 593 | des_key_sched((C_Block *)ofb_key,ks); | 663 | DES_set_key_checked(&ofb_key,&ks); |
| 594 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 664 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 595 | memset(ofb_buf1,0,sizeof(ofb_buf1)); | 665 | memset(ofb_buf1,0,sizeof(ofb_buf1)); |
| 596 | memset(ofb_buf2,0,sizeof(ofb_buf1)); | 666 | memset(ofb_buf2,0,sizeof(ofb_buf1)); |
| 597 | num=0; | 667 | num=0; |
| 598 | for (i=0; i<sizeof(plain); i++) | 668 | for (i=0; i<sizeof(plain); i++) |
| 599 | { | 669 | { |
| 600 | des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks, | 670 | des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp, |
| 601 | (C_Block *)ofb_tmp,&num); | 671 | &num); |
| 602 | } | 672 | } |
| 603 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) | 673 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) |
| 604 | { | 674 | { |
| @@ -607,8 +677,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 607 | } | 677 | } |
| 608 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 678 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 609 | num=0; | 679 | num=0; |
| 610 | des_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks, | 680 | des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp, |
| 611 | (C_Block *)ofb_tmp,&num); | 681 | &num); |
| 612 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) | 682 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) |
| 613 | { | 683 | { |
| 614 | printf("ofb64_encrypt decrypt error\n"); | 684 | printf("ofb64_encrypt decrypt error\n"); |
| @@ -616,15 +686,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 616 | } | 686 | } |
| 617 | 687 | ||
| 618 | printf("Doing ede_ofb64\n"); | 688 | printf("Doing ede_ofb64\n"); |
| 619 | des_key_sched((C_Block *)ofb_key,ks); | 689 | DES_set_key_checked(&ofb_key,&ks); |
| 620 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 690 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 621 | memset(ofb_buf1,0,sizeof(ofb_buf1)); | 691 | memset(ofb_buf1,0,sizeof(ofb_buf1)); |
| 622 | memset(ofb_buf2,0,sizeof(ofb_buf1)); | 692 | memset(ofb_buf2,0,sizeof(ofb_buf1)); |
| 623 | num=0; | 693 | num=0; |
| 624 | for (i=0; i<sizeof(plain); i++) | 694 | for (i=0; i<sizeof(plain); i++) |
| 625 | { | 695 | { |
| 626 | des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks, | 696 | des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks, |
| 627 | (C_Block *)ofb_tmp,&num); | 697 | ks,&ofb_tmp,&num); |
| 628 | } | 698 | } |
| 629 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) | 699 | if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) |
| 630 | { | 700 | { |
| @@ -633,8 +703,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 633 | } | 703 | } |
| 634 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); | 704 | memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); |
| 635 | num=0; | 705 | num=0; |
| 636 | des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,(long)sizeof(ofb_buf1),ks, | 706 | des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ks,ks, |
| 637 | ks,ks,(C_Block *)ofb_tmp,&num); | 707 | &ofb_tmp,&num); |
| 638 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) | 708 | if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) |
| 639 | { | 709 | { |
| 640 | printf("ede_ofb64_encrypt decrypt error\n"); | 710 | printf("ede_ofb64_encrypt decrypt error\n"); |
| @@ -642,9 +712,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 642 | } | 712 | } |
| 643 | 713 | ||
| 644 | printf("Doing cbc_cksum\n"); | 714 | printf("Doing cbc_cksum\n"); |
| 645 | des_key_sched((C_Block *)cbc_key,ks); | 715 | DES_set_key_checked(&cbc_key,&ks); |
| 646 | cs=des_cbc_cksum((C_Block *)cbc_data,(C_Block *)cret, | 716 | cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); |
| 647 | (long)strlen(cbc_data),ks,(C_Block *)cbc_iv); | ||
| 648 | if (cs != cbc_cksum_ret) | 717 | if (cs != cbc_cksum_ret) |
| 649 | { | 718 | { |
| 650 | printf("bad return value (%08lX), should be %08lX\n", | 719 | printf("bad return value (%08lX), should be %08lX\n", |
| @@ -658,77 +727,82 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 658 | } | 727 | } |
| 659 | 728 | ||
| 660 | printf("Doing quad_cksum\n"); | 729 | printf("Doing quad_cksum\n"); |
| 661 | cs=quad_cksum((C_Block *)cbc_data,(C_Block *)qret, | 730 | cs=des_quad_cksum(cbc_data,(des_cblock *)lqret, |
| 662 | (long)strlen(cbc_data),2,(C_Block *)cbc_iv); | 731 | (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv); |
| 663 | j=sizeof(lqret[0])-4; | 732 | if (cs != 0x70d7a63aL) |
| 664 | for (i=0; i<4; i++) | 733 | { |
| 734 | printf("quad_cksum error, ret %08lx should be 70d7a63a\n", | ||
| 735 | (unsigned long)cs); | ||
| 736 | err=1; | ||
| 737 | } | ||
| 738 | #ifdef _CRAY | ||
| 739 | if (lqret[0].a != 0x327eba8dL) | ||
| 665 | { | 740 | { |
| 666 | lqret[i]=0; | 741 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", |
| 667 | memcpy(&(lqret[i]),&(qret[i][0]),4); | 742 | (unsigned long)lqret[0].a,0x327eba8dUL); |
| 668 | if (j > 0) lqret[i]=lqret[i]>>(j*8); /* For Cray */ | 743 | err=1; |
| 669 | } | 744 | } |
| 670 | { /* Big-endian fix */ | 745 | if (lqret[0].b != 0x201a49ccL) |
| 671 | static DES_LONG l=1; | ||
| 672 | static unsigned char *c=(unsigned char *)&l; | ||
| 673 | DES_LONG ll; | ||
| 674 | |||
| 675 | if (!c[0]) | ||
| 676 | { | 746 | { |
| 677 | ll=lqret[0]^lqret[3]; | 747 | printf("quad_cksum error, out[1] %08lx is not %08lx\n", |
| 678 | lqret[0]^=ll; | 748 | (unsigned long)lqret[0].b,0x201a49ccUL); |
| 679 | lqret[3]^=ll; | 749 | err=1; |
| 680 | ll=lqret[1]^lqret[2]; | ||
| 681 | lqret[1]^=ll; | ||
| 682 | lqret[2]^=ll; | ||
| 683 | } | 750 | } |
| 684 | } | 751 | if (lqret[1].a != 0x70d7a63aL) |
| 685 | if (cs != 0x70d7a63aL) | ||
| 686 | { | 752 | { |
| 687 | printf("quad_cksum error, ret %08lx should be 70d7a63a\n", | 753 | printf("quad_cksum error, out[2] %08lx is not %08lx\n", |
| 688 | (unsigned long)cs); | 754 | (unsigned long)lqret[1].a,0x70d7a63aUL); |
| 689 | err=1; | 755 | err=1; |
| 690 | } | 756 | } |
| 757 | if (lqret[1].b != 0x501c2c26L) | ||
| 758 | { | ||
| 759 | printf("quad_cksum error, out[3] %08lx is not %08lx\n", | ||
| 760 | (unsigned long)lqret[1].b,0x501c2c26UL); | ||
| 761 | err=1; | ||
| 762 | } | ||
| 763 | #else | ||
| 691 | if (lqret[0] != 0x327eba8dL) | 764 | if (lqret[0] != 0x327eba8dL) |
| 692 | { | 765 | { |
| 693 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", | 766 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", |
| 694 | (unsigned long)lqret[0],0x327eba8dL); | 767 | (unsigned long)lqret[0],0x327eba8dUL); |
| 695 | err=1; | 768 | err=1; |
| 696 | } | 769 | } |
| 697 | if (lqret[1] != 0x201a49ccL) | 770 | if (lqret[1] != 0x201a49ccL) |
| 698 | { | 771 | { |
| 699 | printf("quad_cksum error, out[1] %08lx is not %08lx\n", | 772 | printf("quad_cksum error, out[1] %08lx is not %08lx\n", |
| 700 | (unsigned long)lqret[1],0x201a49ccL); | 773 | (unsigned long)lqret[1],0x201a49ccUL); |
| 701 | err=1; | 774 | err=1; |
| 702 | } | 775 | } |
| 703 | if (lqret[2] != 0x70d7a63aL) | 776 | if (lqret[2] != 0x70d7a63aL) |
| 704 | { | 777 | { |
| 705 | printf("quad_cksum error, out[2] %08lx is not %08lx\n", | 778 | printf("quad_cksum error, out[2] %08lx is not %08lx\n", |
| 706 | (unsigned long)lqret[2],0x70d7a63aL); | 779 | (unsigned long)lqret[2],0x70d7a63aUL); |
| 707 | err=1; | 780 | err=1; |
| 708 | } | 781 | } |
| 709 | if (lqret[3] != 0x501c2c26L) | 782 | if (lqret[3] != 0x501c2c26L) |
| 710 | { | 783 | { |
| 711 | printf("quad_cksum error, out[3] %08lx is not %08lx\n", | 784 | printf("quad_cksum error, out[3] %08lx is not %08lx\n", |
| 712 | (unsigned long)lqret[3],0x501c2c26L); | 785 | (unsigned long)lqret[3],0x501c2c26UL); |
| 713 | err=1; | 786 | err=1; |
| 714 | } | 787 | } |
| 715 | #endif | 788 | #endif |
| 789 | #endif | ||
| 716 | 790 | ||
| 717 | printf("input word alignment test"); | 791 | printf("input word alignment test"); |
| 718 | for (i=0; i<4; i++) | 792 | for (i=0; i<4; i++) |
| 719 | { | 793 | { |
| 720 | printf(" %d",i); | 794 | printf(" %d",i); |
| 721 | des_ncbc_encrypt((C_Block *)&(cbc_out[i]),(C_Block *)cbc_in, | 795 | des_ncbc_encrypt(&(cbc_out[i]),cbc_in, |
| 722 | (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv, | 796 | strlen((char *)cbc_data)+1,ks, |
| 723 | DES_ENCRYPT); | 797 | &cbc_iv,DES_ENCRYPT); |
| 724 | } | 798 | } |
| 725 | printf("\noutput word alignment test"); | 799 | printf("\noutput word alignment test"); |
| 726 | for (i=0; i<4; i++) | 800 | for (i=0; i<4; i++) |
| 727 | { | 801 | { |
| 728 | printf(" %d",i); | 802 | printf(" %d",i); |
| 729 | des_ncbc_encrypt((C_Block *)cbc_out,(C_Block *)&(cbc_in[i]), | 803 | des_ncbc_encrypt(cbc_out,&(cbc_in[i]), |
| 730 | (long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv, | 804 | strlen((char *)cbc_data)+1,ks, |
| 731 | DES_ENCRYPT); | 805 | &cbc_iv,DES_ENCRYPT); |
| 732 | } | 806 | } |
| 733 | printf("\n"); | 807 | printf("\n"); |
| 734 | printf("fast crypt test "); | 808 | printf("fast crypt test "); |
| @@ -745,12 +819,10 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
| 745 | err=1; | 819 | err=1; |
| 746 | } | 820 | } |
| 747 | printf("\n"); | 821 | printf("\n"); |
| 748 | exit(err); | 822 | return(err); |
| 749 | return(0); | ||
| 750 | } | 823 | } |
| 751 | 824 | ||
| 752 | static char *pt(p) | 825 | static char *pt(unsigned char *p) |
| 753 | unsigned char *p; | ||
| 754 | { | 826 | { |
| 755 | static char bufs[10][20]; | 827 | static char bufs[10][20]; |
| 756 | static int bnum=0; | 828 | static int bnum=0; |
| @@ -771,17 +843,15 @@ unsigned char *p; | |||
| 771 | 843 | ||
| 772 | #ifndef LIBDES_LIT | 844 | #ifndef LIBDES_LIT |
| 773 | 845 | ||
| 774 | static int cfb_test(bits, cfb_cipher) | 846 | static int cfb_test(int bits, unsigned char *cfb_cipher) |
| 775 | int bits; | ||
| 776 | unsigned char *cfb_cipher; | ||
| 777 | { | 847 | { |
| 778 | des_key_schedule ks; | 848 | des_key_schedule ks; |
| 779 | int i,err=0; | 849 | int i,err=0; |
| 780 | 850 | ||
| 781 | des_key_sched((C_Block *)cfb_key,ks); | 851 | DES_set_key_checked(&cfb_key,&ks); |
| 782 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 852 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 783 | des_cfb_encrypt(plain,cfb_buf1,bits,(long)sizeof(plain),ks, | 853 | des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, |
| 784 | (C_Block *)cfb_tmp,DES_ENCRYPT); | 854 | DES_ENCRYPT); |
| 785 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) | 855 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) |
| 786 | { | 856 | { |
| 787 | err=1; | 857 | err=1; |
| @@ -790,8 +860,8 @@ unsigned char *cfb_cipher; | |||
| 790 | printf("%s\n",pt(&(cfb_buf1[i]))); | 860 | printf("%s\n",pt(&(cfb_buf1[i]))); |
| 791 | } | 861 | } |
| 792 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 862 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 793 | des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,(long)sizeof(plain),ks, | 863 | des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp, |
| 794 | (C_Block *)cfb_tmp,DES_DECRYPT); | 864 | DES_DECRYPT); |
| 795 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) | 865 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) |
| 796 | { | 866 | { |
| 797 | err=1; | 867 | err=1; |
| @@ -802,20 +872,17 @@ unsigned char *cfb_cipher; | |||
| 802 | return(err); | 872 | return(err); |
| 803 | } | 873 | } |
| 804 | 874 | ||
| 805 | static int cfb64_test(cfb_cipher) | 875 | static int cfb64_test(unsigned char *cfb_cipher) |
| 806 | unsigned char *cfb_cipher; | ||
| 807 | { | 876 | { |
| 808 | des_key_schedule ks; | 877 | des_key_schedule ks; |
| 809 | int err=0,i,n; | 878 | int err=0,i,n; |
| 810 | 879 | ||
| 811 | des_key_sched((C_Block *)cfb_key,ks); | 880 | DES_set_key_checked(&cfb_key,&ks); |
| 812 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 881 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 813 | n=0; | 882 | n=0; |
| 814 | des_cfb64_encrypt(plain,cfb_buf1,(long)12,ks, | 883 | des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); |
| 815 | (C_Block *)cfb_tmp,&n,DES_ENCRYPT); | 884 | des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks, |
| 816 | des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), | 885 | &cfb_tmp,&n,DES_ENCRYPT); |
| 817 | (long)sizeof(plain)-12,ks, | ||
| 818 | (C_Block *)cfb_tmp,&n,DES_ENCRYPT); | ||
| 819 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) | 886 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) |
| 820 | { | 887 | { |
| 821 | err=1; | 888 | err=1; |
| @@ -825,11 +892,9 @@ unsigned char *cfb_cipher; | |||
| 825 | } | 892 | } |
| 826 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 893 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 827 | n=0; | 894 | n=0; |
| 828 | des_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks, | 895 | des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT); |
| 829 | (C_Block *)cfb_tmp,&n,DES_DECRYPT); | ||
| 830 | des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), | 896 | des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), |
| 831 | (long)sizeof(plain)-17,ks, | 897 | sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT); |
| 832 | (C_Block *)cfb_tmp,&n,DES_DECRYPT); | ||
| 833 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) | 898 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) |
| 834 | { | 899 | { |
| 835 | err=1; | 900 | err=1; |
| @@ -840,20 +905,19 @@ unsigned char *cfb_cipher; | |||
| 840 | return(err); | 905 | return(err); |
| 841 | } | 906 | } |
| 842 | 907 | ||
| 843 | static int ede_cfb64_test(cfb_cipher) | 908 | static int ede_cfb64_test(unsigned char *cfb_cipher) |
| 844 | unsigned char *cfb_cipher; | ||
| 845 | { | 909 | { |
| 846 | des_key_schedule ks; | 910 | des_key_schedule ks; |
| 847 | int err=0,i,n; | 911 | int err=0,i,n; |
| 848 | 912 | ||
| 849 | des_key_sched((C_Block *)cfb_key,ks); | 913 | DES_set_key_checked(&cfb_key,&ks); |
| 850 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 914 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 851 | n=0; | 915 | n=0; |
| 852 | des_ede3_cfb64_encrypt(plain,cfb_buf1,(long)12,ks,ks,ks, | 916 | des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, |
| 853 | (C_Block *)cfb_tmp,&n,DES_ENCRYPT); | 917 | DES_ENCRYPT); |
| 854 | des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), | 918 | des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), |
| 855 | (long)sizeof(plain)-12,ks,ks,ks, | 919 | sizeof(plain)-12,ks,ks,ks, |
| 856 | (C_Block *)cfb_tmp,&n,DES_ENCRYPT); | 920 | &cfb_tmp,&n,DES_ENCRYPT); |
| 857 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) | 921 | if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) |
| 858 | { | 922 | { |
| 859 | err=1; | 923 | err=1; |
| @@ -864,10 +928,10 @@ unsigned char *cfb_cipher; | |||
| 864 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); | 928 | memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); |
| 865 | n=0; | 929 | n=0; |
| 866 | des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks, | 930 | des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks, |
| 867 | (C_Block *)cfb_tmp,&n,DES_DECRYPT); | 931 | &cfb_tmp,&n,DES_DECRYPT); |
| 868 | des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), | 932 | des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), |
| 869 | (long)sizeof(plain)-17,ks,ks,ks, | 933 | sizeof(plain)-17,ks,ks,ks, |
| 870 | (C_Block *)cfb_tmp,&n,DES_DECRYPT); | 934 | &cfb_tmp,&n,DES_DECRYPT); |
| 871 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) | 935 | if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) |
| 872 | { | 936 | { |
| 873 | err=1; | 937 | err=1; |
| @@ -879,4 +943,4 @@ unsigned char *cfb_cipher; | |||
| 879 | } | 943 | } |
| 880 | 944 | ||
| 881 | #endif | 945 | #endif |
| 882 | 946 | #endif | |
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c index a0d53793e4..b4720c3a98 100644 --- a/src/lib/libcrypto/des/read2pwd.c +++ b/src/lib/libcrypto/des/read2pwd.c | |||
| @@ -1,4 +1,57 @@ | |||
| 1 | /* crypto/des/read2pwd.c */ | 1 | /* crypto/des/read2pwd.c */ |
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@openssl.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 55 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 56 | * All rights reserved. |
| 4 | * | 57 | * |
| @@ -56,34 +109,30 @@ | |||
| 56 | * [including the GNU Public Licence.] | 109 | * [including the GNU Public Licence.] |
| 57 | */ | 110 | */ |
| 58 | 111 | ||
| 59 | #include "des_locl.h" | 112 | #include <string.h> |
| 113 | #include <openssl/des.h> | ||
| 114 | #include <openssl/ui.h> | ||
| 60 | 115 | ||
| 61 | int des_read_password(key, prompt, verify) | 116 | int DES_read_password(DES_cblock *key, const char *prompt, int verify) |
| 62 | des_cblock (*key); | ||
| 63 | char *prompt; | ||
| 64 | int verify; | ||
| 65 | { | 117 | { |
| 66 | int ok; | 118 | int ok; |
| 67 | char buf[BUFSIZ],buff[BUFSIZ]; | 119 | char buf[BUFSIZ],buff[BUFSIZ]; |
| 68 | 120 | ||
| 69 | if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) | 121 | if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) |
| 70 | des_string_to_key(buf,key); | 122 | DES_string_to_key(buf,key); |
| 71 | memset(buf,0,BUFSIZ); | 123 | memset(buf,0,BUFSIZ); |
| 72 | memset(buff,0,BUFSIZ); | 124 | memset(buff,0,BUFSIZ); |
| 73 | return(ok); | 125 | return(ok); |
| 74 | } | 126 | } |
| 75 | 127 | ||
| 76 | int des_read_2passwords(key1, key2, prompt, verify) | 128 | int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, |
| 77 | des_cblock (*key1); | 129 | int verify) |
| 78 | des_cblock (*key2); | ||
| 79 | char *prompt; | ||
| 80 | int verify; | ||
| 81 | { | 130 | { |
| 82 | int ok; | 131 | int ok; |
| 83 | char buf[BUFSIZ],buff[BUFSIZ]; | 132 | char buf[BUFSIZ],buff[BUFSIZ]; |
| 84 | 133 | ||
| 85 | if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) | 134 | if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) |
| 86 | des_string_to_2keys(buf,key1,key2); | 135 | DES_string_to_2keys(buf,key1,key2); |
| 87 | memset(buf,0,BUFSIZ); | 136 | memset(buf,0,BUFSIZ); |
| 88 | memset(buff,0,BUFSIZ); | 137 | memset(buff,0,BUFSIZ); |
| 89 | return(ok); | 138 | return(ok); |
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c index 99920f2f86..00000190f8 100644 --- a/src/lib/libcrypto/des/read_pwd.c +++ b/src/lib/libcrypto/des/read_pwd.c | |||
| @@ -56,20 +56,55 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <openssl/e_os2.h> | ||
| 60 | #if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32) | ||
| 61 | #ifdef OPENSSL_UNISTD | ||
| 62 | # include OPENSSL_UNISTD | ||
| 63 | #else | ||
| 64 | # include <unistd.h> | ||
| 65 | #endif | ||
| 66 | /* If unistd.h defines _POSIX_VERSION, we conclude that we | ||
| 67 | * are on a POSIX system and have sigaction and termios. */ | ||
| 68 | #if defined(_POSIX_VERSION) | ||
| 69 | |||
| 70 | # define SIGACTION | ||
| 71 | # if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY) | ||
| 72 | # define TERMIOS | ||
| 73 | # endif | ||
| 74 | |||
| 75 | #endif | ||
| 76 | #endif | ||
| 77 | |||
| 59 | /* #define SIGACTION */ /* Define this if you have sigaction() */ | 78 | /* #define SIGACTION */ /* Define this if you have sigaction() */ |
| 79 | |||
| 60 | #ifdef WIN16TTY | 80 | #ifdef WIN16TTY |
| 61 | #undef WIN16 | 81 | #undef OPENSSL_SYS_WIN16 |
| 62 | #undef _WINDOWS | 82 | #undef _WINDOWS |
| 63 | #include <graph.h> | 83 | #include <graph.h> |
| 64 | #endif | 84 | #endif |
| 65 | 85 | ||
| 66 | /* 06-Apr-92 Luke Brennan Support for VMS */ | 86 | /* 06-Apr-92 Luke Brennan Support for VMS */ |
| 67 | #include "des_locl.h" | 87 | #include "des_locl.h" |
| 88 | #include "cryptlib.h" | ||
| 68 | #include <signal.h> | 89 | #include <signal.h> |
| 90 | #include <stdio.h> | ||
| 69 | #include <string.h> | 91 | #include <string.h> |
| 70 | #include <setjmp.h> | 92 | #include <setjmp.h> |
| 71 | #include <errno.h> | 93 | #include <errno.h> |
| 72 | 94 | ||
| 95 | #ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ | ||
| 96 | #include <starlet.h> | ||
| 97 | #ifdef __DECC | ||
| 98 | #pragma message disable DOLLARID | ||
| 99 | #endif | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifdef WIN_CONSOLE_BUG | ||
| 103 | #include <windows.h> | ||
| 104 | #include <wincon.h> | ||
| 105 | #endif | ||
| 106 | |||
| 107 | |||
| 73 | /* There are 5 types of terminal interface supported, | 108 | /* There are 5 types of terminal interface supported, |
| 74 | * TERMIO, TERMIOS, VMS, MSDOS and SGTTY | 109 | * TERMIO, TERMIOS, VMS, MSDOS and SGTTY |
| 75 | */ | 110 | */ |
| @@ -92,12 +127,18 @@ | |||
| 92 | #undef SGTTY | 127 | #undef SGTTY |
| 93 | #endif | 128 | #endif |
| 94 | 129 | ||
| 95 | #if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) | 130 | #if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE) |
| 96 | #undef TERMIOS | 131 | #undef TERMIOS |
| 97 | #undef TERMIO | 132 | #undef TERMIO |
| 98 | #define SGTTY | 133 | #define SGTTY |
| 99 | #endif | 134 | #endif |
| 100 | 135 | ||
| 136 | #if defined(OPENSSL_SYS_VSWORKS) | ||
| 137 | #undef TERMIOS | ||
| 138 | #undef TERMIO | ||
| 139 | #undef SGTTY | ||
| 140 | #endif | ||
| 141 | |||
| 101 | #ifdef TERMIOS | 142 | #ifdef TERMIOS |
| 102 | #include <termios.h> | 143 | #include <termios.h> |
| 103 | #define TTY_STRUCT struct termios | 144 | #define TTY_STRUCT struct termios |
| @@ -122,16 +163,16 @@ | |||
| 122 | #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) | 163 | #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) |
| 123 | #endif | 164 | #endif |
| 124 | 165 | ||
| 125 | #if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) | 166 | #if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X) |
| 126 | #include <sys/ioctl.h> | 167 | #include <sys/ioctl.h> |
| 127 | #endif | 168 | #endif |
| 128 | 169 | ||
| 129 | #ifdef MSDOS | 170 | #if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) |
| 130 | #include <conio.h> | 171 | #include <conio.h> |
| 131 | #define fgets(a,b,c) noecho_fgets(a,b,c) | 172 | #define fgets(a,b,c) noecho_fgets(a,b,c) |
| 132 | #endif | 173 | #endif |
| 133 | 174 | ||
| 134 | #ifdef VMS | 175 | #ifdef OPENSSL_SYS_VMS |
| 135 | #include <ssdef.h> | 176 | #include <ssdef.h> |
| 136 | #include <iodef.h> | 177 | #include <iodef.h> |
| 137 | #include <ttdef.h> | 178 | #include <ttdef.h> |
| @@ -143,44 +184,35 @@ struct IOSB { | |||
| 143 | }; | 184 | }; |
| 144 | #endif | 185 | #endif |
| 145 | 186 | ||
| 187 | #if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE) | ||
| 188 | /* | ||
| 189 | * This one needs work. As a matter of fact the code is unoperational | ||
| 190 | * and this is only a trick to get it compiled. | ||
| 191 | * <appro@fy.chalmers.se> | ||
| 192 | */ | ||
| 193 | #define TTY_STRUCT int | ||
| 194 | #endif | ||
| 195 | |||
| 146 | #ifndef NX509_SIG | 196 | #ifndef NX509_SIG |
| 147 | #define NX509_SIG 32 | 197 | #define NX509_SIG 32 |
| 148 | #endif | 198 | #endif |
| 149 | 199 | ||
| 150 | #ifndef NOPROTO | ||
| 151 | static void read_till_nl(FILE *); | 200 | static void read_till_nl(FILE *); |
| 152 | static void recsig(int); | 201 | static void recsig(int); |
| 153 | static void pushsig(void); | 202 | static void pushsig(void); |
| 154 | static void popsig(void); | 203 | static void popsig(void); |
| 155 | #if defined(MSDOS) && !defined(WIN16) | 204 | #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) |
| 156 | static int noecho_fgets(char *buf, int size, FILE *tty); | 205 | static int noecho_fgets(char *buf, int size, FILE *tty); |
| 157 | #endif | 206 | #endif |
| 158 | #else | ||
| 159 | static void read_till_nl(); | ||
| 160 | static void recsig(); | ||
| 161 | static void pushsig(); | ||
| 162 | static void popsig(); | ||
| 163 | #if defined(MSDOS) && !defined(WIN16) | ||
| 164 | static int noecho_fgets(); | ||
| 165 | #endif | ||
| 166 | #endif | ||
| 167 | |||
| 168 | #ifdef SIGACTION | 207 | #ifdef SIGACTION |
| 169 | static struct sigaction savsig[NX509_SIG]; | 208 | static struct sigaction savsig[NX509_SIG]; |
| 170 | #else | 209 | #else |
| 171 | # ifndef NOPROTO | ||
| 172 | static void (*savsig[NX509_SIG])(int ); | 210 | static void (*savsig[NX509_SIG])(int ); |
| 173 | # else | ||
| 174 | static void (*savsig[NX509_SIG])(); | ||
| 175 | # endif | ||
| 176 | #endif | 211 | #endif |
| 177 | static jmp_buf save; | 212 | static jmp_buf save; |
| 178 | 213 | ||
| 179 | int des_read_pw_string(buf, length, prompt, verify) | 214 | int des_read_pw_string(char *buf, int length, const char *prompt, |
| 180 | char *buf; | 215 | int verify) |
| 181 | int length; | ||
| 182 | char *prompt; | ||
| 183 | int verify; | ||
| 184 | { | 216 | { |
| 185 | char buff[BUFSIZ]; | 217 | char buff[BUFSIZ]; |
| 186 | int ret; | 218 | int ret; |
| @@ -190,10 +222,9 @@ int verify; | |||
| 190 | return(ret); | 222 | return(ret); |
| 191 | } | 223 | } |
| 192 | 224 | ||
| 193 | #ifndef WIN16 | 225 | #ifndef OPENSSL_SYS_WIN16 |
| 194 | 226 | ||
| 195 | static void read_till_nl(in) | 227 | static void read_till_nl(FILE *in) |
| 196 | FILE *in; | ||
| 197 | { | 228 | { |
| 198 | #define SIZE 4 | 229 | #define SIZE 4 |
| 199 | char buf[SIZE+1]; | 230 | char buf[SIZE+1]; |
| @@ -205,41 +236,54 @@ FILE *in; | |||
| 205 | 236 | ||
| 206 | 237 | ||
| 207 | /* return 0 if ok, 1 (or -1) otherwise */ | 238 | /* return 0 if ok, 1 (or -1) otherwise */ |
| 208 | int des_read_pw(buf, buff, size, prompt, verify) | 239 | int des_read_pw(char *buf, char *buff, int size, const char *prompt, |
| 209 | char *buf; | 240 | int verify) |
| 210 | char *buff; | ||
| 211 | int size; | ||
| 212 | char *prompt; | ||
| 213 | int verify; | ||
| 214 | { | 241 | { |
| 215 | #ifdef VMS | 242 | #ifdef OPENSSL_SYS_VMS |
| 216 | struct IOSB iosb; | 243 | struct IOSB iosb; |
| 217 | $DESCRIPTOR(terminal,"TT"); | 244 | $DESCRIPTOR(terminal,"TT"); |
| 218 | long tty_orig[3], tty_new[3]; | 245 | long tty_orig[3], tty_new[3]; |
| 219 | long status; | 246 | long status; |
| 220 | unsigned short channel = 0; | 247 | unsigned short channel = 0; |
| 221 | #else | 248 | #else |
| 222 | #ifndef MSDOS | 249 | #ifndef OPENSSL_SYS_MSDOS |
| 223 | TTY_STRUCT tty_orig,tty_new; | 250 | TTY_STRUCT tty_orig,tty_new; |
| 224 | #endif | 251 | #endif |
| 225 | #endif | 252 | #endif |
| 226 | int number=5; | 253 | int number; |
| 227 | int ok=0; | 254 | int ok; |
| 228 | int ps=0; | 255 | /* statics are simply to avoid warnings about longjmp clobbering |
| 229 | int is_a_tty=1; | 256 | things */ |
| 230 | 257 | static int ps; | |
| 231 | FILE *tty=NULL; | 258 | int is_a_tty; |
| 259 | static FILE *tty; | ||
| 232 | char *p; | 260 | char *p; |
| 233 | 261 | ||
| 234 | #ifndef MSDOS | 262 | if (setjmp(save)) |
| 235 | if ((tty=fopen("/dev/tty","r")) == NULL) | 263 | { |
| 236 | tty=stdin; | 264 | ok=0; |
| 237 | #else /* MSDOS */ | 265 | goto error; |
| 266 | } | ||
| 267 | |||
| 268 | number=5; | ||
| 269 | ok=0; | ||
| 270 | ps=0; | ||
| 271 | is_a_tty=1; | ||
| 272 | tty=NULL; | ||
| 273 | |||
| 274 | #ifdef OPENSSL_SYS_MSDOS | ||
| 238 | if ((tty=fopen("con","r")) == NULL) | 275 | if ((tty=fopen("con","r")) == NULL) |
| 239 | tty=stdin; | 276 | tty=stdin; |
| 240 | #endif /* MSDOS */ | 277 | #elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS) |
| 278 | tty=stdin; | ||
| 279 | #else | ||
| 280 | #ifndef OPENSSL_SYS_MPE | ||
| 281 | if ((tty=fopen("/dev/tty","r")) == NULL) | ||
| 282 | #endif | ||
| 283 | tty=stdin; | ||
| 284 | #endif | ||
| 241 | 285 | ||
| 242 | #if defined(TTY_get) && !defined(VMS) | 286 | #if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) |
| 243 | if (TTY_get(fileno(tty),&tty_orig) == -1) | 287 | if (TTY_get(fileno(tty),&tty_orig) == -1) |
| 244 | { | 288 | { |
| 245 | #ifdef ENOTTY | 289 | #ifdef ENOTTY |
| @@ -258,20 +302,15 @@ int verify; | |||
| 258 | } | 302 | } |
| 259 | memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); | 303 | memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); |
| 260 | #endif | 304 | #endif |
| 261 | #ifdef VMS | 305 | #ifdef OPENSSL_SYS_VMS |
| 262 | status = SYS$ASSIGN(&terminal,&channel,0,0); | 306 | status = sys$assign(&terminal,&channel,0,0); |
| 263 | if (status != SS$_NORMAL) | 307 | if (status != SS$_NORMAL) |
| 264 | return(-1); | 308 | return(-1); |
| 265 | status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); | 309 | status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); |
| 266 | if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) | 310 | if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) |
| 267 | return(-1); | 311 | return(-1); |
| 268 | #endif | 312 | #endif |
| 269 | 313 | ||
| 270 | if (setjmp(save)) | ||
| 271 | { | ||
| 272 | ok=0; | ||
| 273 | goto error; | ||
| 274 | } | ||
| 275 | pushsig(); | 314 | pushsig(); |
| 276 | ps=1; | 315 | ps=1; |
| 277 | 316 | ||
| @@ -279,15 +318,19 @@ int verify; | |||
| 279 | tty_new.TTY_FLAGS &= ~ECHO; | 318 | tty_new.TTY_FLAGS &= ~ECHO; |
| 280 | #endif | 319 | #endif |
| 281 | 320 | ||
| 282 | #if defined(TTY_set) && !defined(VMS) | 321 | #if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) |
| 283 | if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) | 322 | if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) |
| 323 | #ifdef OPENSSL_SYS_MPE | ||
| 324 | ; /* MPE lies -- echo really has been disabled */ | ||
| 325 | #else | ||
| 284 | return(-1); | 326 | return(-1); |
| 285 | #endif | 327 | #endif |
| 286 | #ifdef VMS | 328 | #endif |
| 329 | #ifdef OPENSSL_SYS_VMS | ||
| 287 | tty_new[0] = tty_orig[0]; | 330 | tty_new[0] = tty_orig[0]; |
| 288 | tty_new[1] = tty_orig[1] | TT$M_NOECHO; | 331 | tty_new[1] = tty_orig[1] | TT$M_NOECHO; |
| 289 | tty_new[2] = tty_orig[2]; | 332 | tty_new[2] = tty_orig[2]; |
| 290 | status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); | 333 | status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); |
| 291 | if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) | 334 | if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) |
| 292 | return(-1); | 335 | return(-1); |
| 293 | #endif | 336 | #endif |
| @@ -329,35 +372,30 @@ int verify; | |||
| 329 | 372 | ||
| 330 | error: | 373 | error: |
| 331 | fprintf(stderr,"\n"); | 374 | fprintf(stderr,"\n"); |
| 332 | #ifdef DEBUG | 375 | #if 0 |
| 333 | perror("fgets(tty)"); | 376 | perror("fgets(tty)"); |
| 334 | #endif | 377 | #endif |
| 335 | /* What can we do if there is an error? */ | 378 | /* What can we do if there is an error? */ |
| 336 | #if defined(TTY_set) && !defined(VMS) | 379 | #if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) |
| 337 | if (ps >= 2) TTY_set(fileno(tty),&tty_orig); | 380 | if (ps >= 2) TTY_set(fileno(tty),&tty_orig); |
| 338 | #endif | 381 | #endif |
| 339 | #ifdef VMS | 382 | #ifdef OPENSSL_SYS_VMS |
| 340 | if (ps >= 2) | 383 | if (ps >= 2) |
| 341 | status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0 | 384 | status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0 |
| 342 | ,tty_orig,12,0,0,0,0); | 385 | ,tty_orig,12,0,0,0,0); |
| 343 | #endif | 386 | #endif |
| 344 | 387 | ||
| 345 | if (ps >= 1) popsig(); | 388 | if (ps >= 1) popsig(); |
| 346 | if (stdin != tty) fclose(tty); | 389 | if (stdin != tty) fclose(tty); |
| 347 | #ifdef VMS | 390 | #ifdef OPENSSL_SYS_VMS |
| 348 | status = SYS$DASSGN(channel); | 391 | status = sys$dassgn(channel); |
| 349 | #endif | 392 | #endif |
| 350 | return(!ok); | 393 | return(!ok); |
| 351 | } | 394 | } |
| 352 | 395 | ||
| 353 | #else /* WIN16 */ | 396 | #else /* OPENSSL_SYS_WIN16 */ |
| 354 | 397 | ||
| 355 | int des_read_pw(buf, buff, size, prompt, verify) | 398 | int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify) |
| 356 | char *buf; | ||
| 357 | char *buff; | ||
| 358 | int size; | ||
| 359 | char *prompt; | ||
| 360 | int verify; | ||
| 361 | { | 399 | { |
| 362 | memset(buf,0,size); | 400 | memset(buf,0,size); |
| 363 | memset(buff,0,size); | 401 | memset(buff,0,size); |
| @@ -366,9 +404,15 @@ int verify; | |||
| 366 | 404 | ||
| 367 | #endif | 405 | #endif |
| 368 | 406 | ||
| 369 | static void pushsig() | 407 | static void pushsig(void) |
| 370 | { | 408 | { |
| 371 | int i; | 409 | int i; |
| 410 | #ifdef SIGACTION | ||
| 411 | struct sigaction sa; | ||
| 412 | |||
| 413 | memset(&sa,0,sizeof sa); | ||
| 414 | sa.sa_handler=recsig; | ||
| 415 | #endif | ||
| 372 | 416 | ||
| 373 | for (i=1; i<NX509_SIG; i++) | 417 | for (i=1; i<NX509_SIG; i++) |
| 374 | { | 418 | { |
| @@ -381,7 +425,7 @@ static void pushsig() | |||
| 381 | continue; | 425 | continue; |
| 382 | #endif | 426 | #endif |
| 383 | #ifdef SIGACTION | 427 | #ifdef SIGACTION |
| 384 | sigaction(i,NULL,&savsig[i]); | 428 | sigaction(i,&sa,&savsig[i]); |
| 385 | #else | 429 | #else |
| 386 | savsig[i]=signal(i,recsig); | 430 | savsig[i]=signal(i,recsig); |
| 387 | #endif | 431 | #endif |
| @@ -392,7 +436,7 @@ static void pushsig() | |||
| 392 | #endif | 436 | #endif |
| 393 | } | 437 | } |
| 394 | 438 | ||
| 395 | static void popsig() | 439 | static void popsig(void) |
| 396 | { | 440 | { |
| 397 | int i; | 441 | int i; |
| 398 | 442 | ||
| @@ -414,8 +458,7 @@ static void popsig() | |||
| 414 | } | 458 | } |
| 415 | } | 459 | } |
| 416 | 460 | ||
| 417 | static void recsig(i) | 461 | static void recsig(int i) |
| 418 | int i; | ||
| 419 | { | 462 | { |
| 420 | longjmp(save,1); | 463 | longjmp(save,1); |
| 421 | #ifdef LINT | 464 | #ifdef LINT |
| @@ -423,11 +466,8 @@ int i; | |||
| 423 | #endif | 466 | #endif |
| 424 | } | 467 | } |
| 425 | 468 | ||
| 426 | #if defined(MSDOS) && !defined(WIN16) | 469 | #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) |
| 427 | static int noecho_fgets(buf,size,tty) | 470 | static int noecho_fgets(char *buf, int size, FILE *tty) |
| 428 | char *buf; | ||
| 429 | int size; | ||
| 430 | FILE *tty; | ||
| 431 | { | 471 | { |
| 432 | int i; | 472 | int i; |
| 433 | char *p; | 473 | char *p; |
| @@ -454,6 +494,18 @@ FILE *tty; | |||
| 454 | break; | 494 | break; |
| 455 | } | 495 | } |
| 456 | } | 496 | } |
| 497 | #ifdef WIN_CONSOLE_BUG | ||
| 498 | /* Win95 has several evil console bugs: one of these is that the | ||
| 499 | * last character read using getch() is passed to the next read: this is | ||
| 500 | * usually a CR so this can be trouble. No STDIO fix seems to work but | ||
| 501 | * flushing the console appears to do the trick. | ||
| 502 | */ | ||
| 503 | { | ||
| 504 | HANDLE inh; | ||
| 505 | inh = GetStdHandle(STD_INPUT_HANDLE); | ||
| 506 | FlushConsoleInputBuffer(inh); | ||
| 507 | } | ||
| 508 | #endif | ||
| 457 | return(strlen(buf)); | 509 | return(strlen(buf)); |
| 458 | } | 510 | } |
| 459 | #endif | 511 | #endif |
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c index 7c1da1f538..d937d08da5 100644 --- a/src/lib/libcrypto/des/rpc_enc.c +++ b/src/lib/libcrypto/des/rpc_enc.c | |||
| @@ -60,32 +60,23 @@ | |||
| 60 | #include "des_locl.h" | 60 | #include "des_locl.h" |
| 61 | #include "des_ver.h" | 61 | #include "des_ver.h" |
| 62 | 62 | ||
| 63 | #ifndef NOPROTO | ||
| 64 | int _des_crypt(char *buf,int len,struct desparams *desp); | 63 | int _des_crypt(char *buf,int len,struct desparams *desp); |
| 65 | #else | 64 | int _des_crypt(char *buf, int len, struct desparams *desp) |
| 66 | int _des_crypt(); | ||
| 67 | #endif | ||
| 68 | |||
| 69 | int _des_crypt(buf, len, desp) | ||
| 70 | char *buf; | ||
| 71 | int len; | ||
| 72 | struct desparams *desp; | ||
| 73 | { | 65 | { |
| 74 | des_key_schedule ks; | 66 | DES_key_schedule ks; |
| 75 | int enc; | 67 | int enc; |
| 76 | 68 | ||
| 77 | des_set_key((des_cblock *)desp->des_key,ks); | 69 | DES_set_key_unchecked(&desp->des_key,&ks); |
| 78 | enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; | 70 | enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; |
| 79 | 71 | ||
| 80 | if (desp->des_mode == CBC) | 72 | if (desp->des_mode == CBC) |
| 81 | des_ecb_encrypt((des_cblock *)desp->UDES.UDES_buf, | 73 | DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf, |
| 82 | (des_cblock *)desp->UDES.UDES_buf,ks,enc); | 74 | (DES_cblock *)desp->UDES.UDES_buf,&ks, |
| 75 | enc); | ||
| 83 | else | 76 | else |
| 84 | { | 77 | { |
| 85 | des_ncbc_encrypt((des_cblock *)desp->UDES.UDES_buf, | 78 | DES_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf, |
| 86 | (des_cblock *)desp->UDES.UDES_buf, | 79 | len,&ks,&desp->des_ivec,enc); |
| 87 | (long)len,ks, | ||
| 88 | (des_cblock *)desp->des_ivec,enc); | ||
| 89 | #ifdef undef | 80 | #ifdef undef |
| 90 | /* len will always be %8 if called from common_crypt | 81 | /* len will always be %8 if called from common_crypt |
| 91 | * in secure_rpc. | 82 | * in secure_rpc. |
diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c index 6447ed9cf0..8a9473c4f9 100644 --- a/src/lib/libcrypto/des/rpw.c +++ b/src/lib/libcrypto/des/rpw.c | |||
| @@ -57,17 +57,15 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "des.h" | 60 | #include <openssl/des.h> |
| 61 | 61 | ||
| 62 | int main(argc,argv) | 62 | int main(int argc, char *argv[]) |
| 63 | int argc; | ||
| 64 | char *argv[]; | ||
| 65 | { | 63 | { |
| 66 | des_cblock k,k1; | 64 | DES_cblock k,k1; |
| 67 | int i; | 65 | int i; |
| 68 | 66 | ||
| 69 | printf("read passwd\n"); | 67 | printf("read passwd\n"); |
| 70 | if ((i=des_read_password((C_Block *)k,"Enter password:",0)) == 0) | 68 | if ((i=des_read_password(&k,"Enter password:",0)) == 0) |
| 71 | { | 69 | { |
| 72 | printf("password = "); | 70 | printf("password = "); |
| 73 | for (i=0; i<8; i++) | 71 | for (i=0; i<8; i++) |
| @@ -77,7 +75,7 @@ char *argv[]; | |||
| 77 | printf("error %d\n",i); | 75 | printf("error %d\n",i); |
| 78 | printf("\n"); | 76 | printf("\n"); |
| 79 | printf("read 2passwds and verify\n"); | 77 | printf("read 2passwds and verify\n"); |
| 80 | if ((i=des_read_2passwords((C_Block *)k,(C_Block *)k1, | 78 | if ((i=des_read_2passwords(&k,&k1, |
| 81 | "Enter verified password:",1)) == 0) | 79 | "Enter verified password:",1)) == 0) |
| 82 | { | 80 | { |
| 83 | printf("password1 = "); | 81 | printf("password1 = "); |
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c index 5bbe8b01d6..48fc1d49fc 100644 --- a/src/lib/libcrypto/des/speed.c +++ b/src/lib/libcrypto/des/speed.c | |||
| @@ -59,19 +59,17 @@ | |||
| 59 | /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ | 59 | /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ |
| 60 | /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ | 60 | /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ |
| 61 | 61 | ||
| 62 | #ifndef MSDOS | 62 | #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) |
| 63 | #define TIMES | 63 | #define TIMES |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #include <stdio.h> | 66 | #include <stdio.h> |
| 67 | #ifndef MSDOS | 67 | |
| 68 | #include <unistd.h> | 68 | #include <openssl/e_os2.h> |
| 69 | #else | 69 | #include OPENSSL_UNISTD_IO |
| 70 | #include <io.h> | 70 | OPENSSL_DECLARE_EXIT |
| 71 | extern int exit(); | 71 | |
| 72 | #endif | ||
| 73 | #include <signal.h> | 72 | #include <signal.h> |
| 74 | #ifndef VMS | ||
| 75 | #ifndef _IRIX | 73 | #ifndef _IRIX |
| 76 | #include <time.h> | 74 | #include <time.h> |
| 77 | #endif | 75 | #endif |
| @@ -79,35 +77,32 @@ extern int exit(); | |||
| 79 | #include <sys/types.h> | 77 | #include <sys/types.h> |
| 80 | #include <sys/times.h> | 78 | #include <sys/times.h> |
| 81 | #endif | 79 | #endif |
| 82 | #else /* VMS */ | 80 | |
| 83 | #include <types.h> | 81 | /* Depending on the VMS version, the tms structure is perhaps defined. |
| 84 | struct tms { | 82 | The __TMS macro will show if it was. If it wasn't defined, we should |
| 85 | time_t tms_utime; | 83 | undefine TIMES, since that tells the rest of the program how things |
| 86 | time_t tms_stime; | 84 | should be handled. -- Richard Levitte */ |
| 87 | time_t tms_uchild; /* I dunno... */ | 85 | #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) |
| 88 | time_t tms_uchildsys; /* so these names are a guess :-) */ | 86 | #undef TIMES |
| 89 | } | ||
| 90 | #endif | 87 | #endif |
| 88 | |||
| 91 | #ifndef TIMES | 89 | #ifndef TIMES |
| 92 | #include <sys/timeb.h> | 90 | #include <sys/timeb.h> |
| 93 | #endif | 91 | #endif |
| 94 | 92 | ||
| 95 | #ifdef sun | 93 | #if defined(sun) || defined(__ultrix) |
| 94 | #define _POSIX_SOURCE | ||
| 96 | #include <limits.h> | 95 | #include <limits.h> |
| 97 | #include <sys/param.h> | 96 | #include <sys/param.h> |
| 98 | #endif | 97 | #endif |
| 99 | 98 | ||
| 100 | #include "des.h" | 99 | #include <openssl/des.h> |
| 101 | 100 | ||
| 102 | /* The following if from times(3) man page. It may need to be changed */ | 101 | /* The following if from times(3) man page. It may need to be changed */ |
| 103 | #ifndef HZ | 102 | #ifndef HZ |
| 104 | # ifndef CLK_TCK | 103 | # ifndef CLK_TCK |
| 105 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ | 104 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ |
| 106 | # ifndef VMS | 105 | # define HZ 100.0 |
| 107 | # define HZ 100.0 | ||
| 108 | # else /* VMS */ | ||
| 109 | # define HZ 100.0 | ||
| 110 | # endif | ||
| 111 | # else /* _BSD_CLK_TCK_ */ | 106 | # else /* _BSD_CLK_TCK_ */ |
| 112 | # define HZ ((double)_BSD_CLK_TCK_) | 107 | # define HZ ((double)_BSD_CLK_TCK_) |
| 113 | # endif | 108 | # endif |
| @@ -119,12 +114,7 @@ struct tms { | |||
| 119 | #define BUFSIZE ((long)1024) | 114 | #define BUFSIZE ((long)1024) |
| 120 | long run=0; | 115 | long run=0; |
| 121 | 116 | ||
| 122 | #ifndef NOPROTO | ||
| 123 | double Time_F(int s); | 117 | double Time_F(int s); |
| 124 | #else | ||
| 125 | double Time_F(); | ||
| 126 | #endif | ||
| 127 | |||
| 128 | #ifdef SIGALRM | 118 | #ifdef SIGALRM |
| 129 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) | 119 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) |
| 130 | #define SIGRETTYPE void | 120 | #define SIGRETTYPE void |
| @@ -132,14 +122,8 @@ double Time_F(); | |||
| 132 | #define SIGRETTYPE int | 122 | #define SIGRETTYPE int |
| 133 | #endif | 123 | #endif |
| 134 | 124 | ||
| 135 | #ifndef NOPROTO | ||
| 136 | SIGRETTYPE sig_done(int sig); | 125 | SIGRETTYPE sig_done(int sig); |
| 137 | #else | 126 | SIGRETTYPE sig_done(int sig) |
| 138 | SIGRETTYPE sig_done(); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | SIGRETTYPE sig_done(sig) | ||
| 142 | int sig; | ||
| 143 | { | 127 | { |
| 144 | signal(SIGALRM,sig_done); | 128 | signal(SIGALRM,sig_done); |
| 145 | run=0; | 129 | run=0; |
| @@ -152,8 +136,7 @@ int sig; | |||
| 152 | #define START 0 | 136 | #define START 0 |
| 153 | #define STOP 1 | 137 | #define STOP 1 |
| 154 | 138 | ||
| 155 | double Time_F(s) | 139 | double Time_F(int s) |
| 156 | int s; | ||
| 157 | { | 140 | { |
| 158 | double ret; | 141 | double ret; |
| 159 | #ifdef TIMES | 142 | #ifdef TIMES |
| @@ -189,32 +172,30 @@ int s; | |||
| 189 | #endif | 172 | #endif |
| 190 | } | 173 | } |
| 191 | 174 | ||
| 192 | int main(argc,argv) | 175 | int main(int argc, char **argv) |
| 193 | int argc; | ||
| 194 | char **argv; | ||
| 195 | { | 176 | { |
| 196 | long count; | 177 | long count; |
| 197 | static unsigned char buf[BUFSIZE]; | 178 | static unsigned char buf[BUFSIZE]; |
| 198 | static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; | 179 | static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; |
| 199 | static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; | 180 | static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; |
| 200 | static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; | 181 | static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; |
| 201 | des_key_schedule sch,sch2,sch3; | 182 | DES_key_schedule sch,sch2,sch3; |
| 202 | double a,b,c,d,e; | 183 | double a,b,c,d,e; |
| 203 | #ifndef SIGALRM | 184 | #ifndef SIGALRM |
| 204 | long ca,cb,cc,cd,ce; | 185 | long ca,cb,cc,cd,ce; |
| 205 | #endif | 186 | #endif |
| 206 | 187 | ||
| 207 | #ifndef TIMES | 188 | #ifndef TIMES |
| 208 | printf("To get the most acurate results, try to run this\n"); | 189 | printf("To get the most accurate results, try to run this\n"); |
| 209 | printf("program when this computer is idle.\n"); | 190 | printf("program when this computer is idle.\n"); |
| 210 | #endif | 191 | #endif |
| 211 | 192 | ||
| 212 | des_set_key((C_Block *)key2,sch2); | 193 | DES_set_key_unchecked(&key2,&sch2); |
| 213 | des_set_key((C_Block *)key3,sch3); | 194 | DES_set_key_unchecked(&key3,&sch3); |
| 214 | 195 | ||
| 215 | #ifndef SIGALRM | 196 | #ifndef SIGALRM |
| 216 | printf("First we calculate the approximate speed ...\n"); | 197 | printf("First we calculate the approximate speed ...\n"); |
| 217 | des_set_key((C_Block *)key,sch); | 198 | DES_set_key_unchecked(&key,&sch); |
| 218 | count=10; | 199 | count=10; |
| 219 | do { | 200 | do { |
| 220 | long i; | 201 | long i; |
| @@ -223,7 +204,7 @@ char **argv; | |||
| 223 | count*=2; | 204 | count*=2; |
| 224 | Time_F(START); | 205 | Time_F(START); |
| 225 | for (i=count; i; i--) | 206 | for (i=count; i; i--) |
| 226 | des_encrypt(data,&(sch[0]),DES_ENCRYPT); | 207 | DES_encrypt1(data,&sch,DES_ENCRYPT); |
| 227 | d=Time_F(STOP); | 208 | d=Time_F(STOP); |
| 228 | } while (d < 3.0); | 209 | } while (d < 3.0); |
| 229 | ca=count; | 210 | ca=count; |
| @@ -244,63 +225,63 @@ char **argv; | |||
| 244 | 225 | ||
| 245 | Time_F(START); | 226 | Time_F(START); |
| 246 | for (count=0,run=1; COND(ca); count++) | 227 | for (count=0,run=1; COND(ca); count++) |
| 247 | des_set_key((C_Block *)key,sch); | 228 | DES_set_key_unchecked(&key,&sch); |
| 248 | d=Time_F(STOP); | 229 | d=Time_F(STOP); |
| 249 | printf("%ld set_key's in %.2f seconds\n",count,d); | 230 | printf("%ld set_key's in %.2f seconds\n",count,d); |
| 250 | a=((double)COUNT(ca))/d; | 231 | a=((double)COUNT(ca))/d; |
| 251 | 232 | ||
| 252 | #ifdef SIGALRM | 233 | #ifdef SIGALRM |
| 253 | printf("Doing des_encrypt's for 10 seconds\n"); | 234 | printf("Doing DES_encrypt's for 10 seconds\n"); |
| 254 | alarm(10); | 235 | alarm(10); |
| 255 | #else | 236 | #else |
| 256 | printf("Doing des_encrypt %ld times\n",cb); | 237 | printf("Doing DES_encrypt %ld times\n",cb); |
| 257 | #endif | 238 | #endif |
| 258 | Time_F(START); | 239 | Time_F(START); |
| 259 | for (count=0,run=1; COND(cb); count++) | 240 | for (count=0,run=1; COND(cb); count++) |
| 260 | { | 241 | { |
| 261 | DES_LONG data[2]; | 242 | DES_LONG data[2]; |
| 262 | 243 | ||
| 263 | des_encrypt(data,&(sch[0]),DES_ENCRYPT); | 244 | DES_encrypt1(data,&sch,DES_ENCRYPT); |
| 264 | } | 245 | } |
| 265 | d=Time_F(STOP); | 246 | d=Time_F(STOP); |
| 266 | printf("%ld des_encrypt's in %.2f second\n",count,d); | 247 | printf("%ld DES_encrypt's in %.2f second\n",count,d); |
| 267 | b=((double)COUNT(cb)*8)/d; | 248 | b=((double)COUNT(cb)*8)/d; |
| 268 | 249 | ||
| 269 | #ifdef SIGALRM | 250 | #ifdef SIGALRM |
| 270 | printf("Doing des_cbc_encrypt on %ld byte blocks for 10 seconds\n", | 251 | printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n", |
| 271 | BUFSIZE); | 252 | BUFSIZE); |
| 272 | alarm(10); | 253 | alarm(10); |
| 273 | #else | 254 | #else |
| 274 | printf("Doing des_cbc_encrypt %ld times on %ld byte blocks\n",cc, | 255 | printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc, |
| 275 | BUFSIZE); | 256 | BUFSIZE); |
| 276 | #endif | 257 | #endif |
| 277 | Time_F(START); | 258 | Time_F(START); |
| 278 | for (count=0,run=1; COND(cc); count++) | 259 | for (count=0,run=1; COND(cc); count++) |
| 279 | des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]), | 260 | DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch, |
| 280 | (C_Block *)&(key[0]),DES_ENCRYPT); | 261 | &key,DES_ENCRYPT); |
| 281 | d=Time_F(STOP); | 262 | d=Time_F(STOP); |
| 282 | printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", | 263 | printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n", |
| 283 | count,BUFSIZE,d); | 264 | count,BUFSIZE,d); |
| 284 | c=((double)COUNT(cc)*BUFSIZE)/d; | 265 | c=((double)COUNT(cc)*BUFSIZE)/d; |
| 285 | 266 | ||
| 286 | #ifdef SIGALRM | 267 | #ifdef SIGALRM |
| 287 | printf("Doing des_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", | 268 | printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", |
| 288 | BUFSIZE); | 269 | BUFSIZE); |
| 289 | alarm(10); | 270 | alarm(10); |
| 290 | #else | 271 | #else |
| 291 | printf("Doing des_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, | 272 | printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, |
| 292 | BUFSIZE); | 273 | BUFSIZE); |
| 293 | #endif | 274 | #endif |
| 294 | Time_F(START); | 275 | Time_F(START); |
| 295 | for (count=0,run=1; COND(cd); count++) | 276 | for (count=0,run=1; COND(cd); count++) |
| 296 | des_ede3_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE, | 277 | DES_ede3_cbc_encrypt(buf,buf,BUFSIZE, |
| 297 | &(sch[0]), | 278 | &sch, |
| 298 | &(sch2[0]), | 279 | &sch2, |
| 299 | &(sch3[0]), | 280 | &sch3, |
| 300 | (C_Block *)&(key[0]), | 281 | &key, |
| 301 | DES_ENCRYPT); | 282 | DES_ENCRYPT); |
| 302 | d=Time_F(STOP); | 283 | d=Time_F(STOP); |
| 303 | printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", | 284 | printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", |
| 304 | count,BUFSIZE,d); | 285 | count,BUFSIZE,d); |
| 305 | d=((double)COUNT(cd)*BUFSIZE)/d; | 286 | d=((double)COUNT(cd)*BUFSIZE)/d; |
| 306 | 287 | ||
| @@ -323,7 +304,7 @@ char **argv; | |||
| 323 | printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); | 304 | printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); |
| 324 | printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e); | 305 | printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e); |
| 325 | exit(0); | 306 | exit(0); |
| 326 | #if defined(LINT) || defined(MSDOS) | 307 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) |
| 327 | return(0); | 308 | return(0); |
| 328 | #endif | 309 | #endif |
| 329 | } | 310 | } |
