summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/cast
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/cast')
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl51
-rw-r--r--src/lib/libcrypto/cast/Makefile.uni3
-rw-r--r--src/lib/libcrypto/cast/asm/c-win32.asm117
-rw-r--r--src/lib/libcrypto/cast/asm/cast-586.pl267
-rw-r--r--src/lib/libcrypto/cast/asm/cx86unix.cpp1010
-rw-r--r--src/lib/libcrypto/cast/c_cfb64.c25
-rw-r--r--src/lib/libcrypto/cast/c_ecb.c14
-rw-r--r--src/lib/libcrypto/cast/c_enc.c43
-rw-r--r--src/lib/libcrypto/cast/c_ofb64.c16
-rw-r--r--src/lib/libcrypto/cast/c_skey.c11
-rw-r--r--src/lib/libcrypto/cast/cast.h36
-rw-r--r--src/lib/libcrypto/cast/cast_lcl.h20
-rw-r--r--src/lib/libcrypto/cast/cast_s.h16
-rw-r--r--src/lib/libcrypto/cast/cast_spd.c59
-rw-r--r--src/lib/libcrypto/cast/castopts.c61
-rw-r--r--src/lib/libcrypto/cast/casts.cpp2
-rw-r--r--src/lib/libcrypto/cast/casttest.c183
17 files changed, 457 insertions, 1477 deletions
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
index 0143827ae5..cc040576ae 100644
--- a/src/lib/libcrypto/cast/Makefile.ssl
+++ b/src/lib/libcrypto/cast/Makefile.ssl
@@ -8,9 +8,11 @@ CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= 9INCLUDES=
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
11INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
14MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
15AR= ar r 17AR= ar r
16 18
@@ -45,7 +47,7 @@ all: lib
45 47
46lib: $(LIBOBJ) 48lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ) 49 $(AR) $(LIB) $(LIBOBJ)
48 sh $(TOP)/util/ranlib.sh $(LIB) 50 $(RANLIB) $(LIB)
49 @touch lib 51 @touch lib
50 52
51# elf 53# elf
@@ -64,26 +66,25 @@ asm/cx86-out.o: asm/cx86unix.cpp
64 66
65# bsdi 67# bsdi
66asm/cx86bsdi.o: asm/cx86unix.cpp 68asm/cx86bsdi.o: asm/cx86unix.cpp
67 $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o 69 $(CPP) -DBSDI asm/cx86unix.cpp | sed 's/ :/:/' | as -o asm/cx86bsdi.o
68 70
69asm/cx86unix.cpp: 71asm/cx86unix.cpp: asm/cast-586.pl
70 (cd asm; perl cast-586.pl cpp >cx86unix.cpp) 72 (cd asm; $(PERL) cast-586.pl cpp $(PROCESSOR) >cx86unix.cpp)
71 73
72files: 74files:
73 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 75 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74 76
75links: 77links:
76 /bin/rm -f Makefile 78 @$(TOP)/util/point.sh Makefile.ssl Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ; 79 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
78 $(TOP)/util/mklink.sh ../../include $(EXHEADER) 80 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
79 $(TOP)/util/mklink.sh ../../test $(TEST) 81 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
80 $(TOP)/util/mklink.sh ../../apps $(APPS)
81 82
82install: 83install:
83 @for i in $(EXHEADER) ; \ 84 @for i in $(EXHEADER) ; \
84 do \ 85 do \
85 (cp $$i $(INSTALLTOP)/include/$$i; \ 86 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
86 chmod 644 $(INSTALLTOP)/include/$$i ); \ 87 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
87 done; 88 done;
88 89
89tags: 90tags:
@@ -95,15 +96,29 @@ lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff 96 lint -DLINT $(INCLUDES) $(SRC)>fluff
96 97
97depend: 98depend:
98 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 99 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
99 100
100dclean: 101dclean:
101 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 102 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
102 mv -f Makefile.new $(MAKEFILE) 103 mv -f Makefile.new $(MAKEFILE)
103 104
104clean: 105clean:
105 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 106 rm -f asm/cx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
106
107errors:
108 107
109# DO NOT DELETE THIS LINE -- make depend depends on it. 108# DO NOT DELETE THIS LINE -- make depend depends on it.
109
110c_cfb64.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h
111c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
112c_cfb64.o: cast_lcl.h
113c_ecb.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h
114c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
115c_ecb.o: ../../include/openssl/opensslv.h cast_lcl.h
116c_enc.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h
117c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
118c_enc.o: cast_lcl.h
119c_ofb64.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h
120c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
121c_ofb64.o: cast_lcl.h
122c_skey.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h
123c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
124c_skey.o: cast_lcl.h cast_s.h
diff --git a/src/lib/libcrypto/cast/Makefile.uni b/src/lib/libcrypto/cast/Makefile.uni
index 780073e75b..a5870897cf 100644
--- a/src/lib/libcrypto/cast/Makefile.uni
+++ b/src/lib/libcrypto/cast/Makefile.uni
@@ -24,6 +24,7 @@ MAKE= make
24MAKEDEPEND= makedepend 24MAKEDEPEND= makedepend
25MAKEFILE= Makefile.uni 25MAKEFILE= Makefile.uni
26AR= ar r 26AR= ar r
27RANLIB= ranlib
27 28
28CAST_ENC=c_enc.o 29CAST_ENC=c_enc.o
29# or use 30# or use
@@ -55,7 +56,7 @@ all: $(LIB) $(TEST) $(APPS)
55 56
56$(LIB): $(LIBOBJ) 57$(LIB): $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ) 58 $(AR) $(LIB) $(LIBOBJ)
58 sh $(TOP)/ranlib.sh $(LIB) 59 $(RANLIB) $(LIB)
59# elf 60# elf
60asm/cx86-elf.o: asm/cx86unix.cpp 61asm/cx86-elf.o: asm/cx86unix.cpp
61 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o 62 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o
diff --git a/src/lib/libcrypto/cast/asm/c-win32.asm b/src/lib/libcrypto/cast/asm/c-win32.asm
index a1d8a2671a..ba78a3c69c 100644
--- a/src/lib/libcrypto/cast/asm/c-win32.asm
+++ b/src/lib/libcrypto/cast/asm/c-win32.asm
@@ -25,6 +25,9 @@ _CAST_encrypt PROC NEAR
25 ; Load the 2 words 25 ; Load the 2 words
26 mov edi, DWORD PTR [ebx] 26 mov edi, DWORD PTR [ebx]
27 mov esi, DWORD PTR 4[ebx] 27 mov esi, DWORD PTR 4[ebx]
28 ; Get short key flag
29 mov eax, DWORD PTR 128[ebp]
30 push eax
28 xor eax, eax 31 xor eax, eax
29 ; round 0 32 ; round 0
30 mov edx, DWORD PTR [ebp] 33 mov edx, DWORD PTR [ebp]
@@ -278,6 +281,10 @@ _CAST_encrypt PROC NEAR
278 mov ebx, DWORD PTR _CAST_S_table3[edx*4] 281 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
279 sub ecx, ebx 282 sub ecx, ebx
280 xor esi, ecx 283 xor esi, ecx
284 ; test short key flag
285 pop edx
286 or edx, edx
287 jnz $L000cast_enc_done
281 ; round 12 288 ; round 12
282 mov edx, DWORD PTR 96[ebp] 289 mov edx, DWORD PTR 96[ebp]
283 mov ecx, DWORD PTR 100[ebp] 290 mov ecx, DWORD PTR 100[ebp]
@@ -361,9 +368,10 @@ _CAST_encrypt PROC NEAR
361 sub ecx, ebx 368 sub ecx, ebx
362 mov ebx, DWORD PTR _CAST_S_table3[edx*4] 369 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
363 add ecx, ebx 370 add ecx, ebx
364 mov eax, DWORD PTR 20[esp]
365 xor esi, ecx 371 xor esi, ecx
372$L000cast_enc_done:
366 nop 373 nop
374 mov eax, DWORD PTR 20[esp]
367 mov DWORD PTR 4[eax],edi 375 mov DWORD PTR 4[eax],edi
368 mov DWORD PTR [eax],esi 376 mov DWORD PTR [eax],esi
369 pop edi 377 pop edi
@@ -391,6 +399,10 @@ _CAST_decrypt PROC NEAR
391 ; Load the 2 words 399 ; Load the 2 words
392 mov edi, DWORD PTR [ebx] 400 mov edi, DWORD PTR [ebx]
393 mov esi, DWORD PTR 4[ebx] 401 mov esi, DWORD PTR 4[ebx]
402 ; Get short key flag
403 mov eax, DWORD PTR 128[ebp]
404 or eax, eax
405 jnz $L001cast_dec_skip
394 xor eax, eax 406 xor eax, eax
395 ; round 15 407 ; round 15
396 mov edx, DWORD PTR 120[ebp] 408 mov edx, DWORD PTR 120[ebp]
@@ -476,6 +488,7 @@ _CAST_decrypt PROC NEAR
476 mov ebx, DWORD PTR _CAST_S_table3[edx*4] 488 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
477 add ecx, ebx 489 add ecx, ebx
478 xor esi, ecx 490 xor esi, ecx
491$L001cast_dec_skip:
479 ; round 11 492 ; round 11
480 mov edx, DWORD PTR 88[ebp] 493 mov edx, DWORD PTR 88[ebp]
481 mov ecx, DWORD PTR 92[ebp] 494 mov ecx, DWORD PTR 92[ebp]
@@ -727,9 +740,9 @@ _CAST_decrypt PROC NEAR
727 sub ecx, ebx 740 sub ecx, ebx
728 mov ebx, DWORD PTR _CAST_S_table3[edx*4] 741 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
729 add ecx, ebx 742 add ecx, ebx
730 mov eax, DWORD PTR 20[esp]
731 xor esi, ecx 743 xor esi, ecx
732 nop 744 nop
745 mov eax, DWORD PTR 20[esp]
733 mov DWORD PTR 4[eax],edi 746 mov DWORD PTR 4[eax],edi
734 mov DWORD PTR [eax],esi 747 mov DWORD PTR [eax],esi
735 pop edi 748 pop edi
@@ -767,12 +780,12 @@ _CAST_cbc_encrypt PROC NEAR
767 push eax 780 push eax
768 push ebx 781 push ebx
769 cmp ecx, 0 782 cmp ecx, 0
770 jz $L000decrypt 783 jz $L002decrypt
771 and ebp, 4294967288 784 and ebp, 4294967288
772 mov eax, DWORD PTR 8[esp] 785 mov eax, DWORD PTR 8[esp]
773 mov ebx, DWORD PTR 12[esp] 786 mov ebx, DWORD PTR 12[esp]
774 jz $L001encrypt_finish 787 jz $L003encrypt_finish
775L002encrypt_loop: 788L004encrypt_loop:
776 mov ecx, DWORD PTR [esi] 789 mov ecx, DWORD PTR [esi]
777 mov edx, DWORD PTR 4[esi] 790 mov edx, DWORD PTR 4[esi]
778 xor eax, ecx 791 xor eax, ecx
@@ -791,35 +804,35 @@ L002encrypt_loop:
791 add esi, 8 804 add esi, 8
792 add edi, 8 805 add edi, 8
793 sub ebp, 8 806 sub ebp, 8
794 jnz L002encrypt_loop 807 jnz L004encrypt_loop
795$L001encrypt_finish: 808$L003encrypt_finish:
796 mov ebp, DWORD PTR 52[esp] 809 mov ebp, DWORD PTR 52[esp]
797 and ebp, 7 810 and ebp, 7
798 jz $L003finish 811 jz $L005finish
799 xor ecx, ecx 812 xor ecx, ecx
800 xor edx, edx 813 xor edx, edx
801 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4] 814 mov ebp, DWORD PTR $L006cbc_enc_jmp_table[ebp*4]
802 jmp ebp 815 jmp ebp
803L005ej7: 816L007ej7:
804 xor edx, edx 817 xor edx, edx
805 mov dh, BYTE PTR 6[esi] 818 mov dh, BYTE PTR 6[esi]
806 shl edx, 8 819 shl edx, 8
807L006ej6: 820L008ej6:
808 mov dh, BYTE PTR 5[esi] 821 mov dh, BYTE PTR 5[esi]
809L007ej5: 822L009ej5:
810 mov dl, BYTE PTR 4[esi] 823 mov dl, BYTE PTR 4[esi]
811L008ej4: 824L010ej4:
812 mov ecx, DWORD PTR [esi] 825 mov ecx, DWORD PTR [esi]
813 jmp $L009ejend 826 jmp $L011ejend
814L010ej3: 827L012ej3:
815 mov ch, BYTE PTR 2[esi] 828 mov ch, BYTE PTR 2[esi]
816 xor ecx, ecx 829 xor ecx, ecx
817 shl ecx, 8 830 shl ecx, 8
818L011ej2: 831L013ej2:
819 mov ch, BYTE PTR 1[esi] 832 mov ch, BYTE PTR 1[esi]
820L012ej1: 833L014ej1:
821 mov cl, BYTE PTR [esi] 834 mov cl, BYTE PTR [esi]
822$L009ejend: 835$L011ejend:
823 xor eax, ecx 836 xor eax, ecx
824 xor ebx, edx 837 xor ebx, edx
825 bswap eax 838 bswap eax
@@ -833,13 +846,13 @@ $L009ejend:
833 bswap ebx 846 bswap ebx
834 mov DWORD PTR [edi],eax 847 mov DWORD PTR [edi],eax
835 mov DWORD PTR 4[edi],ebx 848 mov DWORD PTR 4[edi],ebx
836 jmp $L003finish 849 jmp $L005finish
837$L000decrypt: 850$L002decrypt:
838 and ebp, 4294967288 851 and ebp, 4294967288
839 mov eax, DWORD PTR 16[esp] 852 mov eax, DWORD PTR 16[esp]
840 mov ebx, DWORD PTR 20[esp] 853 mov ebx, DWORD PTR 20[esp]
841 jz $L013decrypt_finish 854 jz $L015decrypt_finish
842L014decrypt_loop: 855L016decrypt_loop:
843 mov eax, DWORD PTR [esi] 856 mov eax, DWORD PTR [esi]
844 mov ebx, DWORD PTR 4[esi] 857 mov ebx, DWORD PTR 4[esi]
845 bswap eax 858 bswap eax
@@ -864,11 +877,11 @@ L014decrypt_loop:
864 add esi, 8 877 add esi, 8
865 add edi, 8 878 add edi, 8
866 sub ebp, 8 879 sub ebp, 8
867 jnz L014decrypt_loop 880 jnz L016decrypt_loop
868$L013decrypt_finish: 881$L015decrypt_finish:
869 mov ebp, DWORD PTR 52[esp] 882 mov ebp, DWORD PTR 52[esp]
870 and ebp, 7 883 and ebp, 7
871 jz $L003finish 884 jz $L005finish
872 mov eax, DWORD PTR [esi] 885 mov eax, DWORD PTR [esi]
873 mov ebx, DWORD PTR 4[esi] 886 mov ebx, DWORD PTR 4[esi]
874 bswap eax 887 bswap eax
@@ -886,28 +899,28 @@ $L013decrypt_finish:
886 xor edx, ebx 899 xor edx, ebx
887 mov eax, DWORD PTR [esi] 900 mov eax, DWORD PTR [esi]
888 mov ebx, DWORD PTR 4[esi] 901 mov ebx, DWORD PTR 4[esi]
889L015dj7: 902L017dj7:
890 ror edx, 16 903 ror edx, 16
891 mov BYTE PTR 6[edi],dl 904 mov BYTE PTR 6[edi],dl
892 shr edx, 16 905 shr edx, 16
893L016dj6: 906L018dj6:
894 mov BYTE PTR 5[edi],dh 907 mov BYTE PTR 5[edi],dh
895L017dj5: 908L019dj5:
896 mov BYTE PTR 4[edi],dl 909 mov BYTE PTR 4[edi],dl
897L018dj4: 910L020dj4:
898 mov DWORD PTR [edi],ecx 911 mov DWORD PTR [edi],ecx
899 jmp $L019djend 912 jmp $L021djend
900L020dj3: 913L022dj3:
901 ror ecx, 16 914 ror ecx, 16
902 mov BYTE PTR 2[edi],cl 915 mov BYTE PTR 2[edi],cl
903 shl ecx, 16 916 shl ecx, 16
904L021dj2: 917L023dj2:
905 mov BYTE PTR 1[esi],ch 918 mov BYTE PTR 1[esi],ch
906L022dj1: 919L024dj1:
907 mov BYTE PTR [esi], cl 920 mov BYTE PTR [esi], cl
908$L019djend: 921$L021djend:
909 jmp $L003finish 922 jmp $L005finish
910$L003finish: 923$L005finish:
911 mov ecx, DWORD PTR 60[esp] 924 mov ecx, DWORD PTR 60[esp]
912 add esp, 24 925 add esp, 24
913 mov DWORD PTR [ecx],eax 926 mov DWORD PTR [ecx],eax
@@ -917,24 +930,24 @@ $L003finish:
917 pop ebx 930 pop ebx
918 pop ebp 931 pop ebp
919 ret 932 ret
920$L004cbc_enc_jmp_table: 933$L006cbc_enc_jmp_table:
921 DD 0 934 DD 0
922 DD L012ej1 935 DD L014ej1
923 DD L011ej2 936 DD L013ej2
924 DD L010ej3 937 DD L012ej3
925 DD L008ej4 938 DD L010ej4
926 DD L007ej5 939 DD L009ej5
927 DD L006ej6 940 DD L008ej6
928 DD L005ej7 941 DD L007ej7
929L023cbc_dec_jmp_table: 942L025cbc_dec_jmp_table:
930 DD 0 943 DD 0
931 DD L022dj1 944 DD L024dj1
932 DD L021dj2 945 DD L023dj2
933 DD L020dj3 946 DD L022dj3
934 DD L018dj4 947 DD L020dj4
935 DD L017dj5 948 DD L019dj5
936 DD L016dj6 949 DD L018dj6
937 DD L015dj7 950 DD L017dj7
938_CAST_cbc_encrypt ENDP 951_CAST_cbc_encrypt ENDP
939_TEXT ENDS 952_TEXT ENDS
940END 953END
diff --git a/src/lib/libcrypto/cast/asm/cast-586.pl b/src/lib/libcrypto/cast/asm/cast-586.pl
index d0be004c99..6be0bfe572 100644
--- a/src/lib/libcrypto/cast/asm/cast-586.pl
+++ b/src/lib/libcrypto/cast/asm/cast-586.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3# define for pentium pro friendly version 3# define for pentium pro friendly version
4$ppro=1; 4$ppro=1;
@@ -7,7 +7,7 @@ push(@INC,"perlasm","../../perlasm");
7require "x86asm.pl"; 7require "x86asm.pl";
8require "cbc.pl"; 8require "cbc.pl";
9 9
10&asm_init($ARGV[0],"cast-586.pl"); 10&asm_init($ARGV[0],"cast-586.pl",$ARGV[$#ARGV] eq "386");
11 11
12$CAST_ROUNDS=16; 12$CAST_ROUNDS=16;
13$L="edi"; 13$L="edi";
@@ -32,136 +32,145 @@ $S4="CAST_S_table3";
32 32
33&asm_finish(); 33&asm_finish();
34 34
35sub CAST_encrypt 35sub CAST_encrypt {
36 { 36 local($name,$enc)=@_;
37 local($name,$enc)=@_;
38 37
39 local($win_ex)=<<"EOF"; 38 local($win_ex)=<<"EOF";
40EXTERN _CAST_S_table0:DWORD 39EXTERN _CAST_S_table0:DWORD
41EXTERN _CAST_S_table1:DWORD 40EXTERN _CAST_S_table1:DWORD
42EXTERN _CAST_S_table2:DWORD 41EXTERN _CAST_S_table2:DWORD
43EXTERN _CAST_S_table3:DWORD 42EXTERN _CAST_S_table3:DWORD
44EOF 43EOF
45 &main'external_label( 44 &main::external_label(
46 "CAST_S_table0", 45 "CAST_S_table0",
47 "CAST_S_table1", 46 "CAST_S_table1",
48 "CAST_S_table2", 47 "CAST_S_table2",
49 "CAST_S_table3", 48 "CAST_S_table3",
50 ); 49 );
51 50
52 &function_begin_B($name,$win_ex); 51 &function_begin_B($name,$win_ex);
53 52
54 &comment(""); 53 &comment("");
55 54
56 &push("ebp"); 55 &push("ebp");
57 &push("ebx"); 56 &push("ebx");
58 &mov($tmp2,&wparam(0)); 57 &mov($tmp2,&wparam(0));
59 &mov($K,&wparam(1)); 58 &mov($K,&wparam(1));
60 &push("esi"); 59 &push("esi");
61 &push("edi"); 60 &push("edi");
62 61
63 &comment("Load the 2 words"); 62 &comment("Load the 2 words");
64 &mov($L,&DWP(0,$tmp2,"",0)); 63 &mov($L,&DWP(0,$tmp2,"",0));
65 &mov($R,&DWP(4,$tmp2,"",0)); 64 &mov($R,&DWP(4,$tmp2,"",0));
66 65
67 &xor( $tmp3, $tmp3); 66 &comment('Get short key flag');
68 67 &mov($tmp3,&DWP(128,$K,"",0));
69 # encrypting part 68 if($enc) {
70 69 &push($tmp3);
71 if ($enc) 70 } else {
72 { 71 &or($tmp3,$tmp3);
73 &E_CAST( 0,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 72 &jnz(&label('cast_dec_skip'));
74 &E_CAST( 1,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 73 }
75 &E_CAST( 2,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 74
76 &E_CAST( 3,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 75 &xor($tmp3, $tmp3);
77 &E_CAST( 4,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 76
78 &E_CAST( 5,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 77 # encrypting part
79 &E_CAST( 6,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 78
80 &E_CAST( 7,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 79 if ($enc) {
81 &E_CAST( 8,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 80 &E_CAST( 0,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
82 &E_CAST( 9,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 81 &E_CAST( 1,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
83 &E_CAST(10,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 82 &E_CAST( 2,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
84 &E_CAST(11,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 83 &E_CAST( 3,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
85 &E_CAST(12,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 84 &E_CAST( 4,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
86 &E_CAST(13,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 85 &E_CAST( 5,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
87 &E_CAST(14,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 86 &E_CAST( 6,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
88 &E_CAST(15,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4,1); 87 &E_CAST( 7,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
89 } 88 &E_CAST( 8,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
90 else 89 &E_CAST( 9,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
91 { 90 &E_CAST(10,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
92 &E_CAST(15,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 91 &E_CAST(11,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
93 &E_CAST(14,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 92 &comment('test short key flag');
94 &E_CAST(13,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 93 &pop($tmp4);
95 &E_CAST(12,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 94 &or($tmp4,$tmp4);
96 &E_CAST(11,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 95 &jnz(&label('cast_enc_done'));
97 &E_CAST(10,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 96 &E_CAST(12,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
98 &E_CAST( 9,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 97 &E_CAST(13,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
99 &E_CAST( 8,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 98 &E_CAST(14,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
100 &E_CAST( 7,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 99 &E_CAST(15,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
101 &E_CAST( 6,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 100 } else {
102 &E_CAST( 5,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 101 &E_CAST(15,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
103 &E_CAST( 4,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 102 &E_CAST(14,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
104 &E_CAST( 3,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4); 103 &E_CAST(13,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
105 &E_CAST( 2,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4); 104 &E_CAST(12,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
106 &E_CAST( 1,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4); 105 &set_label('cast_dec_skip');
107 &E_CAST( 0,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4,1); 106 &E_CAST(11,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
108 } 107 &E_CAST(10,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
109 108 &E_CAST( 9,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
110 &nop(); 109 &E_CAST( 8,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
111 &mov(&DWP(4,$tmp3,"",0),$L); 110 &E_CAST( 7,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
112 &mov(&DWP(0,$tmp3,"",0),$R); 111 &E_CAST( 6,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
113 &function_end($name); 112 &E_CAST( 5,$S,$L,$R,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
114 } 113 &E_CAST( 4,$S,$R,$L,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
115 114 &E_CAST( 3,$S,$L,$R,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
116sub E_CAST 115 &E_CAST( 2,$S,$R,$L,$K,@F3,$tmp1,$tmp2,$tmp3,$tmp4);
117 { 116 &E_CAST( 1,$S,$L,$R,$K,@F2,$tmp1,$tmp2,$tmp3,$tmp4);
118 local($i,$S,$L,$R,$K,$OP1,$OP2,$OP3,$tmp1,$tmp2,$tmp3,$tmp4,$lst)=@_; 117 &E_CAST( 0,$S,$R,$L,$K,@F1,$tmp1,$tmp2,$tmp3,$tmp4);
119 # Ri needs to have 16 pre added. 118 }
120 119
121 &comment("round $i"); 120 &set_label('cast_enc_done') if $enc;
122 &mov( $tmp4, &DWP($i*8,$K,"",1)); 121# Why the nop? - Ben 17/1/99
123 122 &nop();
124 &mov( $tmp1, &DWP($i*8+4,$K,"",1));# must be word 123 &mov($tmp3,&wparam(0));
125 &$OP1( $tmp4, $R); 124 &mov(&DWP(4,$tmp3,"",0),$L);
126 125 &mov(&DWP(0,$tmp3,"",0),$R);
127 &rotl( $tmp4, &LB($tmp1)); 126 &function_end($name);
128 127}
129 if ($ppro) 128
130 { 129sub E_CAST {
131 &mov( $tmp2, $tmp4); # B 130 local($i,$S,$L,$R,$K,$OP1,$OP2,$OP3,$tmp1,$tmp2,$tmp3,$tmp4)=@_;
132 &xor( $tmp1, $tmp1); 131 # Ri needs to have 16 pre added.
133 132
134 &movb( &LB($tmp1), &HB($tmp4)); # A 133 &comment("round $i");
135 &and( $tmp2, 0xff); 134 &mov( $tmp4, &DWP($i*8,$K,"",1));
136 135
137 &shr( $tmp4, 16); # 136 &mov( $tmp1, &DWP($i*8+4,$K,"",1));
138 &xor( $tmp3, $tmp3); 137 &$OP1( $tmp4, $R);
139 } 138
140 else 139 &rotl( $tmp4, &LB($tmp1));
141 { 140
142 &mov( $tmp2, $tmp4); # B 141 if ($ppro) {
143 &movb( &LB($tmp1), &HB($tmp4)); # A # BAD BAD BAD 142 &mov( $tmp2, $tmp4); # B
144 143 &xor( $tmp1, $tmp1);
145 &shr( $tmp4, 16); # 144
146 &and( $tmp2, 0xff); 145 &movb( &LB($tmp1), &HB($tmp4)); # A
147 } 146 &and( $tmp2, 0xff);
148 147
149 &movb( &LB($tmp3), &HB($tmp4)); # C # BAD BAD BAD 148 &shr( $tmp4, 16); #
150 &and( $tmp4, 0xff); # D 149 &xor( $tmp3, $tmp3);
151 150 } else {
152 &mov( $tmp1, &DWP($S1,"",$tmp1,4)); 151 &mov( $tmp2, $tmp4); # B
153 &mov( $tmp2, &DWP($S2,"",$tmp2,4)); 152 &movb( &LB($tmp1), &HB($tmp4)); # A # BAD BAD BAD
154 153
155 &$OP2( $tmp1, $tmp2); 154 &shr( $tmp4, 16); #
156 &mov( $tmp2, &DWP($S3,"",$tmp3,4)); 155 &and( $tmp2, 0xff);
157 156 }
158 &$OP3( $tmp1, $tmp2); 157
159 &mov( $tmp2, &DWP($S4,"",$tmp4,4)); 158 &movb( &LB($tmp3), &HB($tmp4)); # C # BAD BAD BAD
160 159 &and( $tmp4, 0xff); # D
161 &$OP1( $tmp1, $tmp2); 160
162 &mov($tmp3,&wparam(0)) if $lst; 161 &mov( $tmp1, &DWP($S1,"",$tmp1,4));
163 # XXX 162 &mov( $tmp2, &DWP($S2,"",$tmp2,4));
164 163
165 &xor( $L, $tmp1); 164 &$OP2( $tmp1, $tmp2);
166 # XXX 165 &mov( $tmp2, &DWP($S3,"",$tmp3,4));
167 } 166
167 &$OP3( $tmp1, $tmp2);
168 &mov( $tmp2, &DWP($S4,"",$tmp4,4));
169
170 &$OP1( $tmp1, $tmp2);
171 # XXX
172
173 &xor( $L, $tmp1);
174 # XXX
175}
176
diff --git a/src/lib/libcrypto/cast/asm/cx86unix.cpp b/src/lib/libcrypto/cast/asm/cx86unix.cpp
deleted file mode 100644
index 035692a5af..0000000000
--- a/src/lib/libcrypto/cast/asm/cx86unix.cpp
+++ /dev/null
@@ -1,1010 +0,0 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define CAST_S_table0 _CAST_S_table0
13#define CAST_S_table1 _CAST_S_table1
14#define CAST_S_table2 _CAST_S_table2
15#define CAST_S_table3 _CAST_S_table3
16#define CAST_encrypt _CAST_encrypt
17#define CAST_S_table0 _CAST_S_table0
18#define CAST_S_table1 _CAST_S_table1
19#define CAST_S_table2 _CAST_S_table2
20#define CAST_S_table3 _CAST_S_table3
21#define CAST_decrypt _CAST_decrypt
22#define CAST_cbc_encrypt _CAST_cbc_encrypt
23
24#endif
25
26#ifdef OUT
27#define OK 1
28#define ALIGN 4
29#endif
30
31#ifdef BSDI
32#define OK 1
33#define ALIGN 4
34#undef SIZE
35#undef TYPE
36#define SIZE(a,b)
37#define TYPE(a,b)
38#endif
39
40#if defined(ELF) || defined(SOL)
41#define OK 1
42#define ALIGN 16
43#endif
44
45#ifndef OK
46You need to define one of
47ELF - elf systems - linux-elf, NetBSD and DG-UX
48OUT - a.out systems - linux-a.out and FreeBSD
49SOL - solaris systems, which are elf with strange comment lines
50BSDI - a.out with a very primative version of as.
51#endif
52
53/* Let the Assembler begin :-) */
54 /* Don't even think of reading this code */
55 /* It was automatically generated by cast-586.pl */
56 /* Which is a perl program used to generate the x86 assember for */
57 /* any of elf, a.out, BSDI,Win32, or Solaris */
58 /* eric <eay@cryptsoft.com> */
59
60 .file "cast-586.s"
61 .version "01.01"
62gcc2_compiled.:
63.text
64 .align ALIGN
65.globl CAST_encrypt
66 TYPE(CAST_encrypt,@function)
67CAST_encrypt:
68
69 pushl %ebp
70 pushl %ebx
71 movl 12(%esp), %ebx
72 movl 16(%esp), %ebp
73 pushl %esi
74 pushl %edi
75 /* Load the 2 words */
76 movl (%ebx), %edi
77 movl 4(%ebx), %esi
78 xorl %eax, %eax
79 /* round 0 */
80 movl (%ebp), %edx
81 movl 4(%ebp), %ecx
82 addl %esi, %edx
83 roll %cl, %edx
84 movl %edx, %ebx
85 xorl %ecx, %ecx
86 movb %dh, %cl
87 andl $255, %ebx
88 shrl $16, %edx
89 xorl %eax, %eax
90 movb %dh, %al
91 andl $255, %edx
92 movl CAST_S_table0(,%ecx,4),%ecx
93 movl CAST_S_table1(,%ebx,4),%ebx
94 xorl %ebx, %ecx
95 movl CAST_S_table2(,%eax,4),%ebx
96 subl %ebx, %ecx
97 movl CAST_S_table3(,%edx,4),%ebx
98 addl %ebx, %ecx
99 xorl %ecx, %edi
100 /* round 1 */
101 movl 8(%ebp), %edx
102 movl 12(%ebp), %ecx
103 xorl %edi, %edx
104 roll %cl, %edx
105 movl %edx, %ebx
106 xorl %ecx, %ecx
107 movb %dh, %cl
108 andl $255, %ebx
109 shrl $16, %edx
110 xorl %eax, %eax
111 movb %dh, %al
112 andl $255, %edx
113 movl CAST_S_table0(,%ecx,4),%ecx
114 movl CAST_S_table1(,%ebx,4),%ebx
115 subl %ebx, %ecx
116 movl CAST_S_table2(,%eax,4),%ebx
117 addl %ebx, %ecx
118 movl CAST_S_table3(,%edx,4),%ebx
119 xorl %ebx, %ecx
120 xorl %ecx, %esi
121 /* round 2 */
122 movl 16(%ebp), %edx
123 movl 20(%ebp), %ecx
124 subl %esi, %edx
125 roll %cl, %edx
126 movl %edx, %ebx
127 xorl %ecx, %ecx
128 movb %dh, %cl
129 andl $255, %ebx
130 shrl $16, %edx
131 xorl %eax, %eax
132 movb %dh, %al
133 andl $255, %edx
134 movl CAST_S_table0(,%ecx,4),%ecx
135 movl CAST_S_table1(,%ebx,4),%ebx
136 addl %ebx, %ecx
137 movl CAST_S_table2(,%eax,4),%ebx
138 xorl %ebx, %ecx
139 movl CAST_S_table3(,%edx,4),%ebx
140 subl %ebx, %ecx
141 xorl %ecx, %edi
142 /* round 3 */
143 movl 24(%ebp), %edx
144 movl 28(%ebp), %ecx
145 addl %edi, %edx
146 roll %cl, %edx
147 movl %edx, %ebx
148 xorl %ecx, %ecx
149 movb %dh, %cl
150 andl $255, %ebx
151 shrl $16, %edx
152 xorl %eax, %eax
153 movb %dh, %al
154 andl $255, %edx
155 movl CAST_S_table0(,%ecx,4),%ecx
156 movl CAST_S_table1(,%ebx,4),%ebx
157 xorl %ebx, %ecx
158 movl CAST_S_table2(,%eax,4),%ebx
159 subl %ebx, %ecx
160 movl CAST_S_table3(,%edx,4),%ebx
161 addl %ebx, %ecx
162 xorl %ecx, %esi
163 /* round 4 */
164 movl 32(%ebp), %edx
165 movl 36(%ebp), %ecx
166 xorl %esi, %edx
167 roll %cl, %edx
168 movl %edx, %ebx
169 xorl %ecx, %ecx
170 movb %dh, %cl
171 andl $255, %ebx
172 shrl $16, %edx
173 xorl %eax, %eax
174 movb %dh, %al
175 andl $255, %edx
176 movl CAST_S_table0(,%ecx,4),%ecx
177 movl CAST_S_table1(,%ebx,4),%ebx
178 subl %ebx, %ecx
179 movl CAST_S_table2(,%eax,4),%ebx
180 addl %ebx, %ecx
181 movl CAST_S_table3(,%edx,4),%ebx
182 xorl %ebx, %ecx
183 xorl %ecx, %edi
184 /* round 5 */
185 movl 40(%ebp), %edx
186 movl 44(%ebp), %ecx
187 subl %edi, %edx
188 roll %cl, %edx
189 movl %edx, %ebx
190 xorl %ecx, %ecx
191 movb %dh, %cl
192 andl $255, %ebx
193 shrl $16, %edx
194 xorl %eax, %eax
195 movb %dh, %al
196 andl $255, %edx
197 movl CAST_S_table0(,%ecx,4),%ecx
198 movl CAST_S_table1(,%ebx,4),%ebx
199 addl %ebx, %ecx
200 movl CAST_S_table2(,%eax,4),%ebx
201 xorl %ebx, %ecx
202 movl CAST_S_table3(,%edx,4),%ebx
203 subl %ebx, %ecx
204 xorl %ecx, %esi
205 /* round 6 */
206 movl 48(%ebp), %edx
207 movl 52(%ebp), %ecx
208 addl %esi, %edx
209 roll %cl, %edx
210 movl %edx, %ebx
211 xorl %ecx, %ecx
212 movb %dh, %cl
213 andl $255, %ebx
214 shrl $16, %edx
215 xorl %eax, %eax
216 movb %dh, %al
217 andl $255, %edx
218 movl CAST_S_table0(,%ecx,4),%ecx
219 movl CAST_S_table1(,%ebx,4),%ebx
220 xorl %ebx, %ecx
221 movl CAST_S_table2(,%eax,4),%ebx
222 subl %ebx, %ecx
223 movl CAST_S_table3(,%edx,4),%ebx
224 addl %ebx, %ecx
225 xorl %ecx, %edi
226 /* round 7 */
227 movl 56(%ebp), %edx
228 movl 60(%ebp), %ecx
229 xorl %edi, %edx
230 roll %cl, %edx
231 movl %edx, %ebx
232 xorl %ecx, %ecx
233 movb %dh, %cl
234 andl $255, %ebx
235 shrl $16, %edx
236 xorl %eax, %eax
237 movb %dh, %al
238 andl $255, %edx
239 movl CAST_S_table0(,%ecx,4),%ecx
240 movl CAST_S_table1(,%ebx,4),%ebx
241 subl %ebx, %ecx
242 movl CAST_S_table2(,%eax,4),%ebx
243 addl %ebx, %ecx
244 movl CAST_S_table3(,%edx,4),%ebx
245 xorl %ebx, %ecx
246 xorl %ecx, %esi
247 /* round 8 */
248 movl 64(%ebp), %edx
249 movl 68(%ebp), %ecx
250 subl %esi, %edx
251 roll %cl, %edx
252 movl %edx, %ebx
253 xorl %ecx, %ecx
254 movb %dh, %cl
255 andl $255, %ebx
256 shrl $16, %edx
257 xorl %eax, %eax
258 movb %dh, %al
259 andl $255, %edx
260 movl CAST_S_table0(,%ecx,4),%ecx
261 movl CAST_S_table1(,%ebx,4),%ebx
262 addl %ebx, %ecx
263 movl CAST_S_table2(,%eax,4),%ebx
264 xorl %ebx, %ecx
265 movl CAST_S_table3(,%edx,4),%ebx
266 subl %ebx, %ecx
267 xorl %ecx, %edi
268 /* round 9 */
269 movl 72(%ebp), %edx
270 movl 76(%ebp), %ecx
271 addl %edi, %edx
272 roll %cl, %edx
273 movl %edx, %ebx
274 xorl %ecx, %ecx
275 movb %dh, %cl
276 andl $255, %ebx
277 shrl $16, %edx
278 xorl %eax, %eax
279 movb %dh, %al
280 andl $255, %edx
281 movl CAST_S_table0(,%ecx,4),%ecx
282 movl CAST_S_table1(,%ebx,4),%ebx
283 xorl %ebx, %ecx
284 movl CAST_S_table2(,%eax,4),%ebx
285 subl %ebx, %ecx
286 movl CAST_S_table3(,%edx,4),%ebx
287 addl %ebx, %ecx
288 xorl %ecx, %esi
289 /* round 10 */
290 movl 80(%ebp), %edx
291 movl 84(%ebp), %ecx
292 xorl %esi, %edx
293 roll %cl, %edx
294 movl %edx, %ebx
295 xorl %ecx, %ecx
296 movb %dh, %cl
297 andl $255, %ebx
298 shrl $16, %edx
299 xorl %eax, %eax
300 movb %dh, %al
301 andl $255, %edx
302 movl CAST_S_table0(,%ecx,4),%ecx
303 movl CAST_S_table1(,%ebx,4),%ebx
304 subl %ebx, %ecx
305 movl CAST_S_table2(,%eax,4),%ebx
306 addl %ebx, %ecx
307 movl CAST_S_table3(,%edx,4),%ebx
308 xorl %ebx, %ecx
309 xorl %ecx, %edi
310 /* round 11 */
311 movl 88(%ebp), %edx
312 movl 92(%ebp), %ecx
313 subl %edi, %edx
314 roll %cl, %edx
315 movl %edx, %ebx
316 xorl %ecx, %ecx
317 movb %dh, %cl
318 andl $255, %ebx
319 shrl $16, %edx
320 xorl %eax, %eax
321 movb %dh, %al
322 andl $255, %edx
323 movl CAST_S_table0(,%ecx,4),%ecx
324 movl CAST_S_table1(,%ebx,4),%ebx
325 addl %ebx, %ecx
326 movl CAST_S_table2(,%eax,4),%ebx
327 xorl %ebx, %ecx
328 movl CAST_S_table3(,%edx,4),%ebx
329 subl %ebx, %ecx
330 xorl %ecx, %esi
331 /* round 12 */
332 movl 96(%ebp), %edx
333 movl 100(%ebp), %ecx
334 addl %esi, %edx
335 roll %cl, %edx
336 movl %edx, %ebx
337 xorl %ecx, %ecx
338 movb %dh, %cl
339 andl $255, %ebx
340 shrl $16, %edx
341 xorl %eax, %eax
342 movb %dh, %al
343 andl $255, %edx
344 movl CAST_S_table0(,%ecx,4),%ecx
345 movl CAST_S_table1(,%ebx,4),%ebx
346 xorl %ebx, %ecx
347 movl CAST_S_table2(,%eax,4),%ebx
348 subl %ebx, %ecx
349 movl CAST_S_table3(,%edx,4),%ebx
350 addl %ebx, %ecx
351 xorl %ecx, %edi
352 /* round 13 */
353 movl 104(%ebp), %edx
354 movl 108(%ebp), %ecx
355 xorl %edi, %edx
356 roll %cl, %edx
357 movl %edx, %ebx
358 xorl %ecx, %ecx
359 movb %dh, %cl
360 andl $255, %ebx
361 shrl $16, %edx
362 xorl %eax, %eax
363 movb %dh, %al
364 andl $255, %edx
365 movl CAST_S_table0(,%ecx,4),%ecx
366 movl CAST_S_table1(,%ebx,4),%ebx
367 subl %ebx, %ecx
368 movl CAST_S_table2(,%eax,4),%ebx
369 addl %ebx, %ecx
370 movl CAST_S_table3(,%edx,4),%ebx
371 xorl %ebx, %ecx
372 xorl %ecx, %esi
373 /* round 14 */
374 movl 112(%ebp), %edx
375 movl 116(%ebp), %ecx
376 subl %esi, %edx
377 roll %cl, %edx
378 movl %edx, %ebx
379 xorl %ecx, %ecx
380 movb %dh, %cl
381 andl $255, %ebx
382 shrl $16, %edx
383 xorl %eax, %eax
384 movb %dh, %al
385 andl $255, %edx
386 movl CAST_S_table0(,%ecx,4),%ecx
387 movl CAST_S_table1(,%ebx,4),%ebx
388 addl %ebx, %ecx
389 movl CAST_S_table2(,%eax,4),%ebx
390 xorl %ebx, %ecx
391 movl CAST_S_table3(,%edx,4),%ebx
392 subl %ebx, %ecx
393 xorl %ecx, %edi
394 /* round 15 */
395 movl 120(%ebp), %edx
396 movl 124(%ebp), %ecx
397 addl %edi, %edx
398 roll %cl, %edx
399 movl %edx, %ebx
400 xorl %ecx, %ecx
401 movb %dh, %cl
402 andl $255, %ebx
403 shrl $16, %edx
404 xorl %eax, %eax
405 movb %dh, %al
406 andl $255, %edx
407 movl CAST_S_table0(,%ecx,4),%ecx
408 movl CAST_S_table1(,%ebx,4),%ebx
409 xorl %ebx, %ecx
410 movl CAST_S_table2(,%eax,4),%ebx
411 subl %ebx, %ecx
412 movl CAST_S_table3(,%edx,4),%ebx
413 addl %ebx, %ecx
414 movl 20(%esp), %eax
415 xorl %ecx, %esi
416 nop
417 movl %edi, 4(%eax)
418 movl %esi, (%eax)
419 popl %edi
420 popl %esi
421 popl %ebx
422 popl %ebp
423 ret
424.CAST_encrypt_end:
425 SIZE(CAST_encrypt,.CAST_encrypt_end-CAST_encrypt)
426.ident "CAST_encrypt"
427.text
428 .align ALIGN
429.globl CAST_decrypt
430 TYPE(CAST_decrypt,@function)
431CAST_decrypt:
432
433 pushl %ebp
434 pushl %ebx
435 movl 12(%esp), %ebx
436 movl 16(%esp), %ebp
437 pushl %esi
438 pushl %edi
439 /* Load the 2 words */
440 movl (%ebx), %edi
441 movl 4(%ebx), %esi
442 xorl %eax, %eax
443 /* round 15 */
444 movl 120(%ebp), %edx
445 movl 124(%ebp), %ecx
446 addl %esi, %edx
447 roll %cl, %edx
448 movl %edx, %ebx
449 xorl %ecx, %ecx
450 movb %dh, %cl
451 andl $255, %ebx
452 shrl $16, %edx
453 xorl %eax, %eax
454 movb %dh, %al
455 andl $255, %edx
456 movl CAST_S_table0(,%ecx,4),%ecx
457 movl CAST_S_table1(,%ebx,4),%ebx
458 xorl %ebx, %ecx
459 movl CAST_S_table2(,%eax,4),%ebx
460 subl %ebx, %ecx
461 movl CAST_S_table3(,%edx,4),%ebx
462 addl %ebx, %ecx
463 xorl %ecx, %edi
464 /* round 14 */
465 movl 112(%ebp), %edx
466 movl 116(%ebp), %ecx
467 subl %edi, %edx
468 roll %cl, %edx
469 movl %edx, %ebx
470 xorl %ecx, %ecx
471 movb %dh, %cl
472 andl $255, %ebx
473 shrl $16, %edx
474 xorl %eax, %eax
475 movb %dh, %al
476 andl $255, %edx
477 movl CAST_S_table0(,%ecx,4),%ecx
478 movl CAST_S_table1(,%ebx,4),%ebx
479 addl %ebx, %ecx
480 movl CAST_S_table2(,%eax,4),%ebx
481 xorl %ebx, %ecx
482 movl CAST_S_table3(,%edx,4),%ebx
483 subl %ebx, %ecx
484 xorl %ecx, %esi
485 /* round 13 */
486 movl 104(%ebp), %edx
487 movl 108(%ebp), %ecx
488 xorl %esi, %edx
489 roll %cl, %edx
490 movl %edx, %ebx
491 xorl %ecx, %ecx
492 movb %dh, %cl
493 andl $255, %ebx
494 shrl $16, %edx
495 xorl %eax, %eax
496 movb %dh, %al
497 andl $255, %edx
498 movl CAST_S_table0(,%ecx,4),%ecx
499 movl CAST_S_table1(,%ebx,4),%ebx
500 subl %ebx, %ecx
501 movl CAST_S_table2(,%eax,4),%ebx
502 addl %ebx, %ecx
503 movl CAST_S_table3(,%edx,4),%ebx
504 xorl %ebx, %ecx
505 xorl %ecx, %edi
506 /* round 12 */
507 movl 96(%ebp), %edx
508 movl 100(%ebp), %ecx
509 addl %edi, %edx
510 roll %cl, %edx
511 movl %edx, %ebx
512 xorl %ecx, %ecx
513 movb %dh, %cl
514 andl $255, %ebx
515 shrl $16, %edx
516 xorl %eax, %eax
517 movb %dh, %al
518 andl $255, %edx
519 movl CAST_S_table0(,%ecx,4),%ecx
520 movl CAST_S_table1(,%ebx,4),%ebx
521 xorl %ebx, %ecx
522 movl CAST_S_table2(,%eax,4),%ebx
523 subl %ebx, %ecx
524 movl CAST_S_table3(,%edx,4),%ebx
525 addl %ebx, %ecx
526 xorl %ecx, %esi
527 /* round 11 */
528 movl 88(%ebp), %edx
529 movl 92(%ebp), %ecx
530 subl %esi, %edx
531 roll %cl, %edx
532 movl %edx, %ebx
533 xorl %ecx, %ecx
534 movb %dh, %cl
535 andl $255, %ebx
536 shrl $16, %edx
537 xorl %eax, %eax
538 movb %dh, %al
539 andl $255, %edx
540 movl CAST_S_table0(,%ecx,4),%ecx
541 movl CAST_S_table1(,%ebx,4),%ebx
542 addl %ebx, %ecx
543 movl CAST_S_table2(,%eax,4),%ebx
544 xorl %ebx, %ecx
545 movl CAST_S_table3(,%edx,4),%ebx
546 subl %ebx, %ecx
547 xorl %ecx, %edi
548 /* round 10 */
549 movl 80(%ebp), %edx
550 movl 84(%ebp), %ecx
551 xorl %edi, %edx
552 roll %cl, %edx
553 movl %edx, %ebx
554 xorl %ecx, %ecx
555 movb %dh, %cl
556 andl $255, %ebx
557 shrl $16, %edx
558 xorl %eax, %eax
559 movb %dh, %al
560 andl $255, %edx
561 movl CAST_S_table0(,%ecx,4),%ecx
562 movl CAST_S_table1(,%ebx,4),%ebx
563 subl %ebx, %ecx
564 movl CAST_S_table2(,%eax,4),%ebx
565 addl %ebx, %ecx
566 movl CAST_S_table3(,%edx,4),%ebx
567 xorl %ebx, %ecx
568 xorl %ecx, %esi
569 /* round 9 */
570 movl 72(%ebp), %edx
571 movl 76(%ebp), %ecx
572 addl %esi, %edx
573 roll %cl, %edx
574 movl %edx, %ebx
575 xorl %ecx, %ecx
576 movb %dh, %cl
577 andl $255, %ebx
578 shrl $16, %edx
579 xorl %eax, %eax
580 movb %dh, %al
581 andl $255, %edx
582 movl CAST_S_table0(,%ecx,4),%ecx
583 movl CAST_S_table1(,%ebx,4),%ebx
584 xorl %ebx, %ecx
585 movl CAST_S_table2(,%eax,4),%ebx
586 subl %ebx, %ecx
587 movl CAST_S_table3(,%edx,4),%ebx
588 addl %ebx, %ecx
589 xorl %ecx, %edi
590 /* round 8 */
591 movl 64(%ebp), %edx
592 movl 68(%ebp), %ecx
593 subl %edi, %edx
594 roll %cl, %edx
595 movl %edx, %ebx
596 xorl %ecx, %ecx
597 movb %dh, %cl
598 andl $255, %ebx
599 shrl $16, %edx
600 xorl %eax, %eax
601 movb %dh, %al
602 andl $255, %edx
603 movl CAST_S_table0(,%ecx,4),%ecx
604 movl CAST_S_table1(,%ebx,4),%ebx
605 addl %ebx, %ecx
606 movl CAST_S_table2(,%eax,4),%ebx
607 xorl %ebx, %ecx
608 movl CAST_S_table3(,%edx,4),%ebx
609 subl %ebx, %ecx
610 xorl %ecx, %esi
611 /* round 7 */
612 movl 56(%ebp), %edx
613 movl 60(%ebp), %ecx
614 xorl %esi, %edx
615 roll %cl, %edx
616 movl %edx, %ebx
617 xorl %ecx, %ecx
618 movb %dh, %cl
619 andl $255, %ebx
620 shrl $16, %edx
621 xorl %eax, %eax
622 movb %dh, %al
623 andl $255, %edx
624 movl CAST_S_table0(,%ecx,4),%ecx
625 movl CAST_S_table1(,%ebx,4),%ebx
626 subl %ebx, %ecx
627 movl CAST_S_table2(,%eax,4),%ebx
628 addl %ebx, %ecx
629 movl CAST_S_table3(,%edx,4),%ebx
630 xorl %ebx, %ecx
631 xorl %ecx, %edi
632 /* round 6 */
633 movl 48(%ebp), %edx
634 movl 52(%ebp), %ecx
635 addl %edi, %edx
636 roll %cl, %edx
637 movl %edx, %ebx
638 xorl %ecx, %ecx
639 movb %dh, %cl
640 andl $255, %ebx
641 shrl $16, %edx
642 xorl %eax, %eax
643 movb %dh, %al
644 andl $255, %edx
645 movl CAST_S_table0(,%ecx,4),%ecx
646 movl CAST_S_table1(,%ebx,4),%ebx
647 xorl %ebx, %ecx
648 movl CAST_S_table2(,%eax,4),%ebx
649 subl %ebx, %ecx
650 movl CAST_S_table3(,%edx,4),%ebx
651 addl %ebx, %ecx
652 xorl %ecx, %esi
653 /* round 5 */
654 movl 40(%ebp), %edx
655 movl 44(%ebp), %ecx
656 subl %esi, %edx
657 roll %cl, %edx
658 movl %edx, %ebx
659 xorl %ecx, %ecx
660 movb %dh, %cl
661 andl $255, %ebx
662 shrl $16, %edx
663 xorl %eax, %eax
664 movb %dh, %al
665 andl $255, %edx
666 movl CAST_S_table0(,%ecx,4),%ecx
667 movl CAST_S_table1(,%ebx,4),%ebx
668 addl %ebx, %ecx
669 movl CAST_S_table2(,%eax,4),%ebx
670 xorl %ebx, %ecx
671 movl CAST_S_table3(,%edx,4),%ebx
672 subl %ebx, %ecx
673 xorl %ecx, %edi
674 /* round 4 */
675 movl 32(%ebp), %edx
676 movl 36(%ebp), %ecx
677 xorl %edi, %edx
678 roll %cl, %edx
679 movl %edx, %ebx
680 xorl %ecx, %ecx
681 movb %dh, %cl
682 andl $255, %ebx
683 shrl $16, %edx
684 xorl %eax, %eax
685 movb %dh, %al
686 andl $255, %edx
687 movl CAST_S_table0(,%ecx,4),%ecx
688 movl CAST_S_table1(,%ebx,4),%ebx
689 subl %ebx, %ecx
690 movl CAST_S_table2(,%eax,4),%ebx
691 addl %ebx, %ecx
692 movl CAST_S_table3(,%edx,4),%ebx
693 xorl %ebx, %ecx
694 xorl %ecx, %esi
695 /* round 3 */
696 movl 24(%ebp), %edx
697 movl 28(%ebp), %ecx
698 addl %esi, %edx
699 roll %cl, %edx
700 movl %edx, %ebx
701 xorl %ecx, %ecx
702 movb %dh, %cl
703 andl $255, %ebx
704 shrl $16, %edx
705 xorl %eax, %eax
706 movb %dh, %al
707 andl $255, %edx
708 movl CAST_S_table0(,%ecx,4),%ecx
709 movl CAST_S_table1(,%ebx,4),%ebx
710 xorl %ebx, %ecx
711 movl CAST_S_table2(,%eax,4),%ebx
712 subl %ebx, %ecx
713 movl CAST_S_table3(,%edx,4),%ebx
714 addl %ebx, %ecx
715 xorl %ecx, %edi
716 /* round 2 */
717 movl 16(%ebp), %edx
718 movl 20(%ebp), %ecx
719 subl %edi, %edx
720 roll %cl, %edx
721 movl %edx, %ebx
722 xorl %ecx, %ecx
723 movb %dh, %cl
724 andl $255, %ebx
725 shrl $16, %edx
726 xorl %eax, %eax
727 movb %dh, %al
728 andl $255, %edx
729 movl CAST_S_table0(,%ecx,4),%ecx
730 movl CAST_S_table1(,%ebx,4),%ebx
731 addl %ebx, %ecx
732 movl CAST_S_table2(,%eax,4),%ebx
733 xorl %ebx, %ecx
734 movl CAST_S_table3(,%edx,4),%ebx
735 subl %ebx, %ecx
736 xorl %ecx, %esi
737 /* round 1 */
738 movl 8(%ebp), %edx
739 movl 12(%ebp), %ecx
740 xorl %esi, %edx
741 roll %cl, %edx
742 movl %edx, %ebx
743 xorl %ecx, %ecx
744 movb %dh, %cl
745 andl $255, %ebx
746 shrl $16, %edx
747 xorl %eax, %eax
748 movb %dh, %al
749 andl $255, %edx
750 movl CAST_S_table0(,%ecx,4),%ecx
751 movl CAST_S_table1(,%ebx,4),%ebx
752 subl %ebx, %ecx
753 movl CAST_S_table2(,%eax,4),%ebx
754 addl %ebx, %ecx
755 movl CAST_S_table3(,%edx,4),%ebx
756 xorl %ebx, %ecx
757 xorl %ecx, %edi
758 /* round 0 */
759 movl (%ebp), %edx
760 movl 4(%ebp), %ecx
761 addl %edi, %edx
762 roll %cl, %edx
763 movl %edx, %ebx
764 xorl %ecx, %ecx
765 movb %dh, %cl
766 andl $255, %ebx
767 shrl $16, %edx
768 xorl %eax, %eax
769 movb %dh, %al
770 andl $255, %edx
771 movl CAST_S_table0(,%ecx,4),%ecx
772 movl CAST_S_table1(,%ebx,4),%ebx
773 xorl %ebx, %ecx
774 movl CAST_S_table2(,%eax,4),%ebx
775 subl %ebx, %ecx
776 movl CAST_S_table3(,%edx,4),%ebx
777 addl %ebx, %ecx
778 movl 20(%esp), %eax
779 xorl %ecx, %esi
780 nop
781 movl %edi, 4(%eax)
782 movl %esi, (%eax)
783 popl %edi
784 popl %esi
785 popl %ebx
786 popl %ebp
787 ret
788.CAST_decrypt_end:
789 SIZE(CAST_decrypt,.CAST_decrypt_end-CAST_decrypt)
790.ident "CAST_decrypt"
791.text
792 .align ALIGN
793.globl CAST_cbc_encrypt
794 TYPE(CAST_cbc_encrypt,@function)
795CAST_cbc_encrypt:
796
797 pushl %ebp
798 pushl %ebx
799 pushl %esi
800 pushl %edi
801 movl 28(%esp), %ebp
802 /* getting iv ptr from parameter 4 */
803 movl 36(%esp), %ebx
804 movl (%ebx), %esi
805 movl 4(%ebx), %edi
806 pushl %edi
807 pushl %esi
808 pushl %edi
809 pushl %esi
810 movl %esp, %ebx
811 movl 36(%esp), %esi
812 movl 40(%esp), %edi
813 /* getting encrypt flag from parameter 5 */
814 movl 56(%esp), %ecx
815 /* get and push parameter 3 */
816 movl 48(%esp), %eax
817 pushl %eax
818 pushl %ebx
819 cmpl $0, %ecx
820 jz .L000decrypt
821 andl $4294967288, %ebp
822 movl 8(%esp), %eax
823 movl 12(%esp), %ebx
824 jz .L001encrypt_finish
825.L002encrypt_loop:
826 movl (%esi), %ecx
827 movl 4(%esi), %edx
828 xorl %ecx, %eax
829 xorl %edx, %ebx
830.byte 15
831.byte 200 /* bswapl %eax */
832.byte 15
833.byte 203 /* bswapl %ebx */
834 movl %eax, 8(%esp)
835 movl %ebx, 12(%esp)
836 call CAST_encrypt
837 movl 8(%esp), %eax
838 movl 12(%esp), %ebx
839.byte 15
840.byte 200 /* bswapl %eax */
841.byte 15
842.byte 203 /* bswapl %ebx */
843 movl %eax, (%edi)
844 movl %ebx, 4(%edi)
845 addl $8, %esi
846 addl $8, %edi
847 subl $8, %ebp
848 jnz .L002encrypt_loop
849.L001encrypt_finish:
850 movl 52(%esp), %ebp
851 andl $7, %ebp
852 jz .L003finish
853 xorl %ecx, %ecx
854 xorl %edx, %edx
855 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
856 jmp *%ebp
857.L005ej7:
858 xorl %edx, %edx
859 movb 6(%esi), %dh
860 sall $8, %edx
861.L006ej6:
862 movb 5(%esi), %dh
863.L007ej5:
864 movb 4(%esi), %dl
865.L008ej4:
866 movl (%esi), %ecx
867 jmp .L009ejend
868.L010ej3:
869 movb 2(%esi), %ch
870 xorl %ecx, %ecx
871 sall $8, %ecx
872.L011ej2:
873 movb 1(%esi), %ch
874.L012ej1:
875 movb (%esi), %cl
876.L009ejend:
877 xorl %ecx, %eax
878 xorl %edx, %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl %eax, 8(%esp)
884 movl %ebx, 12(%esp)
885 call CAST_encrypt
886 movl 8(%esp), %eax
887 movl 12(%esp), %ebx
888.byte 15
889.byte 200 /* bswapl %eax */
890.byte 15
891.byte 203 /* bswapl %ebx */
892 movl %eax, (%edi)
893 movl %ebx, 4(%edi)
894 jmp .L003finish
895.align ALIGN
896.L000decrypt:
897 andl $4294967288, %ebp
898 movl 16(%esp), %eax
899 movl 20(%esp), %ebx
900 jz .L013decrypt_finish
901.L014decrypt_loop:
902 movl (%esi), %eax
903 movl 4(%esi), %ebx
904.byte 15
905.byte 200 /* bswapl %eax */
906.byte 15
907.byte 203 /* bswapl %ebx */
908 movl %eax, 8(%esp)
909 movl %ebx, 12(%esp)
910 call CAST_decrypt
911 movl 8(%esp), %eax
912 movl 12(%esp), %ebx
913.byte 15
914.byte 200 /* bswapl %eax */
915.byte 15
916.byte 203 /* bswapl %ebx */
917 movl 16(%esp), %ecx
918 movl 20(%esp), %edx
919 xorl %eax, %ecx
920 xorl %ebx, %edx
921 movl (%esi), %eax
922 movl 4(%esi), %ebx
923 movl %ecx, (%edi)
924 movl %edx, 4(%edi)
925 movl %eax, 16(%esp)
926 movl %ebx, 20(%esp)
927 addl $8, %esi
928 addl $8, %edi
929 subl $8, %ebp
930 jnz .L014decrypt_loop
931.L013decrypt_finish:
932 movl 52(%esp), %ebp
933 andl $7, %ebp
934 jz .L003finish
935 movl (%esi), %eax
936 movl 4(%esi), %ebx
937.byte 15
938.byte 200 /* bswapl %eax */
939.byte 15
940.byte 203 /* bswapl %ebx */
941 movl %eax, 8(%esp)
942 movl %ebx, 12(%esp)
943 call CAST_decrypt
944 movl 8(%esp), %eax
945 movl 12(%esp), %ebx
946.byte 15
947.byte 200 /* bswapl %eax */
948.byte 15
949.byte 203 /* bswapl %ebx */
950 movl 16(%esp), %ecx
951 movl 20(%esp), %edx
952 xorl %eax, %ecx
953 xorl %ebx, %edx
954 movl (%esi), %eax
955 movl 4(%esi), %ebx
956.L015dj7:
957 rorl $16, %edx
958 movb %dl, 6(%edi)
959 shrl $16, %edx
960.L016dj6:
961 movb %dh, 5(%edi)
962.L017dj5:
963 movb %dl, 4(%edi)
964.L018dj4:
965 movl %ecx, (%edi)
966 jmp .L019djend
967.L020dj3:
968 rorl $16, %ecx
969 movb %cl, 2(%edi)
970 sall $16, %ecx
971.L021dj2:
972 movb %ch, 1(%esi)
973.L022dj1:
974 movb %cl, (%esi)
975.L019djend:
976 jmp .L003finish
977.align ALIGN
978.L003finish:
979 movl 60(%esp), %ecx
980 addl $24, %esp
981 movl %eax, (%ecx)
982 movl %ebx, 4(%ecx)
983 popl %edi
984 popl %esi
985 popl %ebx
986 popl %ebp
987 ret
988.align ALIGN
989.L004cbc_enc_jmp_table:
990 .long 0
991 .long .L012ej1
992 .long .L011ej2
993 .long .L010ej3
994 .long .L008ej4
995 .long .L007ej5
996 .long .L006ej6
997 .long .L005ej7
998.align ALIGN
999.L023cbc_dec_jmp_table:
1000 .long 0
1001 .long .L022dj1
1002 .long .L021dj2
1003 .long .L020dj3
1004 .long .L018dj4
1005 .long .L017dj5
1006 .long .L016dj6
1007 .long .L015dj7
1008.CAST_cbc_encrypt_end:
1009 SIZE(CAST_cbc_encrypt,.CAST_cbc_encrypt_end-CAST_cbc_encrypt)
1010.ident "desasm.pl"
diff --git a/src/lib/libcrypto/cast/c_cfb64.c b/src/lib/libcrypto/cast/c_cfb64.c
index c46c375f75..514c005c32 100644
--- a/src/lib/libcrypto/cast/c_cfb64.c
+++ b/src/lib/libcrypto/cast/c_cfb64.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "cast.h" 59#include <openssl/cast.h>
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61 61
62/* The input and output encrypted as though 64bit cfb mode is being 62/* The input and output encrypted as though 64bit cfb mode is being
@@ -64,14 +64,9 @@
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66 66
67void CAST_cfb64_encrypt(in, out, length, schedule, ivec, num, encrypt) 67void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68unsigned char *in; 68 long length, CAST_KEY *schedule, unsigned char *ivec,
69unsigned char *out; 69 int *num, int enc)
70long length;
71CAST_KEY *schedule;
72unsigned char *ivec;
73int *num;
74int encrypt;
75 { 70 {
76 register CAST_LONG v0,v1,t; 71 register CAST_LONG v0,v1,t;
77 register int n= *num; 72 register int n= *num;
@@ -79,8 +74,8 @@ int encrypt;
79 CAST_LONG ti[2]; 74 CAST_LONG ti[2];
80 unsigned char *iv,c,cc; 75 unsigned char *iv,c,cc;
81 76
82 iv=(unsigned char *)ivec; 77 iv=ivec;
83 if (encrypt) 78 if (enc)
84 { 79 {
85 while (l--) 80 while (l--)
86 { 81 {
@@ -89,10 +84,10 @@ int encrypt;
89 n2l(iv,v0); ti[0]=v0; 84 n2l(iv,v0); ti[0]=v0;
90 n2l(iv,v1); ti[1]=v1; 85 n2l(iv,v1); ti[1]=v1;
91 CAST_encrypt((CAST_LONG *)ti,schedule); 86 CAST_encrypt((CAST_LONG *)ti,schedule);
92 iv=(unsigned char *)ivec; 87 iv=ivec;
93 t=ti[0]; l2n(t,iv); 88 t=ti[0]; l2n(t,iv);
94 t=ti[1]; l2n(t,iv); 89 t=ti[1]; l2n(t,iv);
95 iv=(unsigned char *)ivec; 90 iv=ivec;
96 } 91 }
97 c= *(in++)^iv[n]; 92 c= *(in++)^iv[n];
98 *(out++)=c; 93 *(out++)=c;
@@ -109,10 +104,10 @@ int encrypt;
109 n2l(iv,v0); ti[0]=v0; 104 n2l(iv,v0); ti[0]=v0;
110 n2l(iv,v1); ti[1]=v1; 105 n2l(iv,v1); ti[1]=v1;
111 CAST_encrypt((CAST_LONG *)ti,schedule); 106 CAST_encrypt((CAST_LONG *)ti,schedule);
112 iv=(unsigned char *)ivec; 107 iv=ivec;
113 t=ti[0]; l2n(t,iv); 108 t=ti[0]; l2n(t,iv);
114 t=ti[1]; l2n(t,iv); 109 t=ti[1]; l2n(t,iv);
115 iv=(unsigned char *)ivec; 110 iv=ivec;
116 } 111 }
117 cc= *(in++); 112 cc= *(in++);
118 c=iv[n]; 113 c=iv[n];
diff --git a/src/lib/libcrypto/cast/c_ecb.c b/src/lib/libcrypto/cast/c_ecb.c
index f0f2f4df0e..33182f2b71 100644
--- a/src/lib/libcrypto/cast/c_ecb.c
+++ b/src/lib/libcrypto/cast/c_ecb.c
@@ -56,22 +56,20 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "cast.h" 59#include <openssl/cast.h>
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61#include <openssl/opensslv.h>
61 62
62char *CAST_version="CAST part of SSLeay 0.9.0b 29-Jun-1998"; 63char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
63 64
64void CAST_ecb_encrypt(in, out, ks, encrypt) 65void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
65unsigned char *in; 66 CAST_KEY *ks, int enc)
66unsigned char *out;
67CAST_KEY *ks;
68int encrypt;
69 { 67 {
70 CAST_LONG l,d[2]; 68 CAST_LONG l,d[2];
71 69
72 n2l(in,l); d[0]=l; 70 n2l(in,l); d[0]=l;
73 n2l(in,l); d[1]=l; 71 n2l(in,l); d[1]=l;
74 if (encrypt) 72 if (enc)
75 CAST_encrypt(d,ks); 73 CAST_encrypt(d,ks);
76 else 74 else
77 CAST_decrypt(d,ks); 75 CAST_decrypt(d,ks);
diff --git a/src/lib/libcrypto/cast/c_enc.c b/src/lib/libcrypto/cast/c_enc.c
index d998dd4953..0fe2cffecc 100644
--- a/src/lib/libcrypto/cast/c_enc.c
+++ b/src/lib/libcrypto/cast/c_enc.c
@@ -56,12 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "cast.h" 59#include <openssl/cast.h>
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61 61
62void CAST_encrypt(data,key) 62void CAST_encrypt(CAST_LONG *data, CAST_KEY *key)
63CAST_LONG *data;
64CAST_KEY *key;
65 { 63 {
66 register CAST_LONG l,r,*k,t; 64 register CAST_LONG l,r,*k,t;
67 65
@@ -81,18 +79,19 @@ CAST_KEY *key;
81 E_CAST( 9,k,r,l,+,^,-); 79 E_CAST( 9,k,r,l,+,^,-);
82 E_CAST(10,k,l,r,^,-,+); 80 E_CAST(10,k,l,r,^,-,+);
83 E_CAST(11,k,r,l,-,+,^); 81 E_CAST(11,k,r,l,-,+,^);
84 E_CAST(12,k,l,r,+,^,-); 82 if(!key->short_key)
85 E_CAST(13,k,r,l,^,-,+); 83 {
86 E_CAST(14,k,l,r,-,+,^); 84 E_CAST(12,k,l,r,+,^,-);
87 E_CAST(15,k,r,l,+,^,-); 85 E_CAST(13,k,r,l,^,-,+);
86 E_CAST(14,k,l,r,-,+,^);
87 E_CAST(15,k,r,l,+,^,-);
88 }
88 89
89 data[1]=l&0xffffffffL; 90 data[1]=l&0xffffffffL;
90 data[0]=r&0xffffffffL; 91 data[0]=r&0xffffffffL;
91 } 92 }
92 93
93void CAST_decrypt(data,key) 94void CAST_decrypt(CAST_LONG *data, CAST_KEY *key)
94CAST_LONG *data;
95CAST_KEY *key;
96 { 95 {
97 register CAST_LONG l,r,*k,t; 96 register CAST_LONG l,r,*k,t;
98 97
@@ -100,10 +99,13 @@ CAST_KEY *key;
100 l=data[0]; 99 l=data[0];
101 r=data[1]; 100 r=data[1];
102 101
103 E_CAST(15,k,l,r,+,^,-); 102 if(!key->short_key)
104 E_CAST(14,k,r,l,-,+,^); 103 {
105 E_CAST(13,k,l,r,^,-,+); 104 E_CAST(15,k,l,r,+,^,-);
106 E_CAST(12,k,r,l,+,^,-); 105 E_CAST(14,k,r,l,-,+,^);
106 E_CAST(13,k,l,r,^,-,+);
107 E_CAST(12,k,r,l,+,^,-);
108 }
107 E_CAST(11,k,l,r,-,+,^); 109 E_CAST(11,k,l,r,-,+,^);
108 E_CAST(10,k,r,l,^,-,+); 110 E_CAST(10,k,r,l,^,-,+);
109 E_CAST( 9,k,l,r,+,^,-); 111 E_CAST( 9,k,l,r,+,^,-);
@@ -121,20 +123,15 @@ CAST_KEY *key;
121 data[0]=r&0xffffffffL; 123 data[0]=r&0xffffffffL;
122 } 124 }
123 125
124void CAST_cbc_encrypt(in, out, length, ks, iv, encrypt) 126void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
125unsigned char *in; 127 CAST_KEY *ks, unsigned char *iv, int enc)
126unsigned char *out;
127long length;
128CAST_KEY *ks;
129unsigned char *iv;
130int encrypt;
131 { 128 {
132 register CAST_LONG tin0,tin1; 129 register CAST_LONG tin0,tin1;
133 register CAST_LONG tout0,tout1,xor0,xor1; 130 register CAST_LONG tout0,tout1,xor0,xor1;
134 register long l=length; 131 register long l=length;
135 CAST_LONG tin[2]; 132 CAST_LONG tin[2];
136 133
137 if (encrypt) 134 if (enc)
138 { 135 {
139 n2l(iv,tout0); 136 n2l(iv,tout0);
140 n2l(iv,tout1); 137 n2l(iv,tout1);
diff --git a/src/lib/libcrypto/cast/c_ofb64.c b/src/lib/libcrypto/cast/c_ofb64.c
index 2aad2d6d96..fd0469a62f 100644
--- a/src/lib/libcrypto/cast/c_ofb64.c
+++ b/src/lib/libcrypto/cast/c_ofb64.c
@@ -56,20 +56,16 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "cast.h" 59#include <openssl/cast.h>
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61 61
62/* The input and output encrypted as though 64bit ofb mode is being 62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the 63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num; 64 * 64bit block we have used is contained in *num;
65 */ 65 */
66void CAST_ofb64_encrypt(in, out, length, schedule, ivec, num) 66void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
67unsigned char *in; 67 long length, CAST_KEY *schedule, unsigned char *ivec,
68unsigned char *out; 68 int *num)
69long length;
70CAST_KEY *schedule;
71unsigned char *ivec;
72int *num;
73 { 69 {
74 register CAST_LONG v0,v1,t; 70 register CAST_LONG v0,v1,t;
75 register int n= *num; 71 register int n= *num;
@@ -80,7 +76,7 @@ int *num;
80 unsigned char *iv; 76 unsigned char *iv;
81 int save=0; 77 int save=0;
82 78
83 iv=(unsigned char *)ivec; 79 iv=ivec;
84 n2l(iv,v0); 80 n2l(iv,v0);
85 n2l(iv,v1); 81 n2l(iv,v1);
86 ti[0]=v0; 82 ti[0]=v0;
@@ -105,7 +101,7 @@ int *num;
105 { 101 {
106 v0=ti[0]; 102 v0=ti[0];
107 v1=ti[1]; 103 v1=ti[1];
108 iv=(unsigned char *)ivec; 104 iv=ivec;
109 l2n(v0,iv); 105 l2n(v0,iv);
110 l2n(v1,iv); 106 l2n(v1,iv);
111 } 107 }
diff --git a/src/lib/libcrypto/cast/c_skey.c b/src/lib/libcrypto/cast/c_skey.c
index 2fc3363dcd..acf2c3eeb5 100644
--- a/src/lib/libcrypto/cast/c_skey.c
+++ b/src/lib/libcrypto/cast/c_skey.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "cast.h" 59#include <openssl/cast.h>
60#include "cast_lcl.h" 60#include "cast_lcl.h"
61#include "cast_s.h" 61#include "cast_s.h"
62 62
@@ -72,10 +72,7 @@
72#define S6 CAST_S_table6 72#define S6 CAST_S_table6
73#define S7 CAST_S_table7 73#define S7 CAST_S_table7
74 74
75void CAST_set_key(key,len,data) 75void CAST_set_key(CAST_KEY *key, int len, unsigned char *data)
76CAST_KEY *key;
77int len;
78unsigned char *data;
79 { 76 {
80 CAST_LONG x[16]; 77 CAST_LONG x[16];
81 CAST_LONG z[16]; 78 CAST_LONG z[16];
@@ -88,6 +85,10 @@ unsigned char *data;
88 if (len > 16) len=16; 85 if (len > 16) len=16;
89 for (i=0; i<len; i++) 86 for (i=0; i<len; i++)
90 x[i]=data[i]; 87 x[i]=data[i];
88 if(len <= 10)
89 key->short_key=1;
90 else
91 key->short_key=0;
91 92
92 K= &k[0]; 93 K= &k[0];
93 X[0]=((x[ 0]<<24)|(x[ 1]<<16)|(x[ 2]<<8)|x[ 3])&0xffffffffL; 94 X[0]=((x[ 0]<<24)|(x[ 1]<<16)|(x[ 2]<<8)|x[ 3])&0xffffffffL;
diff --git a/src/lib/libcrypto/cast/cast.h b/src/lib/libcrypto/cast/cast.h
index 528cb7c824..6cc5e8aa8c 100644
--- a/src/lib/libcrypto/cast/cast.h
+++ b/src/lib/libcrypto/cast/cast.h
@@ -63,6 +63,10 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_CAST
67#error CAST is disabled.
68#endif
69
66#define CAST_ENCRYPT 1 70#define CAST_ENCRYPT 1
67#define CAST_DECRYPT 0 71#define CAST_DECRYPT 0
68 72
@@ -74,33 +78,23 @@ extern "C" {
74typedef struct cast_key_st 78typedef struct cast_key_st
75 { 79 {
76 CAST_LONG data[32]; 80 CAST_LONG data[32];
81 int short_key; /* Use reduced rounds for short key */
77 } CAST_KEY; 82 } CAST_KEY;
78 83
79#ifndef NOPROTO
80 84
81void CAST_set_key(CAST_KEY *key, int len, unsigned char *data); 85void CAST_set_key(CAST_KEY *key, int len, unsigned char *data);
82void CAST_ecb_encrypt(unsigned char *in,unsigned char *out,CAST_KEY *key, 86void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key,
83 int enc); 87 int enc);
84void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); 88void CAST_encrypt(CAST_LONG *data,CAST_KEY *key);
85void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); 89void CAST_decrypt(CAST_LONG *data,CAST_KEY *key);
86void CAST_cbc_encrypt(unsigned char *in, unsigned char *out, long length, 90void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
87 CAST_KEY *ks, unsigned char *iv, int enc); 91 CAST_KEY *ks, unsigned char *iv, int enc);
88void CAST_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 92void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
89 CAST_KEY *schedule, unsigned char *ivec, int *num, int enc); 93 long length, CAST_KEY *schedule, unsigned char *ivec,
90void CAST_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, 94 int *num, int enc);
91 CAST_KEY *schedule, unsigned char *ivec, int *num); 95void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
92 96 long length, CAST_KEY *schedule, unsigned char *ivec,
93#else 97 int *num);
94
95void CAST_set_key();
96void CAST_ecb_encrypt();
97void CAST_encrypt();
98void CAST_decrypt();
99void CAST_cbc_encrypt();
100void CAST_cfb64_encrypt();
101void CAST_ofb64_encrypt();
102
103#endif
104 98
105#ifdef __cplusplus 99#ifdef __cplusplus
106} 100}
diff --git a/src/lib/libcrypto/cast/cast_lcl.h b/src/lib/libcrypto/cast/cast_lcl.h
index 6587952a96..83cf382a91 100644
--- a/src/lib/libcrypto/cast/cast_lcl.h
+++ b/src/lib/libcrypto/cast/cast_lcl.h
@@ -60,6 +60,9 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#endif 61#endif
62 62
63
64#include "openssl/e_os.h" /* OPENSSL_EXTERN */
65
63#undef c2l 66#undef c2l
64#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ 67#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
65 l|=((unsigned long)(*((c)++)))<< 8L, \ 68 l|=((unsigned long)(*((c)++)))<< 8L, \
@@ -213,12 +216,11 @@
213 } 216 }
214#endif 217#endif
215 218
216extern CAST_LONG CAST_S_table0[256]; 219OPENSSL_EXTERN CAST_LONG CAST_S_table0[256];
217extern CAST_LONG CAST_S_table1[256]; 220OPENSSL_EXTERN CAST_LONG CAST_S_table1[256];
218extern CAST_LONG CAST_S_table2[256]; 221OPENSSL_EXTERN CAST_LONG CAST_S_table2[256];
219extern CAST_LONG CAST_S_table3[256]; 222OPENSSL_EXTERN CAST_LONG CAST_S_table3[256];
220extern CAST_LONG CAST_S_table4[256]; 223OPENSSL_EXTERN CAST_LONG CAST_S_table4[256];
221extern CAST_LONG CAST_S_table5[256]; 224OPENSSL_EXTERN CAST_LONG CAST_S_table5[256];
222extern CAST_LONG CAST_S_table6[256]; 225OPENSSL_EXTERN CAST_LONG CAST_S_table6[256];
223extern CAST_LONG CAST_S_table7[256]; 226OPENSSL_EXTERN CAST_LONG CAST_S_table7[256];
224
diff --git a/src/lib/libcrypto/cast/cast_s.h b/src/lib/libcrypto/cast/cast_s.h
index 8fe0152149..9af28972c5 100644
--- a/src/lib/libcrypto/cast/cast_s.h
+++ b/src/lib/libcrypto/cast/cast_s.h
@@ -55,7 +55,7 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58CAST_LONG CAST_S_table0[256]={ 58OPENSSL_GLOBAL CAST_LONG CAST_S_table0[256]={
59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, 59 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a,
60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, 60 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949,
61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, 61 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675,
@@ -121,7 +121,7 @@ CAST_LONG CAST_S_table0[256]={
121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, 121 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d,
122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, 122 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf,
123 }; 123 };
124CAST_LONG CAST_S_table1[256]={ 124OPENSSL_GLOBAL CAST_LONG CAST_S_table1[256]={
125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, 125 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380,
126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, 126 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651,
127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, 127 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba,
@@ -187,7 +187,7 @@ CAST_LONG CAST_S_table1[256]={
187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, 187 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef,
188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, 188 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1,
189 }; 189 };
190CAST_LONG CAST_S_table2[256]={ 190OPENSSL_GLOBAL CAST_LONG CAST_S_table2[256]={
191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, 191 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907,
192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, 192 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90,
193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, 193 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae,
@@ -253,7 +253,7 @@ CAST_LONG CAST_S_table2[256]={
253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, 253 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5,
254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, 254 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783,
255 }; 255 };
256CAST_LONG CAST_S_table3[256]={ 256OPENSSL_GLOBAL CAST_LONG CAST_S_table3[256]={
257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, 257 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298,
258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, 258 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1,
259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, 259 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120,
@@ -319,7 +319,7 @@ CAST_LONG CAST_S_table3[256]={
319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, 319 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e,
320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, 320 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2,
321 }; 321 };
322CAST_LONG CAST_S_table4[256]={ 322OPENSSL_GLOBAL CAST_LONG CAST_S_table4[256]={
323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, 323 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911,
324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, 324 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f,
325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, 325 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00,
@@ -385,7 +385,7 @@ CAST_LONG CAST_S_table4[256]={
385 0xe822fe15,0x88570983,0x750e6249,0xda627e55, 385 0xe822fe15,0x88570983,0x750e6249,0xda627e55,
386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, 386 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4,
387 }; 387 };
388CAST_LONG CAST_S_table5[256]={ 388OPENSSL_GLOBAL CAST_LONG CAST_S_table5[256]={
389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, 389 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c,
390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, 390 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac,
391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, 391 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9,
@@ -451,7 +451,7 @@ CAST_LONG CAST_S_table5[256]={
451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, 451 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454,
452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, 452 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f,
453 }; 453 };
454CAST_LONG CAST_S_table6[256]={ 454OPENSSL_GLOBAL CAST_LONG CAST_S_table6[256]={
455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, 455 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693,
456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, 456 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f,
457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, 457 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82,
@@ -517,7 +517,7 @@ CAST_LONG CAST_S_table6[256]={
517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, 517 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada,
518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, 518 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3,
519 }; 519 };
520CAST_LONG CAST_S_table7[256]={ 520OPENSSL_GLOBAL CAST_LONG CAST_S_table7[256]={
521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, 521 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095,
522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, 522 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5,
523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, 523 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174,
diff --git a/src/lib/libcrypto/cast/cast_spd.c b/src/lib/libcrypto/cast/cast_spd.c
index ab75e65386..c0726906c2 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(MSDOS) && (!defined(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> 70OPENSSL_DECLARE_EXIT
71extern 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.
84struct 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(VMS) && defined(__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)
116long run=0; 111long run=0;
117 112
118#ifndef NOPROTO
119double Time_F(int s); 113double Time_F(int s);
120#else
121double 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
132SIGRETTYPE sig_done(int sig); 121SIGRETTYPE sig_done(int sig);
133#else 122SIGRETTYPE sig_done(int sig)
134SIGRETTYPE sig_done();
135#endif
136
137SIGRETTYPE sig_done(sig)
138int 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
151double Time_F(s) 135double Time_F(int s)
152int 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
188int main(argc,argv) 171int main(int argc, char **argv)
189int argc;
190char **argv;
191 { 172 {
192 long count; 173 long count;
193 static unsigned char buf[BUFSIZE]; 174 static unsigned char buf[BUFSIZE];
diff --git a/src/lib/libcrypto/cast/castopts.c b/src/lib/libcrypto/cast/castopts.c
index 68cf5a4a60..642e9725af 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(MSDOS) && (!defined(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> 70OPENSSL_DECLARE_EXIT
71extern 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.
84struct 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(VMS) && defined(__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)
153long run=0; 148long run=0;
154 149
155#ifndef NOPROTO
156double Time_F(int s); 150double Time_F(int s);
157#else
158double 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
169SIGRETTYPE sig_done(int sig); 158SIGRETTYPE sig_done(int sig);
170#else 159SIGRETTYPE sig_done(int sig)
171SIGRETTYPE sig_done();
172#endif
173
174SIGRETTYPE sig_done(sig)
175int 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
188double Time_F(s) 172double Time_F(int s)
189int 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
250int main(argc,argv) 233int main(int argc, char **argv)
251int argc;
252char **argv;
253 { 234 {
254 long count; 235 long count;
255 static unsigned char buf[BUFSIZE]; 236 static unsigned char buf[BUFSIZE];
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
37void main(int argc,char *argv[]) 37void 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..3244b119e9 100644
--- a/src/lib/libcrypto/cast/casttest.c
+++ b/src/lib/libcrypto/cast/casttest.c
@@ -59,9 +59,17 @@
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 NO_CAST
64int main(int argc, char *argv[])
65{
66 printf("No CAST support\n");
67 return(0);
68}
69#else
70#include <openssl/cast.h>
71
72#define FULL_TEST
65 73
66unsigned char k[16]={ 74unsigned char k[16]={
67 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
@@ -70,7 +78,7 @@ unsigned char k[16]={
70 78
71unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; 79unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
72 80
73int k_len[3]={16,10}; 81int k_len[3]={16,10,5};
74unsigned char c[3][8]={ 82unsigned 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},
@@ -120,104 +128,103 @@ static unsigned char cfb_cipher64[CFB_TEST_SIZE]={
120 }; 128 };
121#endif 129#endif
122 130
123int main(argc,argv) 131int main(int argc, char *argv[])
124int argc; 132 {
125char *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