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/cast | |
| 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/cast')
| -rw-r--r-- | src/lib/libcrypto/cast/cast_spd.c | 63 | ||||
| -rw-r--r-- | src/lib/libcrypto/cast/castopts.c | 65 | ||||
| -rw-r--r-- | src/lib/libcrypto/cast/casts.cpp | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/cast/casttest.c | 199 |
4 files changed, 149 insertions, 180 deletions
diff --git a/src/lib/libcrypto/cast/cast_spd.c b/src/lib/libcrypto/cast/cast_spd.c index ab75e65386..76abf50d98 100644 --- a/src/lib/libcrypto/cast/cast_spd.c +++ b/src/lib/libcrypto/cast/cast_spd.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,34 +77,31 @@ 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 "cast.h" | 99 | #include <openssl/cast.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 VMS | ||
| 106 | #define HZ 100.0 | ||
| 107 | #else /* VMS */ | ||
| 108 | #define HZ 100.0 | 104 | #define HZ 100.0 |
| 109 | #endif | ||
| 110 | #else /* CLK_TCK */ | 105 | #else /* CLK_TCK */ |
| 111 | #define HZ ((double)CLK_TCK) | 106 | #define HZ ((double)CLK_TCK) |
| 112 | #endif | 107 | #endif |
| @@ -115,12 +110,7 @@ struct tms { | |||
| 115 | #define BUFSIZE ((long)1024) | 110 | #define BUFSIZE ((long)1024) |
| 116 | long run=0; | 111 | long run=0; |
| 117 | 112 | ||
| 118 | #ifndef NOPROTO | ||
| 119 | double Time_F(int s); | 113 | double Time_F(int s); |
| 120 | #else | ||
| 121 | double Time_F(); | ||
| 122 | #endif | ||
| 123 | |||
| 124 | #ifdef SIGALRM | 114 | #ifdef SIGALRM |
| 125 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) | 115 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) |
| 126 | #define SIGRETTYPE void | 116 | #define SIGRETTYPE void |
| @@ -128,14 +118,8 @@ double Time_F(); | |||
| 128 | #define SIGRETTYPE int | 118 | #define SIGRETTYPE int |
| 129 | #endif | 119 | #endif |
| 130 | 120 | ||
| 131 | #ifndef NOPROTO | ||
| 132 | SIGRETTYPE sig_done(int sig); | 121 | SIGRETTYPE sig_done(int sig); |
| 133 | #else | 122 | SIGRETTYPE sig_done(int sig) |
| 134 | SIGRETTYPE sig_done(); | ||
| 135 | #endif | ||
| 136 | |||
| 137 | SIGRETTYPE sig_done(sig) | ||
| 138 | int sig; | ||
| 139 | { | 123 | { |
| 140 | signal(SIGALRM,sig_done); | 124 | signal(SIGALRM,sig_done); |
| 141 | run=0; | 125 | run=0; |
| @@ -148,8 +132,7 @@ int sig; | |||
| 148 | #define START 0 | 132 | #define START 0 |
| 149 | #define STOP 1 | 133 | #define STOP 1 |
| 150 | 134 | ||
| 151 | double Time_F(s) | 135 | double Time_F(int s) |
| 152 | int s; | ||
| 153 | { | 136 | { |
| 154 | double ret; | 137 | double ret; |
| 155 | #ifdef TIMES | 138 | #ifdef TIMES |
| @@ -185,9 +168,7 @@ int s; | |||
| 185 | #endif | 168 | #endif |
| 186 | } | 169 | } |
| 187 | 170 | ||
| 188 | int main(argc,argv) | 171 | int main(int argc, char **argv) |
| 189 | int argc; | ||
| 190 | char **argv; | ||
| 191 | { | 172 | { |
| 192 | long count; | 173 | long count; |
| 193 | static unsigned char buf[BUFSIZE]; | 174 | static unsigned char buf[BUFSIZE]; |
| @@ -202,7 +183,7 @@ char **argv; | |||
| 202 | #endif | 183 | #endif |
| 203 | 184 | ||
| 204 | #ifndef TIMES | 185 | #ifndef TIMES |
| 205 | printf("To get the most acurate results, try to run this\n"); | 186 | printf("To get the most accurate results, try to run this\n"); |
| 206 | printf("program when this computer is idle.\n"); | 187 | printf("program when this computer is idle.\n"); |
| 207 | #endif | 188 | #endif |
| 208 | 189 | ||
| @@ -287,7 +268,7 @@ char **argv; | |||
| 287 | printf("CAST raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); | 268 | printf("CAST raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); |
| 288 | printf("CAST cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c); | 269 | printf("CAST cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c); |
| 289 | exit(0); | 270 | exit(0); |
| 290 | #if defined(LINT) || defined(MSDOS) | 271 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) |
| 291 | return(0); | 272 | return(0); |
| 292 | #endif | 273 | #endif |
| 293 | } | 274 | } |
diff --git a/src/lib/libcrypto/cast/castopts.c b/src/lib/libcrypto/cast/castopts.c index 68cf5a4a60..1b858d153b 100644 --- a/src/lib/libcrypto/cast/castopts.c +++ b/src/lib/libcrypto/cast/castopts.c | |||
| @@ -59,19 +59,17 @@ | |||
| 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)) |
| 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 void 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,25 +77,26 @@ extern void 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 "cast.h" | 99 | #include <openssl/cast.h> |
| 101 | 100 | ||
| 102 | #define CAST_DEFAULT_OPTIONS | 101 | #define CAST_DEFAULT_OPTIONS |
| 103 | 102 | ||
| @@ -136,11 +135,7 @@ struct tms { | |||
| 136 | #ifndef HZ | 135 | #ifndef HZ |
| 137 | # ifndef CLK_TCK | 136 | # ifndef CLK_TCK |
| 138 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ | 137 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ |
| 139 | # ifndef VMS | 138 | # define HZ 100.0 |
| 140 | # define HZ 100.0 | ||
| 141 | # else /* VMS */ | ||
| 142 | # define HZ 100.0 | ||
| 143 | # endif | ||
| 144 | # else /* _BSD_CLK_TCK_ */ | 139 | # else /* _BSD_CLK_TCK_ */ |
| 145 | # define HZ ((double)_BSD_CLK_TCK_) | 140 | # define HZ ((double)_BSD_CLK_TCK_) |
| 146 | # endif | 141 | # endif |
| @@ -152,12 +147,7 @@ struct tms { | |||
| 152 | #define BUFSIZE ((long)1024) | 147 | #define BUFSIZE ((long)1024) |
| 153 | long run=0; | 148 | long run=0; |
| 154 | 149 | ||
| 155 | #ifndef NOPROTO | ||
| 156 | double Time_F(int s); | 150 | double Time_F(int s); |
| 157 | #else | ||
| 158 | double Time_F(); | ||
| 159 | #endif | ||
| 160 | |||
| 161 | #ifdef SIGALRM | 151 | #ifdef SIGALRM |
| 162 | #if defined(__STDC__) || defined(sgi) | 152 | #if defined(__STDC__) || defined(sgi) |
| 163 | #define SIGRETTYPE void | 153 | #define SIGRETTYPE void |
| @@ -165,14 +155,8 @@ double Time_F(); | |||
| 165 | #define SIGRETTYPE int | 155 | #define SIGRETTYPE int |
| 166 | #endif | 156 | #endif |
| 167 | 157 | ||
| 168 | #ifndef NOPROTO | ||
| 169 | SIGRETTYPE sig_done(int sig); | 158 | SIGRETTYPE sig_done(int sig); |
| 170 | #else | 159 | SIGRETTYPE sig_done(int sig) |
| 171 | SIGRETTYPE sig_done(); | ||
| 172 | #endif | ||
| 173 | |||
| 174 | SIGRETTYPE sig_done(sig) | ||
| 175 | int sig; | ||
| 176 | { | 160 | { |
| 177 | signal(SIGALRM,sig_done); | 161 | signal(SIGALRM,sig_done); |
| 178 | run=0; | 162 | run=0; |
| @@ -185,8 +169,7 @@ int sig; | |||
| 185 | #define START 0 | 169 | #define START 0 |
| 186 | #define STOP 1 | 170 | #define STOP 1 |
| 187 | 171 | ||
| 188 | double Time_F(s) | 172 | double Time_F(int s) |
| 189 | int s; | ||
| 190 | { | 173 | { |
| 191 | double ret; | 174 | double ret; |
| 192 | #ifdef TIMES | 175 | #ifdef TIMES |
| @@ -247,9 +230,7 @@ int s; | |||
| 247 | fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ | 230 | fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ |
| 248 | tm[index]*8,1.0e6/tm[index]); | 231 | tm[index]*8,1.0e6/tm[index]); |
| 249 | 232 | ||
| 250 | int main(argc,argv) | 233 | int main(int argc, char **argv) |
| 251 | int argc; | ||
| 252 | char **argv; | ||
| 253 | { | 234 | { |
| 254 | long count; | 235 | long count; |
| 255 | static unsigned char buf[BUFSIZE]; | 236 | static unsigned char buf[BUFSIZE]; |
| @@ -271,7 +252,7 @@ char **argv; | |||
| 271 | } | 252 | } |
| 272 | 253 | ||
| 273 | #ifndef TIMES | 254 | #ifndef TIMES |
| 274 | fprintf(stderr,"To get the most acurate results, try to run this\n"); | 255 | fprintf(stderr,"To get the most accurate results, try to run this\n"); |
| 275 | fprintf(stderr,"program when this computer is idle.\n"); | 256 | fprintf(stderr,"program when this computer is idle.\n"); |
| 276 | #endif | 257 | #endif |
| 277 | 258 | ||
| @@ -351,7 +332,7 @@ char **argv; | |||
| 351 | break; | 332 | break; |
| 352 | } | 333 | } |
| 353 | exit(0); | 334 | exit(0); |
| 354 | #if defined(LINT) || defined(MSDOS) | 335 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) |
| 355 | return(0); | 336 | return(0); |
| 356 | #endif | 337 | #endif |
| 357 | } | 338 | } |
diff --git a/src/lib/libcrypto/cast/casts.cpp b/src/lib/libcrypto/cast/casts.cpp index bac7be2c9c..8d7bd468d2 100644 --- a/src/lib/libcrypto/cast/casts.cpp +++ b/src/lib/libcrypto/cast/casts.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 "cast.h" | 35 | #include <openssl/cast.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/cast/casttest.c b/src/lib/libcrypto/cast/casttest.c index 8b009bc249..099e790886 100644 --- a/src/lib/libcrypto/cast/casttest.c +++ b/src/lib/libcrypto/cast/casttest.c | |||
| @@ -59,36 +59,44 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
| 62 | #include "cast.h" | ||
| 63 | 62 | ||
| 64 | /* #define FULL_TEST */ | 63 | #ifdef OPENSSL_NO_CAST |
| 64 | int main(int argc, char *argv[]) | ||
| 65 | { | ||
| 66 | printf("No CAST support\n"); | ||
| 67 | return(0); | ||
| 68 | } | ||
| 69 | #else | ||
| 70 | #include <openssl/cast.h> | ||
| 65 | 71 | ||
| 66 | unsigned char k[16]={ | 72 | #define FULL_TEST |
| 73 | |||
| 74 | static unsigned char k[16]={ | ||
| 67 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, | 75 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, |
| 68 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A | 76 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A |
| 69 | }; | 77 | }; |
| 70 | 78 | ||
| 71 | unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; | 79 | static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; |
| 72 | 80 | ||
| 73 | int k_len[3]={16,10}; | 81 | static int k_len[3]={16,10,5}; |
| 74 | unsigned char c[3][8]={ | 82 | static unsigned char c[3][8]={ |
| 75 | {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2}, | 83 | {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2}, |
| 76 | {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B}, | 84 | {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B}, |
| 77 | {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}, | 85 | {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}, |
| 78 | }; | 86 | }; |
| 79 | unsigned char out[80]; | 87 | static unsigned char out[80]; |
| 80 | 88 | ||
| 81 | unsigned char in_a[16]={ | 89 | static unsigned char in_a[16]={ |
| 82 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, | 90 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, |
| 83 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; | 91 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; |
| 84 | unsigned char in_b[16]={ | 92 | static unsigned char in_b[16]={ |
| 85 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, | 93 | 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, |
| 86 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; | 94 | 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; |
| 87 | 95 | ||
| 88 | unsigned char c_a[16]={ | 96 | static unsigned char c_a[16]={ |
| 89 | 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6, | 97 | 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6, |
| 90 | 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92}; | 98 | 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92}; |
| 91 | unsigned char c_b[16]={ | 99 | static unsigned char c_b[16]={ |
| 92 | 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71, | 100 | 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71, |
| 93 | 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E}; | 101 | 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E}; |
| 94 | 102 | ||
| @@ -120,104 +128,103 @@ static unsigned char cfb_cipher64[CFB_TEST_SIZE]={ | |||
| 120 | }; | 128 | }; |
| 121 | #endif | 129 | #endif |
| 122 | 130 | ||
| 123 | int main(argc,argv) | 131 | int main(int argc, char *argv[]) |
| 124 | int argc; | 132 | { |
| 125 | char *argv[]; | ||
| 126 | { | ||
| 127 | #ifdef FULL_TEST | 133 | #ifdef FULL_TEST |
| 128 | long l; | 134 | long l; |
| 129 | CAST_KEY key_b; | 135 | CAST_KEY key_b; |
| 130 | #endif | 136 | #endif |
| 131 | int i,z,err=0; | 137 | int i,z,err=0; |
| 132 | CAST_KEY key; | 138 | CAST_KEY key; |
| 133 | 139 | ||
| 134 | for (z=0; z<1; z++) | 140 | for (z=0; z<3; z++) |
| 135 | { | 141 | { |
| 136 | CAST_set_key(&key,k_len[z],k); | 142 | CAST_set_key(&key,k_len[z],k); |
| 137 | 143 | ||
| 138 | CAST_ecb_encrypt(in,out,&key,CAST_ENCRYPT); | 144 | CAST_ecb_encrypt(in,out,&key,CAST_ENCRYPT); |
| 139 | if (memcmp(out,&(c[z][0]),8) != 0) | 145 | if (memcmp(out,&(c[z][0]),8) != 0) |
| 140 | { | 146 | { |
| 141 | printf("ecb cast error encrypting\n"); | 147 | printf("ecb cast error encrypting for keysize %d\n",k_len[z]*8); |
| 142 | printf("got :"); | 148 | printf("got :"); |
| 143 | for (i=0; i<8; i++) | 149 | for (i=0; i<8; i++) |
| 144 | printf("%02X ",out[i]); | 150 | printf("%02X ",out[i]); |
| 145 | printf("\n"); | 151 | printf("\n"); |
| 146 | printf("expected:"); | 152 | printf("expected:"); |
| 147 | for (i=0; i<8; i++) | 153 | for (i=0; i<8; i++) |
| 148 | printf("%02X ",c[z][i]); | 154 | printf("%02X ",c[z][i]); |
| 149 | err=20; | 155 | err=20; |
| 150 | printf("\n"); | 156 | printf("\n"); |
| 151 | } | 157 | } |
| 152 | 158 | ||
| 153 | CAST_ecb_encrypt(out,out,&key,CAST_DECRYPT); | 159 | CAST_ecb_encrypt(out,out,&key,CAST_DECRYPT); |
| 154 | if (memcmp(out,in,8) != 0) | 160 | if (memcmp(out,in,8) != 0) |
| 155 | { | 161 | { |
| 156 | printf("ecb cast error decrypting\n"); | 162 | printf("ecb cast error decrypting for keysize %d\n",k_len[z]*8); |
| 157 | printf("got :"); | 163 | printf("got :"); |
| 158 | for (i=0; i<8; i++) | 164 | for (i=0; i<8; i++) |
| 159 | printf("%02X ",out[i]); | 165 | printf("%02X ",out[i]); |
| 160 | printf("\n"); | 166 | printf("\n"); |
| 161 | printf("expected:"); | 167 | printf("expected:"); |
| 162 | for (i=0; i<8; i++) | 168 | for (i=0; i<8; i++) |
| 163 | printf("%02X ",in[i]); | 169 | printf("%02X ",in[i]); |
| 164 | printf("\n"); | 170 | printf("\n"); |
| 165 | err=3; | 171 | err=3; |
| 166 | } | 172 | } |
| 167 | } | 173 | } |
| 168 | if (err == 0) printf("ecb cast5 ok\n"); | 174 | if (err == 0) |
| 175 | printf("ecb cast5 ok\n"); | ||
| 169 | 176 | ||
| 170 | #ifdef FULL_TEST | 177 | #ifdef FULL_TEST |
| 171 | { | 178 | { |
| 172 | unsigned char out_a[16],out_b[16]; | 179 | unsigned char out_a[16],out_b[16]; |
| 173 | static char *hex="0123456789ABCDEF"; | 180 | static char *hex="0123456789ABCDEF"; |
| 174 | 181 | ||
| 175 | printf("This test will take some time...."); | 182 | printf("This test will take some time...."); |
| 176 | fflush(stdout); | 183 | fflush(stdout); |
| 177 | memcpy(out_a,in_a,sizeof(in_a)); | 184 | memcpy(out_a,in_a,sizeof(in_a)); |
| 178 | memcpy(out_b,in_b,sizeof(in_b)); | 185 | memcpy(out_b,in_b,sizeof(in_b)); |
| 179 | i=1; | 186 | i=1; |
| 180 | 187 | ||
| 181 | for (l=0; l<1000000L; l++) | 188 | for (l=0; l<1000000L; l++) |
| 182 | { | 189 | { |
| 183 | CAST_set_key(&key_b,16,out_b); | 190 | CAST_set_key(&key_b,16,out_b); |
| 184 | CAST_ecb_encrypt(&(out_a[0]),&(out_a[0]),&key_b,CAST_ENCRYPT); | 191 | CAST_ecb_encrypt(&(out_a[0]),&(out_a[0]),&key_b,CAST_ENCRYPT); |
| 185 | CAST_ecb_encrypt(&(out_a[8]),&(out_a[8]),&key_b,CAST_ENCRYPT); | 192 | CAST_ecb_encrypt(&(out_a[8]),&(out_a[8]),&key_b,CAST_ENCRYPT); |
| 186 | CAST_set_key(&key,16,out_a); | 193 | CAST_set_key(&key,16,out_a); |
| 187 | CAST_ecb_encrypt(&(out_b[0]),&(out_b[0]),&key,CAST_ENCRYPT); | 194 | CAST_ecb_encrypt(&(out_b[0]),&(out_b[0]),&key,CAST_ENCRYPT); |
| 188 | CAST_ecb_encrypt(&(out_b[8]),&(out_b[8]),&key,CAST_ENCRYPT); | 195 | CAST_ecb_encrypt(&(out_b[8]),&(out_b[8]),&key,CAST_ENCRYPT); |
| 189 | if ((l & 0xffff) == 0xffff) | 196 | if ((l & 0xffff) == 0xffff) |
| 190 | { | 197 | { |
| 191 | printf("%c",hex[i&0x0f]); | 198 | printf("%c",hex[i&0x0f]); |
| 192 | fflush(stdout); | 199 | fflush(stdout); |
| 193 | i++; | 200 | i++; |
| 194 | } | 201 | } |
| 195 | } | 202 | } |
| 196 | 203 | ||
| 197 | if ( (memcmp(out_a,c_a,sizeof(c_a)) != 0) || | 204 | if ( (memcmp(out_a,c_a,sizeof(c_a)) != 0) || |
| 198 | (memcmp(out_b,c_b,sizeof(c_b)) != 0)) | 205 | (memcmp(out_b,c_b,sizeof(c_b)) != 0)) |
| 199 | { | 206 | { |
| 200 | printf("\n"); | 207 | printf("\n"); |
| 201 | printf("Error\n"); | 208 | printf("Error\n"); |
| 202 | 209 | ||
| 203 | printf("A out ="); | 210 | printf("A out ="); |
| 204 | for (i=0; i<16; i++) printf("%02X ",out_a[i]); | 211 | for (i=0; i<16; i++) printf("%02X ",out_a[i]); |
| 205 | printf("\nactual="); | 212 | printf("\nactual="); |
| 206 | for (i=0; i<16; i++) printf("%02X ",c_a[i]); | 213 | for (i=0; i<16; i++) printf("%02X ",c_a[i]); |
| 207 | printf("\n"); | 214 | printf("\n"); |
| 208 | 215 | ||
| 209 | printf("B out ="); | 216 | printf("B out ="); |
| 210 | for (i=0; i<16; i++) printf("%02X ",out_b[i]); | 217 | for (i=0; i<16; i++) printf("%02X ",out_b[i]); |
| 211 | printf("\nactual="); | 218 | printf("\nactual="); |
| 212 | for (i=0; i<16; i++) printf("%02X ",c_b[i]); | 219 | for (i=0; i<16; i++) printf("%02X ",c_b[i]); |
| 213 | printf("\n"); | 220 | printf("\n"); |
| 214 | } | 221 | } |
| 215 | else | 222 | else |
| 216 | printf(" ok\n"); | 223 | printf(" ok\n"); |
| 217 | } | 224 | } |
| 218 | #endif | 225 | #endif |
| 219 | 226 | ||
| 220 | exit(err); | 227 | exit(err); |
| 221 | return(err); | 228 | return(err); |
| 222 | } | 229 | } |
| 223 | 230 | #endif | |
