diff options
Diffstat (limited to 'src/lib/libcrypto/des')
30 files changed, 0 insertions, 5183 deletions
diff --git a/src/lib/libcrypto/des/COPYRIGHT b/src/lib/libcrypto/des/COPYRIGHT deleted file mode 100644 index 5469e1e469..0000000000 --- a/src/lib/libcrypto/des/COPYRIGHT +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
| 2 | All rights reserved. | ||
| 3 | |||
| 4 | This package is an DES implementation written by Eric Young (eay@cryptsoft.com). | ||
| 5 | The implementation was written so as to conform with MIT's libdes. | ||
| 6 | |||
| 7 | This library is free for commercial and non-commercial use as long as | ||
| 8 | the following conditions are aheared to. The following conditions | ||
| 9 | apply to all code found in this distribution. | ||
| 10 | |||
| 11 | Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 12 | the code are not to be removed. | ||
| 13 | If this package is used in a product, Eric Young should be given attribution | ||
| 14 | as the author of that the SSL library. This can be in the form of a textual | ||
| 15 | message at program startup or in documentation (online or textual) provided | ||
| 16 | with the package. | ||
| 17 | |||
| 18 | Redistribution and use in source and binary forms, with or without | ||
| 19 | modification, are permitted provided that the following conditions | ||
| 20 | are met: | ||
| 21 | 1. Redistributions of source code must retain the copyright | ||
| 22 | notice, this list of conditions and the following disclaimer. | ||
| 23 | 2. Redistributions in binary form must reproduce the above copyright | ||
| 24 | notice, this list of conditions and the following disclaimer in the | ||
| 25 | documentation and/or other materials provided with the distribution. | ||
| 26 | 3. All advertising materials mentioning features or use of this software | ||
| 27 | must display the following acknowledgement: | ||
| 28 | This product includes software developed by Eric Young (eay@cryptsoft.com) | ||
| 29 | |||
| 30 | THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 31 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 32 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 33 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 34 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 35 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 36 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 37 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 38 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 39 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 40 | SUCH DAMAGE. | ||
| 41 | |||
| 42 | The license and distribution terms for any publically available version or | ||
| 43 | derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 44 | copied and put under another distrubution license | ||
| 45 | [including the GNU Public License.] | ||
| 46 | |||
| 47 | The reason behind this being stated in this direct manner is past | ||
| 48 | experience in code simply being copied and the attribution removed | ||
| 49 | from it and then being distributed as part of other packages. This | ||
| 50 | implementation was a non-trivial and unpaid effort. | ||
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl deleted file mode 100644 index 3d41d82f69..0000000000 --- a/src/lib/libcrypto/des/asm/crypt586.pl +++ /dev/null | |||
| @@ -1,204 +0,0 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | # | ||
| 3 | # The inner loop instruction sequence and the IP/FP modifications are from | ||
| 4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> | ||
| 5 | # I've added the stuff needed for crypt() but I've not worried about making | ||
| 6 | # things perfect. | ||
| 7 | # | ||
| 8 | |||
| 9 | push(@INC,"perlasm","../../perlasm"); | ||
| 10 | require "x86asm.pl"; | ||
| 11 | |||
| 12 | &asm_init($ARGV[0],"crypt586.pl"); | ||
| 13 | |||
| 14 | $L="edi"; | ||
| 15 | $R="esi"; | ||
| 16 | |||
| 17 | &external_label("DES_SPtrans"); | ||
| 18 | &fcrypt_body("fcrypt_body"); | ||
| 19 | &asm_finish(); | ||
| 20 | |||
| 21 | sub fcrypt_body | ||
| 22 | { | ||
| 23 | local($name,$do_ip)=@_; | ||
| 24 | |||
| 25 | &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); | ||
| 26 | |||
| 27 | &comment(""); | ||
| 28 | &comment("Load the 2 words"); | ||
| 29 | $ks="ebp"; | ||
| 30 | |||
| 31 | &xor( $L, $L); | ||
| 32 | &xor( $R, $R); | ||
| 33 | &mov($ks,&wparam(1)); | ||
| 34 | |||
| 35 | &push(&DWC(25)); # add a variable | ||
| 36 | |||
| 37 | &set_label("start"); | ||
| 38 | for ($i=0; $i<16; $i+=2) | ||
| 39 | { | ||
| 40 | &comment(""); | ||
| 41 | &comment("Round $i"); | ||
| 42 | &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 43 | |||
| 44 | &comment(""); | ||
| 45 | &comment("Round ".sprintf("%d",$i+1)); | ||
| 46 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 47 | } | ||
| 48 | &mov("ebx", &swtmp(0)); | ||
| 49 | &mov("eax", $L); | ||
| 50 | &dec("ebx"); | ||
| 51 | &mov($L, $R); | ||
| 52 | &mov($R, "eax"); | ||
| 53 | &mov(&swtmp(0), "ebx"); | ||
| 54 | &jnz(&label("start")); | ||
| 55 | |||
| 56 | &comment(""); | ||
| 57 | &comment("FP"); | ||
| 58 | &mov("edx",&wparam(0)); | ||
| 59 | |||
| 60 | &FP_new($R,$L,"eax",3); | ||
| 61 | &mov(&DWP(0,"edx","",0),"eax"); | ||
| 62 | &mov(&DWP(4,"edx","",0),$L); | ||
| 63 | |||
| 64 | &pop("ecx"); # remove variable | ||
| 65 | |||
| 66 | &function_end($name); | ||
| 67 | } | ||
| 68 | |||
| 69 | sub D_ENCRYPT | ||
| 70 | { | ||
| 71 | local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; | ||
| 72 | |||
| 73 | &mov( $u, &wparam(2)); # 2 | ||
| 74 | &mov( $t, $R); | ||
| 75 | &shr( $t, 16); # 1 | ||
| 76 | &mov( $tmp2, &wparam(3)); # 2 | ||
| 77 | &xor( $t, $R); # 1 | ||
| 78 | |||
| 79 | &and( $u, $t); # 2 | ||
| 80 | &and( $t, $tmp2); # 2 | ||
| 81 | |||
| 82 | &mov( $tmp1, $u); | ||
| 83 | &shl( $tmp1, 16); # 1 | ||
| 84 | &mov( $tmp2, $t); | ||
| 85 | &shl( $tmp2, 16); # 1 | ||
| 86 | &xor( $u, $tmp1); # 2 | ||
| 87 | &xor( $t, $tmp2); # 2 | ||
| 88 | &mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2 | ||
| 89 | &xor( $u, $tmp1); | ||
| 90 | &mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2 | ||
| 91 | &xor( $u, $R); | ||
| 92 | &xor( $t, $R); | ||
| 93 | &xor( $t, $tmp2); | ||
| 94 | |||
| 95 | &and( $u, "0xfcfcfcfc" ); # 2 | ||
| 96 | &xor( $tmp1, $tmp1); # 1 | ||
| 97 | &and( $t, "0xcfcfcfcf" ); # 2 | ||
| 98 | &xor( $tmp2, $tmp2); | ||
| 99 | &movb( &LB($tmp1), &LB($u) ); | ||
| 100 | &movb( &LB($tmp2), &HB($u) ); | ||
| 101 | &rotr( $t, 4 ); | ||
| 102 | &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); | ||
| 103 | &movb( &LB($tmp1), &LB($t) ); | ||
| 104 | &xor( $L, $ks); | ||
| 105 | &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0)); | ||
| 106 | &xor( $L, $ks); | ||
| 107 | &movb( &LB($tmp2), &HB($t) ); | ||
| 108 | &shr( $u, 16); | ||
| 109 | &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); | ||
| 110 | &xor( $L, $ks); | ||
| 111 | &movb( &LB($tmp1), &HB($u) ); | ||
| 112 | &shr( $t, 16); | ||
| 113 | &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); | ||
| 114 | &xor( $L, $ks); | ||
| 115 | &mov( $ks, &wparam(1)); | ||
| 116 | &movb( &LB($tmp2), &HB($t) ); | ||
| 117 | &and( $u, "0xff" ); | ||
| 118 | &and( $t, "0xff" ); | ||
| 119 | &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); | ||
| 120 | &xor( $L, $tmp1); | ||
| 121 | &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); | ||
| 122 | &xor( $L, $tmp1); | ||
| 123 | &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); | ||
| 124 | &xor( $L, $tmp1); | ||
| 125 | &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); | ||
| 126 | &xor( $L, $tmp1); | ||
| 127 | } | ||
| 128 | |||
| 129 | sub n2a | ||
| 130 | { | ||
| 131 | sprintf("%d",$_[0]); | ||
| 132 | } | ||
| 133 | |||
| 134 | # now has a side affect of rotating $a by $shift | ||
| 135 | sub R_PERM_OP | ||
| 136 | { | ||
| 137 | local($a,$b,$tt,$shift,$mask,$last)=@_; | ||
| 138 | |||
| 139 | &rotl( $a, $shift ) if ($shift != 0); | ||
| 140 | &mov( $tt, $a ); | ||
| 141 | &xor( $a, $b ); | ||
| 142 | &and( $a, $mask ); | ||
| 143 | if ($notlast eq $b) | ||
| 144 | { | ||
| 145 | &xor( $b, $a ); | ||
| 146 | &xor( $tt, $a ); | ||
| 147 | } | ||
| 148 | else | ||
| 149 | { | ||
| 150 | &xor( $tt, $a ); | ||
| 151 | &xor( $b, $a ); | ||
| 152 | } | ||
| 153 | &comment(""); | ||
| 154 | } | ||
| 155 | |||
| 156 | sub IP_new | ||
| 157 | { | ||
| 158 | local($l,$r,$tt,$lr)=@_; | ||
| 159 | |||
| 160 | &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l); | ||
| 161 | &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l); | ||
| 162 | &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r); | ||
| 163 | &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r); | ||
| 164 | &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r); | ||
| 165 | |||
| 166 | if ($lr != 3) | ||
| 167 | { | ||
| 168 | if (($lr-3) < 0) | ||
| 169 | { &rotr($tt, 3-$lr); } | ||
| 170 | else { &rotl($tt, $lr-3); } | ||
| 171 | } | ||
| 172 | if ($lr != 2) | ||
| 173 | { | ||
| 174 | if (($lr-2) < 0) | ||
| 175 | { &rotr($r, 2-$lr); } | ||
| 176 | else { &rotl($r, $lr-2); } | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | sub FP_new | ||
| 181 | { | ||
| 182 | local($l,$r,$tt,$lr)=@_; | ||
| 183 | |||
| 184 | if ($lr != 2) | ||
| 185 | { | ||
| 186 | if (($lr-2) < 0) | ||
| 187 | { &rotl($r, 2-$lr); } | ||
| 188 | else { &rotr($r, $lr-2); } | ||
| 189 | } | ||
| 190 | if ($lr != 3) | ||
| 191 | { | ||
| 192 | if (($lr-3) < 0) | ||
| 193 | { &rotl($l, 3-$lr); } | ||
| 194 | else { &rotr($l, $lr-3); } | ||
| 195 | } | ||
| 196 | |||
| 197 | &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r); | ||
| 198 | &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r); | ||
| 199 | &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l); | ||
| 200 | &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l); | ||
| 201 | &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r); | ||
| 202 | &rotr($tt , 4); | ||
| 203 | } | ||
| 204 | |||
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl deleted file mode 100644 index 0d08e8a3a9..0000000000 --- a/src/lib/libcrypto/des/asm/des-586.pl +++ /dev/null | |||
| @@ -1,253 +0,0 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | # | ||
| 3 | # The inner loop instruction sequence and the IP/FP modifications are from | ||
| 4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> | ||
| 5 | # | ||
| 6 | |||
| 7 | push(@INC,"perlasm","../../perlasm"); | ||
| 8 | require "x86asm.pl"; | ||
| 9 | require "cbc.pl"; | ||
| 10 | require "desboth.pl"; | ||
| 11 | |||
| 12 | # base code is in microsft | ||
| 13 | # op dest, source | ||
| 14 | # format. | ||
| 15 | # | ||
| 16 | |||
| 17 | &asm_init($ARGV[0],"des-586.pl"); | ||
| 18 | |||
| 19 | $L="edi"; | ||
| 20 | $R="esi"; | ||
| 21 | |||
| 22 | &external_label("DES_SPtrans"); | ||
| 23 | &DES_encrypt("DES_encrypt1",1); | ||
| 24 | &DES_encrypt("DES_encrypt2",0); | ||
| 25 | &DES_encrypt3("DES_encrypt3",1); | ||
| 26 | &DES_encrypt3("DES_decrypt3",0); | ||
| 27 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | ||
| 28 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | ||
| 29 | |||
| 30 | &asm_finish(); | ||
| 31 | |||
| 32 | sub DES_encrypt | ||
| 33 | { | ||
| 34 | local($name,$do_ip)=@_; | ||
| 35 | |||
| 36 | &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); | ||
| 37 | |||
| 38 | &push("esi"); | ||
| 39 | &push("edi"); | ||
| 40 | |||
| 41 | &comment(""); | ||
| 42 | &comment("Load the 2 words"); | ||
| 43 | $ks="ebp"; | ||
| 44 | |||
| 45 | if ($do_ip) | ||
| 46 | { | ||
| 47 | &mov($R,&wparam(0)); | ||
| 48 | &xor( "ecx", "ecx" ); | ||
| 49 | |||
| 50 | &push("ebx"); | ||
| 51 | &push("ebp"); | ||
| 52 | |||
| 53 | &mov("eax",&DWP(0,$R,"",0)); | ||
| 54 | &mov("ebx",&wparam(2)); # get encrypt flag | ||
| 55 | &mov($L,&DWP(4,$R,"",0)); | ||
| 56 | &comment(""); | ||
| 57 | &comment("IP"); | ||
| 58 | &IP_new("eax",$L,$R,3); | ||
| 59 | } | ||
| 60 | else | ||
| 61 | { | ||
| 62 | &mov("eax",&wparam(0)); | ||
| 63 | &xor( "ecx", "ecx" ); | ||
| 64 | |||
| 65 | &push("ebx"); | ||
| 66 | &push("ebp"); | ||
| 67 | |||
| 68 | &mov($R,&DWP(0,"eax","",0)); | ||
| 69 | &mov("ebx",&wparam(2)); # get encrypt flag | ||
| 70 | &rotl($R,3); | ||
| 71 | &mov($L,&DWP(4,"eax","",0)); | ||
| 72 | &rotl($L,3); | ||
| 73 | } | ||
| 74 | |||
| 75 | &mov( $ks, &wparam(1) ); | ||
| 76 | &cmp("ebx","0"); | ||
| 77 | &je(&label("start_decrypt")); | ||
| 78 | |||
| 79 | for ($i=0; $i<16; $i+=2) | ||
| 80 | { | ||
| 81 | &comment(""); | ||
| 82 | &comment("Round $i"); | ||
| 83 | &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 84 | |||
| 85 | &comment(""); | ||
| 86 | &comment("Round ".sprintf("%d",$i+1)); | ||
| 87 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 88 | } | ||
| 89 | &jmp(&label("end")); | ||
| 90 | |||
| 91 | &set_label("start_decrypt"); | ||
| 92 | |||
| 93 | for ($i=15; $i>0; $i-=2) | ||
| 94 | { | ||
| 95 | &comment(""); | ||
| 96 | &comment("Round $i"); | ||
| 97 | &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 98 | &comment(""); | ||
| 99 | &comment("Round ".sprintf("%d",$i-1)); | ||
| 100 | &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | ||
| 101 | } | ||
| 102 | |||
| 103 | &set_label("end"); | ||
| 104 | |||
| 105 | if ($do_ip) | ||
| 106 | { | ||
| 107 | &comment(""); | ||
| 108 | &comment("FP"); | ||
| 109 | &mov("edx",&wparam(0)); | ||
| 110 | &FP_new($L,$R,"eax",3); | ||
| 111 | |||
| 112 | &mov(&DWP(0,"edx","",0),"eax"); | ||
| 113 | &mov(&DWP(4,"edx","",0),$R); | ||
| 114 | } | ||
| 115 | else | ||
| 116 | { | ||
| 117 | &comment(""); | ||
| 118 | &comment("Fixup"); | ||
| 119 | &rotr($L,3); # r | ||
| 120 | &mov("eax",&wparam(0)); | ||
| 121 | &rotr($R,3); # l | ||
| 122 | &mov(&DWP(0,"eax","",0),$L); | ||
| 123 | &mov(&DWP(4,"eax","",0),$R); | ||
| 124 | } | ||
| 125 | |||
| 126 | &pop("ebp"); | ||
| 127 | &pop("ebx"); | ||
| 128 | &pop("edi"); | ||
| 129 | &pop("esi"); | ||
| 130 | &ret(); | ||
| 131 | |||
| 132 | &function_end_B($name); | ||
| 133 | } | ||
| 134 | |||
| 135 | sub D_ENCRYPT | ||
| 136 | { | ||
| 137 | local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; | ||
| 138 | |||
| 139 | &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); | ||
| 140 | &xor( $tmp1, $tmp1); | ||
| 141 | &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); | ||
| 142 | &xor( $u, $R); | ||
| 143 | &xor( $t, $R); | ||
| 144 | &and( $u, "0xfcfcfcfc" ); | ||
| 145 | &and( $t, "0xcfcfcfcf" ); | ||
| 146 | &movb( &LB($tmp1), &LB($u) ); | ||
| 147 | &movb( &LB($tmp2), &HB($u) ); | ||
| 148 | &rotr( $t, 4 ); | ||
| 149 | &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); | ||
| 150 | &movb( &LB($tmp1), &LB($t) ); | ||
| 151 | &xor( $L, $ks); | ||
| 152 | &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0)); | ||
| 153 | &xor( $L, $ks); ###### | ||
| 154 | &movb( &LB($tmp2), &HB($t) ); | ||
| 155 | &shr( $u, 16); | ||
| 156 | &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); | ||
| 157 | &xor( $L, $ks); ###### | ||
| 158 | &movb( &LB($tmp1), &HB($u) ); | ||
| 159 | &shr( $t, 16); | ||
| 160 | &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); | ||
| 161 | &xor( $L, $ks); | ||
| 162 | &mov( $ks, &wparam(1) ); | ||
| 163 | &movb( &LB($tmp2), &HB($t) ); | ||
| 164 | &and( $u, "0xff" ); | ||
| 165 | &and( $t, "0xff" ); | ||
| 166 | &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); | ||
| 167 | &xor( $L, $tmp1); | ||
| 168 | &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); | ||
| 169 | &xor( $L, $tmp1); | ||
| 170 | &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); | ||
| 171 | &xor( $L, $tmp1); | ||
| 172 | &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); | ||
| 173 | &xor( $L, $tmp1); | ||
| 174 | } | ||
| 175 | |||
| 176 | sub n2a | ||
| 177 | { | ||
| 178 | sprintf("%d",$_[0]); | ||
| 179 | } | ||
| 180 | |||
| 181 | # now has a side affect of rotating $a by $shift | ||
| 182 | sub R_PERM_OP | ||
| 183 | { | ||
| 184 | local($a,$b,$tt,$shift,$mask,$last)=@_; | ||
| 185 | |||
| 186 | &rotl( $a, $shift ) if ($shift != 0); | ||
| 187 | &mov( $tt, $a ); | ||
| 188 | &xor( $a, $b ); | ||
| 189 | &and( $a, $mask ); | ||
| 190 | # This can never succeed, and besides it is difficult to see what the | ||
| 191 | # idea was - Ben 13 Feb 99 | ||
| 192 | if (!$last eq $b) | ||
| 193 | { | ||
| 194 | &xor( $b, $a ); | ||
| 195 | &xor( $tt, $a ); | ||
| 196 | } | ||
| 197 | else | ||
| 198 | { | ||
| 199 | &xor( $tt, $a ); | ||
| 200 | &xor( $b, $a ); | ||
| 201 | } | ||
| 202 | &comment(""); | ||
| 203 | } | ||
| 204 | |||
| 205 | sub IP_new | ||
| 206 | { | ||
| 207 | local($l,$r,$tt,$lr)=@_; | ||
| 208 | |||
| 209 | &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l); | ||
| 210 | &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l); | ||
| 211 | &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r); | ||
| 212 | &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r); | ||
| 213 | &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r); | ||
| 214 | |||
| 215 | if ($lr != 3) | ||
| 216 | { | ||
| 217 | if (($lr-3) < 0) | ||
| 218 | { &rotr($tt, 3-$lr); } | ||
| 219 | else { &rotl($tt, $lr-3); } | ||
| 220 | } | ||
| 221 | if ($lr != 2) | ||
| 222 | { | ||
| 223 | if (($lr-2) < 0) | ||
| 224 | { &rotr($r, 2-$lr); } | ||
| 225 | else { &rotl($r, $lr-2); } | ||
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 229 | sub FP_new | ||
| 230 | { | ||
| 231 | local($l,$r,$tt,$lr)=@_; | ||
| 232 | |||
| 233 | if ($lr != 2) | ||
| 234 | { | ||
| 235 | if (($lr-2) < 0) | ||
| 236 | { &rotl($r, 2-$lr); } | ||
| 237 | else { &rotr($r, $lr-2); } | ||
| 238 | } | ||
| 239 | if ($lr != 3) | ||
| 240 | { | ||
| 241 | if (($lr-3) < 0) | ||
| 242 | { &rotl($l, 3-$lr); } | ||
| 243 | else { &rotr($l, $lr-3); } | ||
| 244 | } | ||
| 245 | |||
| 246 | &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r); | ||
| 247 | &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r); | ||
| 248 | &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l); | ||
| 249 | &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l); | ||
| 250 | &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r); | ||
| 251 | &rotr($tt , 4); | ||
| 252 | } | ||
| 253 | |||
diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl deleted file mode 100644 index eec00886e4..0000000000 --- a/src/lib/libcrypto/des/asm/desboth.pl +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | $L="edi"; | ||
| 4 | $R="esi"; | ||
| 5 | |||
| 6 | sub DES_encrypt3 | ||
| 7 | { | ||
| 8 | local($name,$enc)=@_; | ||
| 9 | |||
| 10 | &function_begin_B($name,""); | ||
| 11 | &push("ebx"); | ||
| 12 | &mov("ebx",&wparam(0)); | ||
| 13 | |||
| 14 | &push("ebp"); | ||
| 15 | &push("esi"); | ||
| 16 | |||
| 17 | &push("edi"); | ||
| 18 | |||
| 19 | &comment(""); | ||
| 20 | &comment("Load the data words"); | ||
| 21 | &mov($L,&DWP(0,"ebx","",0)); | ||
| 22 | &mov($R,&DWP(4,"ebx","",0)); | ||
| 23 | &stack_push(3); | ||
| 24 | |||
| 25 | &comment(""); | ||
| 26 | &comment("IP"); | ||
| 27 | &IP_new($L,$R,"edx",0); | ||
| 28 | |||
| 29 | # put them back | ||
| 30 | |||
| 31 | if ($enc) | ||
| 32 | { | ||
| 33 | &mov(&DWP(4,"ebx","",0),$R); | ||
| 34 | &mov("eax",&wparam(1)); | ||
| 35 | &mov(&DWP(0,"ebx","",0),"edx"); | ||
| 36 | &mov("edi",&wparam(2)); | ||
| 37 | &mov("esi",&wparam(3)); | ||
| 38 | } | ||
| 39 | else | ||
| 40 | { | ||
| 41 | &mov(&DWP(4,"ebx","",0),$R); | ||
| 42 | &mov("esi",&wparam(1)); | ||
| 43 | &mov(&DWP(0,"ebx","",0),"edx"); | ||
| 44 | &mov("edi",&wparam(2)); | ||
| 45 | &mov("eax",&wparam(3)); | ||
| 46 | } | ||
| 47 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); | ||
| 48 | &mov(&swtmp(1), "eax"); | ||
| 49 | &mov(&swtmp(0), "ebx"); | ||
| 50 | &call("DES_encrypt2"); | ||
| 51 | &mov(&swtmp(2), (DWC(($enc)?"0":"1"))); | ||
| 52 | &mov(&swtmp(1), "edi"); | ||
| 53 | &mov(&swtmp(0), "ebx"); | ||
| 54 | &call("DES_encrypt2"); | ||
| 55 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); | ||
| 56 | &mov(&swtmp(1), "esi"); | ||
| 57 | &mov(&swtmp(0), "ebx"); | ||
| 58 | &call("DES_encrypt2"); | ||
| 59 | |||
| 60 | &stack_pop(3); | ||
| 61 | &mov($L,&DWP(0,"ebx","",0)); | ||
| 62 | &mov($R,&DWP(4,"ebx","",0)); | ||
| 63 | |||
| 64 | &comment(""); | ||
| 65 | &comment("FP"); | ||
| 66 | &FP_new($L,$R,"eax",0); | ||
| 67 | |||
| 68 | &mov(&DWP(0,"ebx","",0),"eax"); | ||
| 69 | &mov(&DWP(4,"ebx","",0),$R); | ||
| 70 | |||
| 71 | &pop("edi"); | ||
| 72 | &pop("esi"); | ||
| 73 | &pop("ebp"); | ||
| 74 | &pop("ebx"); | ||
| 75 | &ret(); | ||
| 76 | &function_end_B($name); | ||
| 77 | } | ||
| 78 | |||
| 79 | |||
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c deleted file mode 100644 index 6c5305b99d..0000000000 --- a/src/lib/libcrypto/des/cbc_cksm.c +++ /dev/null | |||
| @@ -1,97 +0,0 @@ | |||
| 1 | /* crypto/des/cbc_cksm.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output, | ||
| 62 | long length, DES_key_schedule *schedule, | ||
| 63 | const_DES_cblock *ivec) | ||
| 64 | { | ||
| 65 | register DES_LONG tout0,tout1,tin0,tin1; | ||
| 66 | register long l=length; | ||
| 67 | DES_LONG tin[2]; | ||
| 68 | unsigned char *out = &(*output)[0]; | ||
| 69 | const unsigned char *iv = &(*ivec)[0]; | ||
| 70 | |||
| 71 | c2l(iv,tout0); | ||
| 72 | c2l(iv,tout1); | ||
| 73 | for (; l>0; l-=8) | ||
| 74 | { | ||
| 75 | if (l >= 8) | ||
| 76 | { | ||
| 77 | c2l(in,tin0); | ||
| 78 | c2l(in,tin1); | ||
| 79 | } | ||
| 80 | else | ||
| 81 | c2ln(in,tin0,tin1,l); | ||
| 82 | |||
| 83 | tin0^=tout0; tin[0]=tin0; | ||
| 84 | tin1^=tout1; tin[1]=tin1; | ||
| 85 | DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
| 86 | /* fix 15/10/91 eay - thanks to keithr@sco.COM */ | ||
| 87 | tout0=tin[0]; | ||
| 88 | tout1=tin[1]; | ||
| 89 | } | ||
| 90 | if (out != NULL) | ||
| 91 | { | ||
| 92 | l2c(tout0,out); | ||
| 93 | l2c(tout1,out); | ||
| 94 | } | ||
| 95 | tout0=tin0=tin1=tin[0]=tin[1]=0; | ||
| 96 | return(tout1); | ||
| 97 | } | ||
diff --git a/src/lib/libcrypto/des/cbc_enc.c b/src/lib/libcrypto/des/cbc_enc.c deleted file mode 100644 index 677903ae4e..0000000000 --- a/src/lib/libcrypto/des/cbc_enc.c +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 1 | /* crypto/des/cbc_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #define CBC_ENC_C__DONT_UPDATE_IV | ||
| 60 | |||
| 61 | #include "ncbc_enc.c" /* des_cbc_encrypt */ | ||
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c deleted file mode 100644 index 60c1aa08db..0000000000 --- a/src/lib/libcrypto/des/cfb64ede.c +++ /dev/null | |||
| @@ -1,142 +0,0 @@ | |||
| 1 | /* crypto/des/cfb64ede.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output encrypted as though 64bit cfb mode is being | ||
| 62 | * used. The extra state information to record how much of the | ||
| 63 | * 64bit block we have used is contained in *num; | ||
| 64 | */ | ||
| 65 | |||
| 66 | void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 67 | long length, DES_key_schedule *ks1, | ||
| 68 | DES_key_schedule *ks2, DES_key_schedule *ks3, | ||
| 69 | DES_cblock *ivec, int *num, int enc) | ||
| 70 | { | ||
| 71 | register DES_LONG v0,v1; | ||
| 72 | register long l=length; | ||
| 73 | register int n= *num; | ||
| 74 | DES_LONG ti[2]; | ||
| 75 | unsigned char *iv,c,cc; | ||
| 76 | |||
| 77 | iv=&(*ivec)[0]; | ||
| 78 | if (enc) | ||
| 79 | { | ||
| 80 | while (l--) | ||
| 81 | { | ||
| 82 | if (n == 0) | ||
| 83 | { | ||
| 84 | c2l(iv,v0); | ||
| 85 | c2l(iv,v1); | ||
| 86 | |||
| 87 | ti[0]=v0; | ||
| 88 | ti[1]=v1; | ||
| 89 | DES_encrypt3(ti,ks1,ks2,ks3); | ||
| 90 | v0=ti[0]; | ||
| 91 | v1=ti[1]; | ||
| 92 | |||
| 93 | iv = &(*ivec)[0]; | ||
| 94 | l2c(v0,iv); | ||
| 95 | l2c(v1,iv); | ||
| 96 | iv = &(*ivec)[0]; | ||
| 97 | } | ||
| 98 | c= *(in++)^iv[n]; | ||
| 99 | *(out++)=c; | ||
| 100 | iv[n]=c; | ||
| 101 | n=(n+1)&0x07; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | else | ||
| 105 | { | ||
| 106 | while (l--) | ||
| 107 | { | ||
| 108 | if (n == 0) | ||
| 109 | { | ||
| 110 | c2l(iv,v0); | ||
| 111 | c2l(iv,v1); | ||
| 112 | |||
| 113 | ti[0]=v0; | ||
| 114 | ti[1]=v1; | ||
| 115 | DES_encrypt3(ti,ks1,ks2,ks3); | ||
| 116 | v0=ti[0]; | ||
| 117 | v1=ti[1]; | ||
| 118 | |||
| 119 | iv = &(*ivec)[0]; | ||
| 120 | l2c(v0,iv); | ||
| 121 | l2c(v1,iv); | ||
| 122 | iv = &(*ivec)[0]; | ||
| 123 | } | ||
| 124 | cc= *(in++); | ||
| 125 | c=iv[n]; | ||
| 126 | iv[n]=cc; | ||
| 127 | *(out++)=c^cc; | ||
| 128 | n=(n+1)&0x07; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | v0=v1=ti[0]=ti[1]=c=cc=0; | ||
| 132 | *num=n; | ||
| 133 | } | ||
| 134 | |||
| 135 | #ifdef undef /* MACRO */ | ||
| 136 | void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, | ||
| 137 | DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock (*ivec), | ||
| 138 | int *num, int enc) | ||
| 139 | { | ||
| 140 | DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); | ||
| 141 | } | ||
| 142 | #endif | ||
diff --git a/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c deleted file mode 100644 index 5ec8683e40..0000000000 --- a/src/lib/libcrypto/des/cfb64enc.c +++ /dev/null | |||
| @@ -1,121 +0,0 @@ | |||
| 1 | /* crypto/des/cfb64enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output encrypted as though 64bit cfb mode is being | ||
| 62 | * used. The extra state information to record how much of the | ||
| 63 | * 64bit block we have used is contained in *num; | ||
| 64 | */ | ||
| 65 | |||
| 66 | void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 67 | long length, DES_key_schedule *schedule, | ||
| 68 | DES_cblock *ivec, int *num, int enc) | ||
| 69 | { | ||
| 70 | register DES_LONG v0,v1; | ||
| 71 | register long l=length; | ||
| 72 | register int n= *num; | ||
| 73 | DES_LONG ti[2]; | ||
| 74 | unsigned char *iv,c,cc; | ||
| 75 | |||
| 76 | iv = &(*ivec)[0]; | ||
| 77 | if (enc) | ||
| 78 | { | ||
| 79 | while (l--) | ||
| 80 | { | ||
| 81 | if (n == 0) | ||
| 82 | { | ||
| 83 | c2l(iv,v0); ti[0]=v0; | ||
| 84 | c2l(iv,v1); ti[1]=v1; | ||
| 85 | DES_encrypt1(ti,schedule,DES_ENCRYPT); | ||
| 86 | iv = &(*ivec)[0]; | ||
| 87 | v0=ti[0]; l2c(v0,iv); | ||
| 88 | v0=ti[1]; l2c(v0,iv); | ||
| 89 | iv = &(*ivec)[0]; | ||
| 90 | } | ||
| 91 | c= *(in++)^iv[n]; | ||
| 92 | *(out++)=c; | ||
| 93 | iv[n]=c; | ||
| 94 | n=(n+1)&0x07; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | else | ||
| 98 | { | ||
| 99 | while (l--) | ||
| 100 | { | ||
| 101 | if (n == 0) | ||
| 102 | { | ||
| 103 | c2l(iv,v0); ti[0]=v0; | ||
| 104 | c2l(iv,v1); ti[1]=v1; | ||
| 105 | DES_encrypt1(ti,schedule,DES_ENCRYPT); | ||
| 106 | iv = &(*ivec)[0]; | ||
| 107 | v0=ti[0]; l2c(v0,iv); | ||
| 108 | v0=ti[1]; l2c(v0,iv); | ||
| 109 | iv = &(*ivec)[0]; | ||
| 110 | } | ||
| 111 | cc= *(in++); | ||
| 112 | c=iv[n]; | ||
| 113 | iv[n]=cc; | ||
| 114 | *(out++)=c^cc; | ||
| 115 | n=(n+1)&0x07; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | v0=v1=ti[0]=ti[1]=c=cc=0; | ||
| 119 | *num=n; | ||
| 120 | } | ||
| 121 | |||
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c deleted file mode 100644 index 17bf77ca9e..0000000000 --- a/src/lib/libcrypto/des/cfb_enc.c +++ /dev/null | |||
| @@ -1,165 +0,0 @@ | |||
| 1 | /* crypto/des/cfb_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output are loaded in multiples of 8 bits. | ||
| 62 | * What this means is that if you hame numbits=12 and length=2 | ||
| 63 | * the first 12 bits will be retrieved from the first byte and half | ||
| 64 | * the second. The second 12 bits will come from the 3rd and half the 4th | ||
| 65 | * byte. | ||
| 66 | */ | ||
| 67 | void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | ||
| 68 | long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc) | ||
| 69 | { | ||
| 70 | register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; | ||
| 71 | register DES_LONG mask0,mask1; | ||
| 72 | register unsigned long l=length; | ||
| 73 | register int num=numbits; | ||
| 74 | DES_LONG ti[2]; | ||
| 75 | unsigned char *iv; | ||
| 76 | |||
| 77 | if (num > 64) return; | ||
| 78 | if (num > 32) | ||
| 79 | { | ||
| 80 | mask0=0xffffffffL; | ||
| 81 | if (num == 64) | ||
| 82 | mask1=mask0; | ||
| 83 | else mask1=(1L<<(num-32))-1; | ||
| 84 | } | ||
| 85 | else | ||
| 86 | { | ||
| 87 | if (num == 32) | ||
| 88 | mask0=0xffffffffL; | ||
| 89 | else mask0=(1L<<num)-1; | ||
| 90 | mask1=0x00000000L; | ||
| 91 | } | ||
| 92 | |||
| 93 | iv = &(*ivec)[0]; | ||
| 94 | c2l(iv,v0); | ||
| 95 | c2l(iv,v1); | ||
| 96 | if (enc) | ||
| 97 | { | ||
| 98 | while (l >= n) | ||
| 99 | { | ||
| 100 | l-=n; | ||
| 101 | ti[0]=v0; | ||
| 102 | ti[1]=v1; | ||
| 103 | DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
| 104 | c2ln(in,d0,d1,n); | ||
| 105 | in+=n; | ||
| 106 | d0=(d0^ti[0])&mask0; | ||
| 107 | d1=(d1^ti[1])&mask1; | ||
| 108 | l2cn(d0,d1,out,n); | ||
| 109 | out+=n; | ||
| 110 | /* 30-08-94 - eay - changed because l>>32 and | ||
| 111 | * l<<32 are bad under gcc :-( */ | ||
| 112 | if (num == 32) | ||
| 113 | { v0=v1; v1=d0; } | ||
| 114 | else if (num == 64) | ||
| 115 | { v0=d0; v1=d1; } | ||
| 116 | else if (num > 32) /* && num != 64 */ | ||
| 117 | { | ||
| 118 | v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL; | ||
| 119 | v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL; | ||
| 120 | } | ||
| 121 | else /* num < 32 */ | ||
| 122 | { | ||
| 123 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
| 124 | v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 128 | else | ||
| 129 | { | ||
| 130 | while (l >= n) | ||
| 131 | { | ||
| 132 | l-=n; | ||
| 133 | ti[0]=v0; | ||
| 134 | ti[1]=v1; | ||
| 135 | DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
| 136 | c2ln(in,d0,d1,n); | ||
| 137 | in+=n; | ||
| 138 | /* 30-08-94 - eay - changed because l>>32 and | ||
| 139 | * l<<32 are bad under gcc :-( */ | ||
| 140 | if (num == 32) | ||
| 141 | { v0=v1; v1=d0; } | ||
| 142 | else if (num == 64) | ||
| 143 | { v0=d0; v1=d1; } | ||
| 144 | else if (num > 32) /* && num != 64 */ | ||
| 145 | { | ||
| 146 | v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL; | ||
| 147 | v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL; | ||
| 148 | } | ||
| 149 | else /* num < 32 */ | ||
| 150 | { | ||
| 151 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
| 152 | v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; | ||
| 153 | } | ||
| 154 | d0=(d0^ti[0])&mask0; | ||
| 155 | d1=(d1^ti[1])&mask1; | ||
| 156 | l2cn(d0,d1,out,n); | ||
| 157 | out+=n; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | iv = &(*ivec)[0]; | ||
| 161 | l2c(v0,iv); | ||
| 162 | l2c(v1,iv); | ||
| 163 | v0=v1=d0=d1=ti[0]=ti[1]=0; | ||
| 164 | } | ||
| 165 | |||
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h deleted file mode 100644 index dfe5ff64e4..0000000000 --- a/src/lib/libcrypto/des/des.h +++ /dev/null | |||
| @@ -1,242 +0,0 @@ | |||
| 1 | /* crypto/des/des.h */ | ||
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_DES_H | ||
| 60 | #define HEADER_DES_H | ||
| 61 | |||
| 62 | #ifdef OPENSSL_NO_DES | ||
| 63 | #error DES is disabled. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #include <openssl/opensslconf.h> /* DES_LONG */ | ||
| 67 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN */ | ||
| 68 | |||
| 69 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO | ||
| 70 | # undef OPENSSL_EXTERN | ||
| 71 | # define OPENSSL_EXTERN OPENSSL_EXPORT | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #define des_SPtrans DES_SPtrans | ||
| 75 | |||
| 76 | #ifdef __cplusplus | ||
| 77 | extern "C" { | ||
| 78 | #endif | ||
| 79 | |||
| 80 | typedef unsigned char DES_cblock[8]; | ||
| 81 | typedef /* const */ unsigned char const_DES_cblock[8]; | ||
| 82 | /* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * | ||
| 83 | * and const_DES_cblock * are incompatible pointer types. */ | ||
| 84 | |||
| 85 | typedef struct DES_ks | ||
| 86 | { | ||
| 87 | union | ||
| 88 | { | ||
| 89 | DES_cblock cblock; | ||
| 90 | /* make sure things are correct size on machines with | ||
| 91 | * 8 byte longs */ | ||
| 92 | DES_LONG deslong[2]; | ||
| 93 | } ks[16]; | ||
| 94 | } DES_key_schedule; | ||
| 95 | |||
| 96 | #ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT | ||
| 97 | # ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT | ||
| 98 | # define OPENSSL_ENABLE_OLD_DES_SUPPORT | ||
| 99 | # endif | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT | ||
| 103 | # include <openssl/des_old.h> | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #define DES_KEY_SZ (sizeof(DES_cblock)) | ||
| 107 | #define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) | ||
| 108 | |||
| 109 | #define DES_ENCRYPT 1 | ||
| 110 | #define DES_DECRYPT 0 | ||
| 111 | |||
| 112 | #define DES_CBC_MODE 0 | ||
| 113 | #define DES_PCBC_MODE 1 | ||
| 114 | |||
| 115 | #define DES_ecb2_encrypt(i,o,k1,k2,e) \ | ||
| 116 | DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) | ||
| 117 | |||
| 118 | #define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ | ||
| 119 | DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) | ||
| 120 | |||
| 121 | #define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ | ||
| 122 | DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) | ||
| 123 | |||
| 124 | #define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ | ||
| 125 | DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) | ||
| 126 | |||
| 127 | OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ | ||
| 128 | #define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) | ||
| 129 | OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ | ||
| 130 | #define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) | ||
| 131 | |||
| 132 | const char *DES_options(void); | ||
| 133 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 134 | DES_key_schedule *ks1,DES_key_schedule *ks2, | ||
| 135 | DES_key_schedule *ks3, int enc); | ||
| 136 | DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, | ||
| 137 | long length,DES_key_schedule *schedule, | ||
| 138 | const_DES_cblock *ivec); | ||
| 139 | /* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ | ||
| 140 | void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, | ||
| 141 | long length,DES_key_schedule *schedule,DES_cblock *ivec, | ||
| 142 | int enc); | ||
| 143 | void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, | ||
| 144 | long length,DES_key_schedule *schedule,DES_cblock *ivec, | ||
| 145 | int enc); | ||
| 146 | void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, | ||
| 147 | long length,DES_key_schedule *schedule,DES_cblock *ivec, | ||
| 148 | const_DES_cblock *inw,const_DES_cblock *outw,int enc); | ||
| 149 | void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, | ||
| 150 | long length,DES_key_schedule *schedule,DES_cblock *ivec, | ||
| 151 | int enc); | ||
| 152 | void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, | ||
| 153 | DES_key_schedule *ks,int enc); | ||
| 154 | |||
| 155 | /* This is the DES encryption function that gets called by just about | ||
| 156 | every other DES routine in the library. You should not use this | ||
| 157 | function except to implement 'modes' of DES. I say this because the | ||
| 158 | functions that call this routine do the conversion from 'char *' to | ||
| 159 | long, and this needs to be done to make sure 'non-aligned' memory | ||
| 160 | access do not occur. The characters are loaded 'little endian'. | ||
| 161 | Data is a pointer to 2 unsigned long's and ks is the | ||
| 162 | DES_key_schedule to use. enc, is non zero specifies encryption, | ||
| 163 | zero if decryption. */ | ||
| 164 | void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); | ||
| 165 | |||
| 166 | /* This functions is the same as DES_encrypt1() except that the DES | ||
| 167 | initial permutation (IP) and final permutation (FP) have been left | ||
| 168 | out. As for DES_encrypt1(), you should not use this function. | ||
| 169 | It is used by the routines in the library that implement triple DES. | ||
| 170 | IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same | ||
| 171 | as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ | ||
| 172 | void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); | ||
| 173 | |||
| 174 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, | ||
| 175 | DES_key_schedule *ks2, DES_key_schedule *ks3); | ||
| 176 | void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, | ||
| 177 | DES_key_schedule *ks2, DES_key_schedule *ks3); | ||
| 178 | void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, | ||
| 179 | long length, | ||
| 180 | DES_key_schedule *ks1,DES_key_schedule *ks2, | ||
| 181 | DES_key_schedule *ks3,DES_cblock *ivec,int enc); | ||
| 182 | void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, | ||
| 183 | long length, | ||
| 184 | DES_key_schedule *ks1,DES_key_schedule *ks2, | ||
| 185 | DES_key_schedule *ks3, | ||
| 186 | DES_cblock *ivec1,DES_cblock *ivec2, | ||
| 187 | int enc); | ||
| 188 | void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, | ||
| 189 | long length,DES_key_schedule *ks1, | ||
| 190 | DES_key_schedule *ks2,DES_key_schedule *ks3, | ||
| 191 | DES_cblock *ivec,int *num,int enc); | ||
| 192 | void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, | ||
| 193 | long length,DES_key_schedule *ks1, | ||
| 194 | DES_key_schedule *ks2,DES_key_schedule *ks3, | ||
| 195 | DES_cblock *ivec,int *num); | ||
| 196 | |||
| 197 | void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, | ||
| 198 | DES_cblock *out_white); | ||
| 199 | |||
| 200 | int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, | ||
| 201 | DES_cblock *iv); | ||
| 202 | int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, | ||
| 203 | DES_cblock *iv); | ||
| 204 | char *DES_fcrypt(const char *buf,const char *salt, char *ret); | ||
| 205 | char *DES_crypt(const char *buf,const char *salt); | ||
| 206 | void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, | ||
| 207 | long length,DES_key_schedule *schedule,DES_cblock *ivec); | ||
| 208 | void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, | ||
| 209 | long length,DES_key_schedule *schedule,DES_cblock *ivec, | ||
| 210 | int enc); | ||
| 211 | DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], | ||
| 212 | long length,int out_count,DES_cblock *seed); | ||
| 213 | int DES_random_key(DES_cblock *ret); | ||
| 214 | void DES_set_odd_parity(DES_cblock *key); | ||
| 215 | int DES_check_key_parity(const_DES_cblock *key); | ||
| 216 | int DES_is_weak_key(const_DES_cblock *key); | ||
| 217 | /* DES_set_key (= set_key = DES_key_sched = key_sched) calls | ||
| 218 | * DES_set_key_checked if global variable DES_check_key is set, | ||
| 219 | * DES_set_key_unchecked otherwise. */ | ||
| 220 | int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); | ||
| 221 | int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); | ||
| 222 | int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); | ||
| 223 | void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); | ||
| 224 | void DES_string_to_key(const char *str,DES_cblock *key); | ||
| 225 | void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); | ||
| 226 | void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, | ||
| 227 | DES_key_schedule *schedule,DES_cblock *ivec,int *num, | ||
| 228 | int enc); | ||
| 229 | void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, | ||
| 230 | DES_key_schedule *schedule,DES_cblock *ivec,int *num); | ||
| 231 | |||
| 232 | int DES_read_password(DES_cblock *key, const char *prompt, int verify); | ||
| 233 | int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, | ||
| 234 | int verify); | ||
| 235 | |||
| 236 | #define DES_fixup_key_parity DES_set_odd_parity | ||
| 237 | |||
| 238 | #ifdef __cplusplus | ||
| 239 | } | ||
| 240 | #endif | ||
| 241 | |||
| 242 | #endif | ||
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c deleted file mode 100644 index 1c37ab96d3..0000000000 --- a/src/lib/libcrypto/des/des_enc.c +++ /dev/null | |||
| @@ -1,407 +0,0 @@ | |||
| 1 | /* crypto/des/des_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | ||
| 62 | { | ||
| 63 | register DES_LONG l,r,t,u; | ||
| 64 | #ifdef DES_PTR | ||
| 65 | register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; | ||
| 66 | #endif | ||
| 67 | #ifndef DES_UNROLL | ||
| 68 | register int i; | ||
| 69 | #endif | ||
| 70 | register DES_LONG *s; | ||
| 71 | |||
| 72 | r=data[0]; | ||
| 73 | l=data[1]; | ||
| 74 | |||
| 75 | IP(r,l); | ||
| 76 | /* Things have been modified so that the initial rotate is | ||
| 77 | * done outside the loop. This required the | ||
| 78 | * DES_SPtrans values in sp.h to be rotated 1 bit to the right. | ||
| 79 | * One perl script later and things have a 5% speed up on a sparc2. | ||
| 80 | * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> | ||
| 81 | * for pointing this out. */ | ||
| 82 | /* clear the top bits on machines with 8byte longs */ | ||
| 83 | /* shift left by 2 */ | ||
| 84 | r=ROTATE(r,29)&0xffffffffL; | ||
| 85 | l=ROTATE(l,29)&0xffffffffL; | ||
| 86 | |||
| 87 | s=ks->ks->deslong; | ||
| 88 | /* I don't know if it is worth the effort of loop unrolling the | ||
| 89 | * inner loop */ | ||
| 90 | if (enc) | ||
| 91 | { | ||
| 92 | #ifdef DES_UNROLL | ||
| 93 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
| 94 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
| 95 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
| 96 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
| 97 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
| 98 | D_ENCRYPT(r,l,10); /* 6 */ | ||
| 99 | D_ENCRYPT(l,r,12); /* 7 */ | ||
| 100 | D_ENCRYPT(r,l,14); /* 8 */ | ||
| 101 | D_ENCRYPT(l,r,16); /* 9 */ | ||
| 102 | D_ENCRYPT(r,l,18); /* 10 */ | ||
| 103 | D_ENCRYPT(l,r,20); /* 11 */ | ||
| 104 | D_ENCRYPT(r,l,22); /* 12 */ | ||
| 105 | D_ENCRYPT(l,r,24); /* 13 */ | ||
| 106 | D_ENCRYPT(r,l,26); /* 14 */ | ||
| 107 | D_ENCRYPT(l,r,28); /* 15 */ | ||
| 108 | D_ENCRYPT(r,l,30); /* 16 */ | ||
| 109 | #else | ||
| 110 | for (i=0; i<32; i+=8) | ||
| 111 | { | ||
| 112 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
| 113 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
| 114 | D_ENCRYPT(l,r,i+4); /* 3 */ | ||
| 115 | D_ENCRYPT(r,l,i+6); /* 4 */ | ||
| 116 | } | ||
| 117 | #endif | ||
| 118 | } | ||
| 119 | else | ||
| 120 | { | ||
| 121 | #ifdef DES_UNROLL | ||
| 122 | D_ENCRYPT(l,r,30); /* 16 */ | ||
| 123 | D_ENCRYPT(r,l,28); /* 15 */ | ||
| 124 | D_ENCRYPT(l,r,26); /* 14 */ | ||
| 125 | D_ENCRYPT(r,l,24); /* 13 */ | ||
| 126 | D_ENCRYPT(l,r,22); /* 12 */ | ||
| 127 | D_ENCRYPT(r,l,20); /* 11 */ | ||
| 128 | D_ENCRYPT(l,r,18); /* 10 */ | ||
| 129 | D_ENCRYPT(r,l,16); /* 9 */ | ||
| 130 | D_ENCRYPT(l,r,14); /* 8 */ | ||
| 131 | D_ENCRYPT(r,l,12); /* 7 */ | ||
| 132 | D_ENCRYPT(l,r,10); /* 6 */ | ||
| 133 | D_ENCRYPT(r,l, 8); /* 5 */ | ||
| 134 | D_ENCRYPT(l,r, 6); /* 4 */ | ||
| 135 | D_ENCRYPT(r,l, 4); /* 3 */ | ||
| 136 | D_ENCRYPT(l,r, 2); /* 2 */ | ||
| 137 | D_ENCRYPT(r,l, 0); /* 1 */ | ||
| 138 | #else | ||
| 139 | for (i=30; i>0; i-=8) | ||
| 140 | { | ||
| 141 | D_ENCRYPT(l,r,i-0); /* 16 */ | ||
| 142 | D_ENCRYPT(r,l,i-2); /* 15 */ | ||
| 143 | D_ENCRYPT(l,r,i-4); /* 14 */ | ||
| 144 | D_ENCRYPT(r,l,i-6); /* 13 */ | ||
| 145 | } | ||
| 146 | #endif | ||
| 147 | } | ||
| 148 | |||
| 149 | /* rotate and clear the top bits on machines with 8byte longs */ | ||
| 150 | l=ROTATE(l,3)&0xffffffffL; | ||
| 151 | r=ROTATE(r,3)&0xffffffffL; | ||
| 152 | |||
| 153 | FP(r,l); | ||
| 154 | data[0]=l; | ||
| 155 | data[1]=r; | ||
| 156 | l=r=t=u=0; | ||
| 157 | } | ||
| 158 | |||
| 159 | void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) | ||
| 160 | { | ||
| 161 | register DES_LONG l,r,t,u; | ||
| 162 | #ifdef DES_PTR | ||
| 163 | register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; | ||
| 164 | #endif | ||
| 165 | #ifndef DES_UNROLL | ||
| 166 | register int i; | ||
| 167 | #endif | ||
| 168 | register DES_LONG *s; | ||
| 169 | |||
| 170 | r=data[0]; | ||
| 171 | l=data[1]; | ||
| 172 | |||
| 173 | /* Things have been modified so that the initial rotate is | ||
| 174 | * done outside the loop. This required the | ||
| 175 | * DES_SPtrans values in sp.h to be rotated 1 bit to the right. | ||
| 176 | * One perl script later and things have a 5% speed up on a sparc2. | ||
| 177 | * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> | ||
| 178 | * for pointing this out. */ | ||
| 179 | /* clear the top bits on machines with 8byte longs */ | ||
| 180 | r=ROTATE(r,29)&0xffffffffL; | ||
| 181 | l=ROTATE(l,29)&0xffffffffL; | ||
| 182 | |||
| 183 | s=ks->ks->deslong; | ||
| 184 | /* I don't know if it is worth the effort of loop unrolling the | ||
| 185 | * inner loop */ | ||
| 186 | if (enc) | ||
| 187 | { | ||
| 188 | #ifdef DES_UNROLL | ||
| 189 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
| 190 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
| 191 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
| 192 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
| 193 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
| 194 | D_ENCRYPT(r,l,10); /* 6 */ | ||
| 195 | D_ENCRYPT(l,r,12); /* 7 */ | ||
| 196 | D_ENCRYPT(r,l,14); /* 8 */ | ||
| 197 | D_ENCRYPT(l,r,16); /* 9 */ | ||
| 198 | D_ENCRYPT(r,l,18); /* 10 */ | ||
| 199 | D_ENCRYPT(l,r,20); /* 11 */ | ||
| 200 | D_ENCRYPT(r,l,22); /* 12 */ | ||
| 201 | D_ENCRYPT(l,r,24); /* 13 */ | ||
| 202 | D_ENCRYPT(r,l,26); /* 14 */ | ||
| 203 | D_ENCRYPT(l,r,28); /* 15 */ | ||
| 204 | D_ENCRYPT(r,l,30); /* 16 */ | ||
| 205 | #else | ||
| 206 | for (i=0; i<32; i+=8) | ||
| 207 | { | ||
| 208 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
| 209 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
| 210 | D_ENCRYPT(l,r,i+4); /* 3 */ | ||
| 211 | D_ENCRYPT(r,l,i+6); /* 4 */ | ||
| 212 | } | ||
| 213 | #endif | ||
| 214 | } | ||
| 215 | else | ||
| 216 | { | ||
| 217 | #ifdef DES_UNROLL | ||
| 218 | D_ENCRYPT(l,r,30); /* 16 */ | ||
| 219 | D_ENCRYPT(r,l,28); /* 15 */ | ||
| 220 | D_ENCRYPT(l,r,26); /* 14 */ | ||
| 221 | D_ENCRYPT(r,l,24); /* 13 */ | ||
| 222 | D_ENCRYPT(l,r,22); /* 12 */ | ||
| 223 | D_ENCRYPT(r,l,20); /* 11 */ | ||
| 224 | D_ENCRYPT(l,r,18); /* 10 */ | ||
| 225 | D_ENCRYPT(r,l,16); /* 9 */ | ||
| 226 | D_ENCRYPT(l,r,14); /* 8 */ | ||
| 227 | D_ENCRYPT(r,l,12); /* 7 */ | ||
| 228 | D_ENCRYPT(l,r,10); /* 6 */ | ||
| 229 | D_ENCRYPT(r,l, 8); /* 5 */ | ||
| 230 | D_ENCRYPT(l,r, 6); /* 4 */ | ||
| 231 | D_ENCRYPT(r,l, 4); /* 3 */ | ||
| 232 | D_ENCRYPT(l,r, 2); /* 2 */ | ||
| 233 | D_ENCRYPT(r,l, 0); /* 1 */ | ||
| 234 | #else | ||
| 235 | for (i=30; i>0; i-=8) | ||
| 236 | { | ||
| 237 | D_ENCRYPT(l,r,i-0); /* 16 */ | ||
| 238 | D_ENCRYPT(r,l,i-2); /* 15 */ | ||
| 239 | D_ENCRYPT(l,r,i-4); /* 14 */ | ||
| 240 | D_ENCRYPT(r,l,i-6); /* 13 */ | ||
| 241 | } | ||
| 242 | #endif | ||
| 243 | } | ||
| 244 | /* rotate and clear the top bits on machines with 8byte longs */ | ||
| 245 | data[0]=ROTATE(l,3)&0xffffffffL; | ||
| 246 | data[1]=ROTATE(r,3)&0xffffffffL; | ||
| 247 | l=r=t=u=0; | ||
| 248 | } | ||
| 249 | |||
| 250 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, | ||
| 251 | DES_key_schedule *ks2, DES_key_schedule *ks3) | ||
| 252 | { | ||
| 253 | register DES_LONG l,r; | ||
| 254 | |||
| 255 | l=data[0]; | ||
| 256 | r=data[1]; | ||
| 257 | IP(l,r); | ||
| 258 | data[0]=l; | ||
| 259 | data[1]=r; | ||
| 260 | DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); | ||
| 261 | DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); | ||
| 262 | DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); | ||
| 263 | l=data[0]; | ||
| 264 | r=data[1]; | ||
| 265 | FP(r,l); | ||
| 266 | data[0]=l; | ||
| 267 | data[1]=r; | ||
| 268 | } | ||
| 269 | |||
| 270 | void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, | ||
| 271 | DES_key_schedule *ks2, DES_key_schedule *ks3) | ||
| 272 | { | ||
| 273 | register DES_LONG l,r; | ||
| 274 | |||
| 275 | l=data[0]; | ||
| 276 | r=data[1]; | ||
| 277 | IP(l,r); | ||
| 278 | data[0]=l; | ||
| 279 | data[1]=r; | ||
| 280 | DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); | ||
| 281 | DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); | ||
| 282 | DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); | ||
| 283 | l=data[0]; | ||
| 284 | r=data[1]; | ||
| 285 | FP(r,l); | ||
| 286 | data[0]=l; | ||
| 287 | data[1]=r; | ||
| 288 | } | ||
| 289 | |||
| 290 | #ifndef DES_DEFAULT_OPTIONS | ||
| 291 | |||
| 292 | #undef CBC_ENC_C__DONT_UPDATE_IV | ||
| 293 | #include "ncbc_enc.c" /* DES_ncbc_encrypt */ | ||
| 294 | |||
| 295 | void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, | ||
| 296 | long length, DES_key_schedule *ks1, | ||
| 297 | DES_key_schedule *ks2, DES_key_schedule *ks3, | ||
| 298 | DES_cblock *ivec, int enc) | ||
| 299 | { | ||
| 300 | register DES_LONG tin0,tin1; | ||
| 301 | register DES_LONG tout0,tout1,xor0,xor1; | ||
| 302 | register const unsigned char *in; | ||
| 303 | unsigned char *out; | ||
| 304 | register long l=length; | ||
| 305 | DES_LONG tin[2]; | ||
| 306 | unsigned char *iv; | ||
| 307 | |||
| 308 | in=input; | ||
| 309 | out=output; | ||
| 310 | iv = &(*ivec)[0]; | ||
| 311 | |||
| 312 | if (enc) | ||
| 313 | { | ||
| 314 | c2l(iv,tout0); | ||
| 315 | c2l(iv,tout1); | ||
| 316 | for (l-=8; l>=0; l-=8) | ||
| 317 | { | ||
| 318 | c2l(in,tin0); | ||
| 319 | c2l(in,tin1); | ||
| 320 | tin0^=tout0; | ||
| 321 | tin1^=tout1; | ||
| 322 | |||
| 323 | tin[0]=tin0; | ||
| 324 | tin[1]=tin1; | ||
| 325 | DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
| 326 | tout0=tin[0]; | ||
| 327 | tout1=tin[1]; | ||
| 328 | |||
| 329 | l2c(tout0,out); | ||
| 330 | l2c(tout1,out); | ||
| 331 | } | ||
| 332 | if (l != -8) | ||
| 333 | { | ||
| 334 | c2ln(in,tin0,tin1,l+8); | ||
| 335 | tin0^=tout0; | ||
| 336 | tin1^=tout1; | ||
| 337 | |||
| 338 | tin[0]=tin0; | ||
| 339 | tin[1]=tin1; | ||
| 340 | DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
| 341 | tout0=tin[0]; | ||
| 342 | tout1=tin[1]; | ||
| 343 | |||
| 344 | l2c(tout0,out); | ||
| 345 | l2c(tout1,out); | ||
| 346 | } | ||
| 347 | iv = &(*ivec)[0]; | ||
| 348 | l2c(tout0,iv); | ||
| 349 | l2c(tout1,iv); | ||
| 350 | } | ||
| 351 | else | ||
| 352 | { | ||
| 353 | register DES_LONG t0,t1; | ||
| 354 | |||
| 355 | c2l(iv,xor0); | ||
| 356 | c2l(iv,xor1); | ||
| 357 | for (l-=8; l>=0; l-=8) | ||
| 358 | { | ||
| 359 | c2l(in,tin0); | ||
| 360 | c2l(in,tin1); | ||
| 361 | |||
| 362 | t0=tin0; | ||
| 363 | t1=tin1; | ||
| 364 | |||
| 365 | tin[0]=tin0; | ||
| 366 | tin[1]=tin1; | ||
| 367 | DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
| 368 | tout0=tin[0]; | ||
| 369 | tout1=tin[1]; | ||
| 370 | |||
| 371 | tout0^=xor0; | ||
| 372 | tout1^=xor1; | ||
| 373 | l2c(tout0,out); | ||
| 374 | l2c(tout1,out); | ||
| 375 | xor0=t0; | ||
| 376 | xor1=t1; | ||
| 377 | } | ||
| 378 | if (l != -8) | ||
| 379 | { | ||
| 380 | c2l(in,tin0); | ||
| 381 | c2l(in,tin1); | ||
| 382 | |||
| 383 | t0=tin0; | ||
| 384 | t1=tin1; | ||
| 385 | |||
| 386 | tin[0]=tin0; | ||
| 387 | tin[1]=tin1; | ||
| 388 | DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
| 389 | tout0=tin[0]; | ||
| 390 | tout1=tin[1]; | ||
| 391 | |||
| 392 | tout0^=xor0; | ||
| 393 | tout1^=xor1; | ||
| 394 | l2cn(tout0,tout1,out,l+8); | ||
| 395 | xor0=t0; | ||
| 396 | xor1=t1; | ||
| 397 | } | ||
| 398 | |||
| 399 | iv = &(*ivec)[0]; | ||
| 400 | l2c(xor0,iv); | ||
| 401 | l2c(xor1,iv); | ||
| 402 | } | ||
| 403 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
| 404 | tin[0]=tin[1]=0; | ||
| 405 | } | ||
| 406 | |||
| 407 | #endif /* DES_DEFAULT_OPTIONS */ | ||
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h deleted file mode 100644 index 70e833be3f..0000000000 --- a/src/lib/libcrypto/des/des_locl.h +++ /dev/null | |||
| @@ -1,417 +0,0 @@ | |||
| 1 | /* crypto/des/des_locl.h */ | ||
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_DES_LOCL_H | ||
| 60 | #define HEADER_DES_LOCL_H | ||
| 61 | |||
| 62 | #include <openssl/e_os2.h> | ||
| 63 | |||
| 64 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) | ||
| 65 | #ifndef OPENSSL_SYS_MSDOS | ||
| 66 | #define OPENSSL_SYS_MSDOS | ||
| 67 | #endif | ||
| 68 | #endif | ||
| 69 | |||
| 70 | #include <stdio.h> | ||
| 71 | #include <stdlib.h> | ||
| 72 | |||
| 73 | #ifndef OPENSSL_SYS_MSDOS | ||
| 74 | #if !defined(OPENSSL_SYS_VMS) || defined(__DECC) | ||
| 75 | #ifdef OPENSSL_UNISTD | ||
| 76 | # include OPENSSL_UNISTD | ||
| 77 | #else | ||
| 78 | # include <unistd.h> | ||
| 79 | #endif | ||
| 80 | #include <math.h> | ||
| 81 | #endif | ||
| 82 | #endif | ||
| 83 | #include <openssl/des.h> | ||
| 84 | |||
| 85 | #ifdef OPENSSL_SYS_MSDOS /* Visual C++ 2.1 (Windows NT/95) */ | ||
| 86 | #include <stdlib.h> | ||
| 87 | #include <errno.h> | ||
| 88 | #include <time.h> | ||
| 89 | #include <io.h> | ||
| 90 | #endif | ||
| 91 | |||
| 92 | #if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS) | ||
| 93 | #include <string.h> | ||
| 94 | #endif | ||
| 95 | |||
| 96 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO | ||
| 97 | # undef OPENSSL_EXTERN | ||
| 98 | # define OPENSSL_EXTERN OPENSSL_EXPORT | ||
| 99 | #endif | ||
| 100 | |||
| 101 | #define ITERATIONS 16 | ||
| 102 | #define HALF_ITERATIONS 8 | ||
| 103 | |||
| 104 | /* used in des_read and des_write */ | ||
| 105 | #define MAXWRITE (1024*16) | ||
| 106 | #define BSIZE (MAXWRITE+4) | ||
| 107 | |||
| 108 | #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ | ||
| 109 | l|=((DES_LONG)(*((c)++)))<< 8L, \ | ||
| 110 | l|=((DES_LONG)(*((c)++)))<<16L, \ | ||
| 111 | l|=((DES_LONG)(*((c)++)))<<24L) | ||
| 112 | |||
| 113 | /* NOTE - c is not incremented as per c2l */ | ||
| 114 | #define c2ln(c,l1,l2,n) { \ | ||
| 115 | c+=n; \ | ||
| 116 | l1=l2=0; \ | ||
| 117 | switch (n) { \ | ||
| 118 | case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ | ||
| 119 | case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ | ||
| 120 | case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ | ||
| 121 | case 5: l2|=((DES_LONG)(*(--(c)))); \ | ||
| 122 | case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ | ||
| 123 | case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ | ||
| 124 | case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ | ||
| 125 | case 1: l1|=((DES_LONG)(*(--(c)))); \ | ||
| 126 | } \ | ||
| 127 | } | ||
| 128 | |||
| 129 | #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ | ||
| 130 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | ||
| 131 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | ||
| 132 | *((c)++)=(unsigned char)(((l)>>24L)&0xff)) | ||
| 133 | |||
| 134 | /* replacements for htonl and ntohl since I have no idea what to do | ||
| 135 | * when faced with machines with 8 byte longs. */ | ||
| 136 | #define HDRSIZE 4 | ||
| 137 | |||
| 138 | #define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ | ||
| 139 | l|=((DES_LONG)(*((c)++)))<<16L, \ | ||
| 140 | l|=((DES_LONG)(*((c)++)))<< 8L, \ | ||
| 141 | l|=((DES_LONG)(*((c)++)))) | ||
| 142 | |||
| 143 | #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ | ||
| 144 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | ||
| 145 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | ||
| 146 | *((c)++)=(unsigned char)(((l) )&0xff)) | ||
| 147 | |||
| 148 | /* NOTE - c is not incremented as per l2c */ | ||
| 149 | #define l2cn(l1,l2,c,n) { \ | ||
| 150 | c+=n; \ | ||
| 151 | switch (n) { \ | ||
| 152 | case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ | ||
| 153 | case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ | ||
| 154 | case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ | ||
| 155 | case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ | ||
| 156 | case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ | ||
| 157 | case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ | ||
| 158 | case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ | ||
| 159 | case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ | ||
| 160 | } \ | ||
| 161 | } | ||
| 162 | |||
| 163 | #if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) | ||
| 164 | #define ROTATE(a,n) (_lrotr(a,n)) | ||
| 165 | #else | ||
| 166 | #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) | ||
| 167 | #endif | ||
| 168 | |||
| 169 | /* Don't worry about the LOAD_DATA() stuff, that is used by | ||
| 170 | * fcrypt() to add it's little bit to the front */ | ||
| 171 | |||
| 172 | #ifdef DES_FCRYPT | ||
| 173 | |||
| 174 | #define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ | ||
| 175 | { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } | ||
| 176 | |||
| 177 | #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ | ||
| 178 | t=R^(R>>16L); \ | ||
| 179 | u=t&E0; t&=E1; \ | ||
| 180 | tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ | ||
| 181 | tmp=(t<<16); t^=R^s[S+1]; t^=tmp | ||
| 182 | #else | ||
| 183 | #define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) | ||
| 184 | #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ | ||
| 185 | u=R^s[S ]; \ | ||
| 186 | t=R^s[S+1] | ||
| 187 | #endif | ||
| 188 | |||
| 189 | /* The changes to this macro may help or hinder, depending on the | ||
| 190 | * compiler and the architecture. gcc2 always seems to do well :-). | ||
| 191 | * Inspired by Dana How <how@isl.stanford.edu> | ||
| 192 | * DO NOT use the alternative version on machines with 8 byte longs. | ||
| 193 | * It does not seem to work on the Alpha, even when DES_LONG is 4 | ||
| 194 | * bytes, probably an issue of accessing non-word aligned objects :-( */ | ||
| 195 | #ifdef DES_PTR | ||
| 196 | |||
| 197 | /* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there | ||
| 198 | * is no reason to not xor all the sub items together. This potentially | ||
| 199 | * saves a register since things can be xored directly into L */ | ||
| 200 | |||
| 201 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
| 202 | #ifdef DES_RISC1 | ||
| 203 | #define D_ENCRYPT(LL,R,S) { \ | ||
| 204 | unsigned int u1,u2,u3; \ | ||
| 205 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
| 206 | u2=(int)u>>8L; \ | ||
| 207 | u1=(int)u&0xfc; \ | ||
| 208 | u2&=0xfc; \ | ||
| 209 | t=ROTATE(t,4); \ | ||
| 210 | u>>=16L; \ | ||
| 211 | LL^= *(const DES_LONG *)(des_SP +u1); \ | ||
| 212 | LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ | ||
| 213 | u3=(int)(u>>8L); \ | ||
| 214 | u1=(int)u&0xfc; \ | ||
| 215 | u3&=0xfc; \ | ||
| 216 | LL^= *(const DES_LONG *)(des_SP+0x400+u1); \ | ||
| 217 | LL^= *(const DES_LONG *)(des_SP+0x600+u3); \ | ||
| 218 | u2=(int)t>>8L; \ | ||
| 219 | u1=(int)t&0xfc; \ | ||
| 220 | u2&=0xfc; \ | ||
| 221 | t>>=16L; \ | ||
| 222 | LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ | ||
| 223 | LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ | ||
| 224 | u3=(int)t>>8L; \ | ||
| 225 | u1=(int)t&0xfc; \ | ||
| 226 | u3&=0xfc; \ | ||
| 227 | LL^= *(const DES_LONG *)(des_SP+0x500+u1); \ | ||
| 228 | LL^= *(const DES_LONG *)(des_SP+0x700+u3); } | ||
| 229 | #endif | ||
| 230 | #ifdef DES_RISC2 | ||
| 231 | #define D_ENCRYPT(LL,R,S) { \ | ||
| 232 | unsigned int u1,u2,s1,s2; \ | ||
| 233 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
| 234 | u2=(int)u>>8L; \ | ||
| 235 | u1=(int)u&0xfc; \ | ||
| 236 | u2&=0xfc; \ | ||
| 237 | t=ROTATE(t,4); \ | ||
| 238 | LL^= *(const DES_LONG *)(des_SP +u1); \ | ||
| 239 | LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ | ||
| 240 | s1=(int)(u>>16L); \ | ||
| 241 | s2=(int)(u>>24L); \ | ||
| 242 | s1&=0xfc; \ | ||
| 243 | s2&=0xfc; \ | ||
| 244 | LL^= *(const DES_LONG *)(des_SP+0x400+s1); \ | ||
| 245 | LL^= *(const DES_LONG *)(des_SP+0x600+s2); \ | ||
| 246 | u2=(int)t>>8L; \ | ||
| 247 | u1=(int)t&0xfc; \ | ||
| 248 | u2&=0xfc; \ | ||
| 249 | LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ | ||
| 250 | LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ | ||
| 251 | s1=(int)(t>>16L); \ | ||
| 252 | s2=(int)(t>>24L); \ | ||
| 253 | s1&=0xfc; \ | ||
| 254 | s2&=0xfc; \ | ||
| 255 | LL^= *(const DES_LONG *)(des_SP+0x500+s1); \ | ||
| 256 | LL^= *(const DES_LONG *)(des_SP+0x700+s2); } | ||
| 257 | #endif | ||
| 258 | #else | ||
| 259 | #define D_ENCRYPT(LL,R,S) { \ | ||
| 260 | LOAD_DATA_tmp(R,S,u,t,E0,E1); \ | ||
| 261 | t=ROTATE(t,4); \ | ||
| 262 | LL^= \ | ||
| 263 | *(const DES_LONG *)(des_SP +((u )&0xfc))^ \ | ||
| 264 | *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \ | ||
| 265 | *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \ | ||
| 266 | *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \ | ||
| 267 | *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \ | ||
| 268 | *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \ | ||
| 269 | *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \ | ||
| 270 | *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); } | ||
| 271 | #endif | ||
| 272 | |||
| 273 | #else /* original version */ | ||
| 274 | |||
| 275 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
| 276 | #ifdef DES_RISC1 | ||
| 277 | #define D_ENCRYPT(LL,R,S) {\ | ||
| 278 | unsigned int u1,u2,u3; \ | ||
| 279 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
| 280 | u>>=2L; \ | ||
| 281 | t=ROTATE(t,6); \ | ||
| 282 | u2=(int)u>>8L; \ | ||
| 283 | u1=(int)u&0x3f; \ | ||
| 284 | u2&=0x3f; \ | ||
| 285 | u>>=16L; \ | ||
| 286 | LL^=DES_SPtrans[0][u1]; \ | ||
| 287 | LL^=DES_SPtrans[2][u2]; \ | ||
| 288 | u3=(int)u>>8L; \ | ||
| 289 | u1=(int)u&0x3f; \ | ||
| 290 | u3&=0x3f; \ | ||
| 291 | LL^=DES_SPtrans[4][u1]; \ | ||
| 292 | LL^=DES_SPtrans[6][u3]; \ | ||
| 293 | u2=(int)t>>8L; \ | ||
| 294 | u1=(int)t&0x3f; \ | ||
| 295 | u2&=0x3f; \ | ||
| 296 | t>>=16L; \ | ||
| 297 | LL^=DES_SPtrans[1][u1]; \ | ||
| 298 | LL^=DES_SPtrans[3][u2]; \ | ||
| 299 | u3=(int)t>>8L; \ | ||
| 300 | u1=(int)t&0x3f; \ | ||
| 301 | u3&=0x3f; \ | ||
| 302 | LL^=DES_SPtrans[5][u1]; \ | ||
| 303 | LL^=DES_SPtrans[7][u3]; } | ||
| 304 | #endif | ||
| 305 | #ifdef DES_RISC2 | ||
| 306 | #define D_ENCRYPT(LL,R,S) {\ | ||
| 307 | unsigned int u1,u2,s1,s2; \ | ||
| 308 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
| 309 | u>>=2L; \ | ||
| 310 | t=ROTATE(t,6); \ | ||
| 311 | u2=(int)u>>8L; \ | ||
| 312 | u1=(int)u&0x3f; \ | ||
| 313 | u2&=0x3f; \ | ||
| 314 | LL^=DES_SPtrans[0][u1]; \ | ||
| 315 | LL^=DES_SPtrans[2][u2]; \ | ||
| 316 | s1=(int)u>>16L; \ | ||
| 317 | s2=(int)u>>24L; \ | ||
| 318 | s1&=0x3f; \ | ||
| 319 | s2&=0x3f; \ | ||
| 320 | LL^=DES_SPtrans[4][s1]; \ | ||
| 321 | LL^=DES_SPtrans[6][s2]; \ | ||
| 322 | u2=(int)t>>8L; \ | ||
| 323 | u1=(int)t&0x3f; \ | ||
| 324 | u2&=0x3f; \ | ||
| 325 | LL^=DES_SPtrans[1][u1]; \ | ||
| 326 | LL^=DES_SPtrans[3][u2]; \ | ||
| 327 | s1=(int)t>>16; \ | ||
| 328 | s2=(int)t>>24L; \ | ||
| 329 | s1&=0x3f; \ | ||
| 330 | s2&=0x3f; \ | ||
| 331 | LL^=DES_SPtrans[5][s1]; \ | ||
| 332 | LL^=DES_SPtrans[7][s2]; } | ||
| 333 | #endif | ||
| 334 | |||
| 335 | #else | ||
| 336 | |||
| 337 | #define D_ENCRYPT(LL,R,S) {\ | ||
| 338 | LOAD_DATA_tmp(R,S,u,t,E0,E1); \ | ||
| 339 | t=ROTATE(t,4); \ | ||
| 340 | LL^=\ | ||
| 341 | DES_SPtrans[0][(u>> 2L)&0x3f]^ \ | ||
| 342 | DES_SPtrans[2][(u>>10L)&0x3f]^ \ | ||
| 343 | DES_SPtrans[4][(u>>18L)&0x3f]^ \ | ||
| 344 | DES_SPtrans[6][(u>>26L)&0x3f]^ \ | ||
| 345 | DES_SPtrans[1][(t>> 2L)&0x3f]^ \ | ||
| 346 | DES_SPtrans[3][(t>>10L)&0x3f]^ \ | ||
| 347 | DES_SPtrans[5][(t>>18L)&0x3f]^ \ | ||
| 348 | DES_SPtrans[7][(t>>26L)&0x3f]; } | ||
| 349 | #endif | ||
| 350 | #endif | ||
| 351 | |||
| 352 | /* IP and FP | ||
| 353 | * The problem is more of a geometric problem that random bit fiddling. | ||
| 354 | 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 | ||
| 355 | 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 | ||
| 356 | 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 | ||
| 357 | 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 | ||
| 358 | |||
| 359 | 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 | ||
| 360 | 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 | ||
| 361 | 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 | ||
| 362 | 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 | ||
| 363 | |||
| 364 | The output has been subject to swaps of the form | ||
| 365 | 0 1 -> 3 1 but the odd and even bits have been put into | ||
| 366 | 2 3 2 0 | ||
| 367 | different words. The main trick is to remember that | ||
| 368 | t=((l>>size)^r)&(mask); | ||
| 369 | r^=t; | ||
| 370 | l^=(t<<size); | ||
| 371 | can be used to swap and move bits between words. | ||
| 372 | |||
| 373 | So l = 0 1 2 3 r = 16 17 18 19 | ||
| 374 | 4 5 6 7 20 21 22 23 | ||
| 375 | 8 9 10 11 24 25 26 27 | ||
| 376 | 12 13 14 15 28 29 30 31 | ||
| 377 | becomes (for size == 2 and mask == 0x3333) | ||
| 378 | t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19 | ||
| 379 | 6^20 7^21 -- -- 4 5 20 21 6 7 22 23 | ||
| 380 | 10^24 11^25 -- -- 8 9 24 25 10 11 24 25 | ||
| 381 | 14^28 15^29 -- -- 12 13 28 29 14 15 28 29 | ||
| 382 | |||
| 383 | Thanks for hints from Richard Outerbridge - he told me IP&FP | ||
| 384 | could be done in 15 xor, 10 shifts and 5 ands. | ||
| 385 | When I finally started to think of the problem in 2D | ||
| 386 | I first got ~42 operations without xors. When I remembered | ||
| 387 | how to use xors :-) I got it to its final state. | ||
| 388 | */ | ||
| 389 | #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
| 390 | (b)^=(t),\ | ||
| 391 | (a)^=((t)<<(n))) | ||
| 392 | |||
| 393 | #define IP(l,r) \ | ||
| 394 | { \ | ||
| 395 | register DES_LONG tt; \ | ||
| 396 | PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ | ||
| 397 | PERM_OP(l,r,tt,16,0x0000ffffL); \ | ||
| 398 | PERM_OP(r,l,tt, 2,0x33333333L); \ | ||
| 399 | PERM_OP(l,r,tt, 8,0x00ff00ffL); \ | ||
| 400 | PERM_OP(r,l,tt, 1,0x55555555L); \ | ||
| 401 | } | ||
| 402 | |||
| 403 | #define FP(l,r) \ | ||
| 404 | { \ | ||
| 405 | register DES_LONG tt; \ | ||
| 406 | PERM_OP(l,r,tt, 1,0x55555555L); \ | ||
| 407 | PERM_OP(r,l,tt, 8,0x00ff00ffL); \ | ||
| 408 | PERM_OP(l,r,tt, 2,0x33333333L); \ | ||
| 409 | PERM_OP(r,l,tt,16,0x0000ffffL); \ | ||
| 410 | PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ | ||
| 411 | } | ||
| 412 | |||
| 413 | OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64]; | ||
| 414 | |||
| 415 | void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, | ||
| 416 | DES_LONG Eswap0, DES_LONG Eswap1); | ||
| 417 | #endif | ||
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c deleted file mode 100644 index c3437bc606..0000000000 --- a/src/lib/libcrypto/des/ecb3_enc.c +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | /* crypto/des/ecb3_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 62 | DES_key_schedule *ks1, DES_key_schedule *ks2, | ||
| 63 | DES_key_schedule *ks3, | ||
| 64 | int enc) | ||
| 65 | { | ||
| 66 | register DES_LONG l0,l1; | ||
| 67 | DES_LONG ll[2]; | ||
| 68 | const unsigned char *in = &(*input)[0]; | ||
| 69 | unsigned char *out = &(*output)[0]; | ||
| 70 | |||
| 71 | c2l(in,l0); | ||
| 72 | c2l(in,l1); | ||
| 73 | ll[0]=l0; | ||
| 74 | ll[1]=l1; | ||
| 75 | if (enc) | ||
| 76 | DES_encrypt3(ll,ks1,ks2,ks3); | ||
| 77 | else | ||
| 78 | DES_decrypt3(ll,ks1,ks2,ks3); | ||
| 79 | l0=ll[0]; | ||
| 80 | l1=ll[1]; | ||
| 81 | l2c(l0,out); | ||
| 82 | l2c(l1,out); | ||
| 83 | } | ||
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c deleted file mode 100644 index 1b70f68806..0000000000 --- a/src/lib/libcrypto/des/ecb_enc.c +++ /dev/null | |||
| @@ -1,121 +0,0 @@ | |||
| 1 | /* crypto/des/ecb_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | #include "des_ver.h" | ||
| 61 | #include "spr.h" | ||
| 62 | #include <openssl/opensslv.h> | ||
| 63 | |||
| 64 | OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; | ||
| 65 | OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; | ||
| 66 | |||
| 67 | const char *DES_options(void) | ||
| 68 | { | ||
| 69 | static int init=1; | ||
| 70 | static char buf[32]; | ||
| 71 | |||
| 72 | if (init) | ||
| 73 | { | ||
| 74 | const char *ptr,*unroll,*risc,*size; | ||
| 75 | |||
| 76 | #ifdef DES_PTR | ||
| 77 | ptr="ptr"; | ||
| 78 | #else | ||
| 79 | ptr="idx"; | ||
| 80 | #endif | ||
| 81 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
| 82 | #ifdef DES_RISC1 | ||
| 83 | risc="risc1"; | ||
| 84 | #endif | ||
| 85 | #ifdef DES_RISC2 | ||
| 86 | risc="risc2"; | ||
| 87 | #endif | ||
| 88 | #else | ||
| 89 | risc="cisc"; | ||
| 90 | #endif | ||
| 91 | #ifdef DES_UNROLL | ||
| 92 | unroll="16"; | ||
| 93 | #else | ||
| 94 | unroll="4"; | ||
| 95 | #endif | ||
| 96 | if (sizeof(DES_LONG) != sizeof(long)) | ||
| 97 | size="int"; | ||
| 98 | else | ||
| 99 | size="long"; | ||
| 100 | sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); | ||
| 101 | init=0; | ||
| 102 | } | ||
| 103 | return(buf); | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 108 | DES_key_schedule *ks, int enc) | ||
| 109 | { | ||
| 110 | register DES_LONG l; | ||
| 111 | DES_LONG ll[2]; | ||
| 112 | const unsigned char *in = &(*input)[0]; | ||
| 113 | unsigned char *out = &(*output)[0]; | ||
| 114 | |||
| 115 | c2l(in,l); ll[0]=l; | ||
| 116 | c2l(in,l); ll[1]=l; | ||
| 117 | DES_encrypt1(ll,ks,enc); | ||
| 118 | l=ll[0]; l2c(l,out); | ||
| 119 | l=ll[1]; l2c(l,out); | ||
| 120 | l=ll[0]=ll[1]=0; | ||
| 121 | } | ||
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c deleted file mode 100644 index fa45aa272b..0000000000 --- a/src/lib/libcrypto/des/ede_cbcm_enc.c +++ /dev/null | |||
| @@ -1,197 +0,0 @@ | |||
| 1 | /* ede_cbcm_enc.c */ | ||
| 2 | /* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL | ||
| 3 | * project 13 Feb 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | /* | ||
| 60 | |||
| 61 | This is an implementation of Triple DES Cipher Block Chaining with Output | ||
| 62 | Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom). | ||
| 63 | |||
| 64 | Note that there is a known attack on this by Biham and Knudsen but it takes | ||
| 65 | a lot of work: | ||
| 66 | |||
| 67 | http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz | ||
| 68 | |||
| 69 | */ | ||
| 70 | |||
| 71 | #ifndef OPENSSL_NO_DESCBCM | ||
| 72 | #include "des_locl.h" | ||
| 73 | |||
| 74 | void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | ||
| 75 | long length, DES_key_schedule *ks1, DES_key_schedule *ks2, | ||
| 76 | DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, | ||
| 77 | int enc) | ||
| 78 | { | ||
| 79 | register DES_LONG tin0,tin1; | ||
| 80 | register DES_LONG tout0,tout1,xor0,xor1,m0,m1; | ||
| 81 | register long l=length; | ||
| 82 | DES_LONG tin[2]; | ||
| 83 | unsigned char *iv1,*iv2; | ||
| 84 | |||
| 85 | iv1 = &(*ivec1)[0]; | ||
| 86 | iv2 = &(*ivec2)[0]; | ||
| 87 | |||
| 88 | if (enc) | ||
| 89 | { | ||
| 90 | c2l(iv1,m0); | ||
| 91 | c2l(iv1,m1); | ||
| 92 | c2l(iv2,tout0); | ||
| 93 | c2l(iv2,tout1); | ||
| 94 | for (l-=8; l>=-7; l-=8) | ||
| 95 | { | ||
| 96 | tin[0]=m0; | ||
| 97 | tin[1]=m1; | ||
| 98 | DES_encrypt1(tin,ks3,1); | ||
| 99 | m0=tin[0]; | ||
| 100 | m1=tin[1]; | ||
| 101 | |||
| 102 | if(l < 0) | ||
| 103 | { | ||
| 104 | c2ln(in,tin0,tin1,l+8); | ||
| 105 | } | ||
| 106 | else | ||
| 107 | { | ||
| 108 | c2l(in,tin0); | ||
| 109 | c2l(in,tin1); | ||
| 110 | } | ||
| 111 | tin0^=tout0; | ||
| 112 | tin1^=tout1; | ||
| 113 | |||
| 114 | tin[0]=tin0; | ||
| 115 | tin[1]=tin1; | ||
| 116 | DES_encrypt1(tin,ks1,1); | ||
| 117 | tin[0]^=m0; | ||
| 118 | tin[1]^=m1; | ||
| 119 | DES_encrypt1(tin,ks2,0); | ||
| 120 | tin[0]^=m0; | ||
| 121 | tin[1]^=m1; | ||
| 122 | DES_encrypt1(tin,ks1,1); | ||
| 123 | tout0=tin[0]; | ||
| 124 | tout1=tin[1]; | ||
| 125 | |||
| 126 | l2c(tout0,out); | ||
| 127 | l2c(tout1,out); | ||
| 128 | } | ||
| 129 | iv1=&(*ivec1)[0]; | ||
| 130 | l2c(m0,iv1); | ||
| 131 | l2c(m1,iv1); | ||
| 132 | |||
| 133 | iv2=&(*ivec2)[0]; | ||
| 134 | l2c(tout0,iv2); | ||
| 135 | l2c(tout1,iv2); | ||
| 136 | } | ||
| 137 | else | ||
| 138 | { | ||
| 139 | register DES_LONG t0,t1; | ||
| 140 | |||
| 141 | c2l(iv1,m0); | ||
| 142 | c2l(iv1,m1); | ||
| 143 | c2l(iv2,xor0); | ||
| 144 | c2l(iv2,xor1); | ||
| 145 | for (l-=8; l>=-7; l-=8) | ||
| 146 | { | ||
| 147 | tin[0]=m0; | ||
| 148 | tin[1]=m1; | ||
| 149 | DES_encrypt1(tin,ks3,1); | ||
| 150 | m0=tin[0]; | ||
| 151 | m1=tin[1]; | ||
| 152 | |||
| 153 | c2l(in,tin0); | ||
| 154 | c2l(in,tin1); | ||
| 155 | |||
| 156 | t0=tin0; | ||
| 157 | t1=tin1; | ||
| 158 | |||
| 159 | tin[0]=tin0; | ||
| 160 | tin[1]=tin1; | ||
| 161 | DES_encrypt1(tin,ks1,0); | ||
| 162 | tin[0]^=m0; | ||
| 163 | tin[1]^=m1; | ||
| 164 | DES_encrypt1(tin,ks2,1); | ||
| 165 | tin[0]^=m0; | ||
| 166 | tin[1]^=m1; | ||
| 167 | DES_encrypt1(tin,ks1,0); | ||
| 168 | tout0=tin[0]; | ||
| 169 | tout1=tin[1]; | ||
| 170 | |||
| 171 | tout0^=xor0; | ||
| 172 | tout1^=xor1; | ||
| 173 | if(l < 0) | ||
| 174 | { | ||
| 175 | l2cn(tout0,tout1,out,l+8); | ||
| 176 | } | ||
| 177 | else | ||
| 178 | { | ||
| 179 | l2c(tout0,out); | ||
| 180 | l2c(tout1,out); | ||
| 181 | } | ||
| 182 | xor0=t0; | ||
| 183 | xor1=t1; | ||
| 184 | } | ||
| 185 | |||
| 186 | iv1=&(*ivec1)[0]; | ||
| 187 | l2c(m0,iv1); | ||
| 188 | l2c(m1,iv1); | ||
| 189 | |||
| 190 | iv2=&(*ivec2)[0]; | ||
| 191 | l2c(xor0,iv2); | ||
| 192 | l2c(xor1,iv2); | ||
| 193 | } | ||
| 194 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
| 195 | tin[0]=tin[1]=0; | ||
| 196 | } | ||
| 197 | #endif | ||
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c deleted file mode 100644 index c70fb686b8..0000000000 --- a/src/lib/libcrypto/des/enc_read.c +++ /dev/null | |||
| @@ -1,228 +0,0 @@ | |||
| 1 | /* crypto/des/enc_read.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <errno.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include "des_locl.h" | ||
| 63 | |||
| 64 | /* This has some uglies in it but it works - even over sockets. */ | ||
| 65 | /*extern int errno;*/ | ||
| 66 | OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE; | ||
| 67 | |||
| 68 | |||
| 69 | /* | ||
| 70 | * WARNINGS: | ||
| 71 | * | ||
| 72 | * - The data format used by DES_enc_write() and DES_enc_read() | ||
| 73 | * has a cryptographic weakness: When asked to write more | ||
| 74 | * than MAXWRITE bytes, DES_enc_write will split the data | ||
| 75 | * into several chunks that are all encrypted | ||
| 76 | * using the same IV. So don't use these functions unless you | ||
| 77 | * are sure you know what you do (in which case you might | ||
| 78 | * not want to use them anyway). | ||
| 79 | * | ||
| 80 | * - This code cannot handle non-blocking sockets. | ||
| 81 | * | ||
| 82 | * - This function uses an internal state and thus cannot be | ||
| 83 | * used on multiple files. | ||
| 84 | */ | ||
| 85 | |||
| 86 | |||
| 87 | int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, | ||
| 88 | DES_cblock *iv) | ||
| 89 | { | ||
| 90 | /* data to be unencrypted */ | ||
| 91 | int net_num=0; | ||
| 92 | static unsigned char *net=NULL; | ||
| 93 | /* extra unencrypted data | ||
| 94 | * for when a block of 100 comes in but is des_read one byte at | ||
| 95 | * a time. */ | ||
| 96 | static unsigned char *unnet=NULL; | ||
| 97 | static int unnet_start=0; | ||
| 98 | static int unnet_left=0; | ||
| 99 | static unsigned char *tmpbuf=NULL; | ||
| 100 | int i; | ||
| 101 | long num=0,rnum; | ||
| 102 | unsigned char *p; | ||
| 103 | |||
| 104 | if (tmpbuf == NULL) | ||
| 105 | { | ||
| 106 | tmpbuf=OPENSSL_malloc(BSIZE); | ||
| 107 | if (tmpbuf == NULL) return(-1); | ||
| 108 | } | ||
| 109 | if (net == NULL) | ||
| 110 | { | ||
| 111 | net=OPENSSL_malloc(BSIZE); | ||
| 112 | if (net == NULL) return(-1); | ||
| 113 | } | ||
| 114 | if (unnet == NULL) | ||
| 115 | { | ||
| 116 | unnet=OPENSSL_malloc(BSIZE); | ||
| 117 | if (unnet == NULL) return(-1); | ||
| 118 | } | ||
| 119 | /* left over data from last decrypt */ | ||
| 120 | if (unnet_left != 0) | ||
| 121 | { | ||
| 122 | if (unnet_left < len) | ||
| 123 | { | ||
| 124 | /* we still still need more data but will return | ||
| 125 | * with the number of bytes we have - should always | ||
| 126 | * check the return value */ | ||
| 127 | memcpy(buf,&(unnet[unnet_start]), | ||
| 128 | unnet_left); | ||
| 129 | /* eay 26/08/92 I had the next 2 lines | ||
| 130 | * reversed :-( */ | ||
| 131 | i=unnet_left; | ||
| 132 | unnet_start=unnet_left=0; | ||
| 133 | } | ||
| 134 | else | ||
| 135 | { | ||
| 136 | memcpy(buf,&(unnet[unnet_start]),len); | ||
| 137 | unnet_start+=len; | ||
| 138 | unnet_left-=len; | ||
| 139 | i=len; | ||
| 140 | } | ||
| 141 | return(i); | ||
| 142 | } | ||
| 143 | |||
| 144 | /* We need to get more data. */ | ||
| 145 | if (len > MAXWRITE) len=MAXWRITE; | ||
| 146 | |||
| 147 | /* first - get the length */ | ||
| 148 | while (net_num < HDRSIZE) | ||
| 149 | { | ||
| 150 | i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); | ||
| 151 | #ifdef EINTR | ||
| 152 | if ((i == -1) && (errno == EINTR)) continue; | ||
| 153 | #endif | ||
| 154 | if (i <= 0) return(0); | ||
| 155 | net_num+=i; | ||
| 156 | } | ||
| 157 | |||
| 158 | /* we now have at net_num bytes in net */ | ||
| 159 | p=net; | ||
| 160 | /* num=0; */ | ||
| 161 | n2l(p,num); | ||
| 162 | /* num should be rounded up to the next group of eight | ||
| 163 | * we make sure that we have read a multiple of 8 bytes from the net. | ||
| 164 | */ | ||
| 165 | if ((num > MAXWRITE) || (num < 0)) /* error */ | ||
| 166 | return(-1); | ||
| 167 | rnum=(num < 8)?8:((num+7)/8*8); | ||
| 168 | |||
| 169 | net_num=0; | ||
| 170 | while (net_num < rnum) | ||
| 171 | { | ||
| 172 | i=read(fd,(void *)&(net[net_num]),rnum-net_num); | ||
| 173 | #ifdef EINTR | ||
| 174 | if ((i == -1) && (errno == EINTR)) continue; | ||
| 175 | #endif | ||
| 176 | if (i <= 0) return(0); | ||
| 177 | net_num+=i; | ||
| 178 | } | ||
| 179 | |||
| 180 | /* Check if there will be data left over. */ | ||
| 181 | if (len < num) | ||
| 182 | { | ||
| 183 | if (DES_rw_mode & DES_PCBC_MODE) | ||
| 184 | DES_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); | ||
| 185 | else | ||
| 186 | DES_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); | ||
| 187 | memcpy(buf,unnet,len); | ||
| 188 | unnet_start=len; | ||
| 189 | unnet_left=num-len; | ||
| 190 | |||
| 191 | /* The following line is done because we return num | ||
| 192 | * as the number of bytes read. */ | ||
| 193 | num=len; | ||
| 194 | } | ||
| 195 | else | ||
| 196 | { | ||
| 197 | /* >output is a multiple of 8 byes, if len < rnum | ||
| 198 | * >we must be careful. The user must be aware that this | ||
| 199 | * >routine will write more bytes than he asked for. | ||
| 200 | * >The length of the buffer must be correct. | ||
| 201 | * FIXED - Should be ok now 18-9-90 - eay */ | ||
| 202 | if (len < rnum) | ||
| 203 | { | ||
| 204 | |||
| 205 | if (DES_rw_mode & DES_PCBC_MODE) | ||
| 206 | DES_pcbc_encrypt(net,tmpbuf,num,sched,iv, | ||
| 207 | DES_DECRYPT); | ||
| 208 | else | ||
| 209 | DES_cbc_encrypt(net,tmpbuf,num,sched,iv, | ||
| 210 | DES_DECRYPT); | ||
| 211 | |||
| 212 | /* eay 26/08/92 fix a bug that returned more | ||
| 213 | * bytes than you asked for (returned len bytes :-( */ | ||
| 214 | memcpy(buf,tmpbuf,num); | ||
| 215 | } | ||
| 216 | else | ||
| 217 | { | ||
| 218 | if (DES_rw_mode & DES_PCBC_MODE) | ||
| 219 | DES_pcbc_encrypt(net,buf,num,sched,iv, | ||
| 220 | DES_DECRYPT); | ||
| 221 | else | ||
| 222 | DES_cbc_encrypt(net,buf,num,sched,iv, | ||
| 223 | DES_DECRYPT); | ||
| 224 | } | ||
| 225 | } | ||
| 226 | return num; | ||
| 227 | } | ||
| 228 | |||
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c deleted file mode 100644 index af5b8c2349..0000000000 --- a/src/lib/libcrypto/des/enc_writ.c +++ /dev/null | |||
| @@ -1,171 +0,0 @@ | |||
| 1 | /* crypto/des/enc_writ.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <errno.h> | ||
| 60 | #include <time.h> | ||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "des_locl.h" | ||
| 64 | #include <openssl/rand.h> | ||
| 65 | |||
| 66 | /* | ||
| 67 | * WARNINGS: | ||
| 68 | * | ||
| 69 | * - The data format used by DES_enc_write() and DES_enc_read() | ||
| 70 | * has a cryptographic weakness: When asked to write more | ||
| 71 | * than MAXWRITE bytes, DES_enc_write will split the data | ||
| 72 | * into several chunks that are all encrypted | ||
| 73 | * using the same IV. So don't use these functions unless you | ||
| 74 | * are sure you know what you do (in which case you might | ||
| 75 | * not want to use them anyway). | ||
| 76 | * | ||
| 77 | * - This code cannot handle non-blocking sockets. | ||
| 78 | */ | ||
| 79 | |||
| 80 | int DES_enc_write(int fd, const void *_buf, int len, | ||
| 81 | DES_key_schedule *sched, DES_cblock *iv) | ||
| 82 | { | ||
| 83 | #ifdef _LIBC | ||
| 84 | extern unsigned long time(); | ||
| 85 | extern int write(); | ||
| 86 | #endif | ||
| 87 | const unsigned char *buf=_buf; | ||
| 88 | long rnum; | ||
| 89 | int i,j,k,outnum; | ||
| 90 | static unsigned char *outbuf=NULL; | ||
| 91 | unsigned char shortbuf[8]; | ||
| 92 | unsigned char *p; | ||
| 93 | const unsigned char *cp; | ||
| 94 | static int start=1; | ||
| 95 | |||
| 96 | if (outbuf == NULL) | ||
| 97 | { | ||
| 98 | outbuf=OPENSSL_malloc(BSIZE+HDRSIZE); | ||
| 99 | if (outbuf == NULL) return(-1); | ||
| 100 | } | ||
| 101 | /* If we are sending less than 8 bytes, the same char will look | ||
| 102 | * the same if we don't pad it out with random bytes */ | ||
| 103 | if (start) | ||
| 104 | { | ||
| 105 | start=0; | ||
| 106 | } | ||
| 107 | |||
| 108 | /* lets recurse if we want to send the data in small chunks */ | ||
| 109 | if (len > MAXWRITE) | ||
| 110 | { | ||
| 111 | j=0; | ||
| 112 | for (i=0; i<len; i+=k) | ||
| 113 | { | ||
| 114 | k=DES_enc_write(fd,&(buf[i]), | ||
| 115 | ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv); | ||
| 116 | if (k < 0) | ||
| 117 | return(k); | ||
| 118 | else | ||
| 119 | j+=k; | ||
| 120 | } | ||
| 121 | return(j); | ||
| 122 | } | ||
| 123 | |||
| 124 | /* write length first */ | ||
| 125 | p=outbuf; | ||
| 126 | l2n(len,p); | ||
| 127 | |||
| 128 | /* pad short strings */ | ||
| 129 | if (len < 8) | ||
| 130 | { | ||
| 131 | cp=shortbuf; | ||
| 132 | memcpy(shortbuf,buf,len); | ||
| 133 | RAND_pseudo_bytes(shortbuf+len, 8-len); | ||
| 134 | rnum=8; | ||
| 135 | } | ||
| 136 | else | ||
| 137 | { | ||
| 138 | cp=buf; | ||
| 139 | rnum=((len+7)/8*8); /* round up to nearest eight */ | ||
| 140 | } | ||
| 141 | |||
| 142 | if (DES_rw_mode & DES_PCBC_MODE) | ||
| 143 | DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, | ||
| 144 | DES_ENCRYPT); | ||
| 145 | else | ||
| 146 | DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, | ||
| 147 | DES_ENCRYPT); | ||
| 148 | |||
| 149 | /* output */ | ||
| 150 | outnum=rnum+HDRSIZE; | ||
| 151 | |||
| 152 | for (j=0; j<outnum; j+=i) | ||
| 153 | { | ||
| 154 | /* eay 26/08/92 I was not doing writing from where we | ||
| 155 | * got up to. */ | ||
| 156 | i=write(fd,(void *)&(outbuf[j]),outnum-j); | ||
| 157 | if (i == -1) | ||
| 158 | { | ||
| 159 | #ifdef EINTR | ||
| 160 | if (errno == EINTR) | ||
| 161 | i=0; | ||
| 162 | else | ||
| 163 | #endif | ||
| 164 | /* This is really a bad error - very bad | ||
| 165 | * It will stuff-up both ends. */ | ||
| 166 | return(-1); | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | return(len); | ||
| 171 | } | ||
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c deleted file mode 100644 index 2758c32656..0000000000 --- a/src/lib/libcrypto/des/fcrypt.c +++ /dev/null | |||
| @@ -1,173 +0,0 @@ | |||
| 1 | /* NOCW */ | ||
| 2 | #include <stdio.h> | ||
| 3 | #ifdef _OSD_POSIX | ||
| 4 | #ifndef CHARSET_EBCDIC | ||
| 5 | #define CHARSET_EBCDIC 1 | ||
| 6 | #endif | ||
| 7 | #endif | ||
| 8 | #ifdef CHARSET_EBCDIC | ||
| 9 | #include <openssl/ebcdic.h> | ||
| 10 | #endif | ||
| 11 | |||
| 12 | /* This version of crypt has been developed from my MIT compatible | ||
| 13 | * DES library. | ||
| 14 | * Eric Young (eay@cryptsoft.com) | ||
| 15 | */ | ||
| 16 | |||
| 17 | /* Modification by Jens Kupferschmidt (Cu) | ||
| 18 | * I have included directive PARA for shared memory computers. | ||
| 19 | * I have included a directive LONGCRYPT to using this routine to cipher | ||
| 20 | * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN | ||
| 21 | * definition is the maximum of length of password and can changed. I have | ||
| 22 | * defined 24. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "des_locl.h" | ||
| 26 | |||
| 27 | /* Added more values to handle illegal salt values the way normal | ||
| 28 | * crypt() implementations do. The patch was sent by | ||
| 29 | * Bjorn Gronvall <bg@sics.se> | ||
| 30 | */ | ||
| 31 | static unsigned const char con_salt[128]={ | ||
| 32 | 0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9, | ||
| 33 | 0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1, | ||
| 34 | 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9, | ||
| 35 | 0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1, | ||
| 36 | 0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9, | ||
| 37 | 0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x00,0x01, | ||
| 38 | 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, | ||
| 39 | 0x0A,0x0B,0x05,0x06,0x07,0x08,0x09,0x0A, | ||
| 40 | 0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12, | ||
| 41 | 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A, | ||
| 42 | 0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22, | ||
| 43 | 0x23,0x24,0x25,0x20,0x21,0x22,0x23,0x24, | ||
| 44 | 0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C, | ||
| 45 | 0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34, | ||
| 46 | 0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C, | ||
| 47 | 0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44, | ||
| 48 | }; | ||
| 49 | |||
| 50 | static unsigned const char cov_2char[64]={ | ||
| 51 | 0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35, | ||
| 52 | 0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44, | ||
| 53 | 0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C, | ||
| 54 | 0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54, | ||
| 55 | 0x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62, | ||
| 56 | 0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A, | ||
| 57 | 0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72, | ||
| 58 | 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A | ||
| 59 | }; | ||
| 60 | |||
| 61 | void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, | ||
| 62 | DES_LONG Eswap0, DES_LONG Eswap1); | ||
| 63 | |||
| 64 | char *DES_crypt(const char *buf, const char *salt) | ||
| 65 | { | ||
| 66 | static char buff[14]; | ||
| 67 | |||
| 68 | #ifndef CHARSET_EBCDIC | ||
| 69 | return(DES_fcrypt(buf,salt,buff)); | ||
| 70 | #else | ||
| 71 | char e_salt[2+1]; | ||
| 72 | char e_buf[32+1]; /* replace 32 by 8 ? */ | ||
| 73 | char *ret; | ||
| 74 | |||
| 75 | /* Copy at most 2 chars of salt */ | ||
| 76 | if ((e_salt[0] = salt[0]) != '\0') | ||
| 77 | e_salt[1] = salt[1]; | ||
| 78 | |||
| 79 | /* Copy at most 32 chars of password */ | ||
| 80 | strncpy (e_buf, buf, sizeof(e_buf)); | ||
| 81 | |||
| 82 | /* Make sure we have a delimiter */ | ||
| 83 | e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0'; | ||
| 84 | |||
| 85 | /* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */ | ||
| 86 | ebcdic2ascii(e_salt, e_salt, sizeof e_salt); | ||
| 87 | |||
| 88 | /* Convert the cleartext password to ASCII */ | ||
| 89 | ebcdic2ascii(e_buf, e_buf, sizeof e_buf); | ||
| 90 | |||
| 91 | /* Encrypt it (from/to ASCII) */ | ||
| 92 | ret = DES_fcrypt(e_buf,e_salt,buff); | ||
| 93 | |||
| 94 | /* Convert the result back to EBCDIC */ | ||
| 95 | ascii2ebcdic(ret, ret, strlen(ret)); | ||
| 96 | |||
| 97 | return ret; | ||
| 98 | #endif | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | char *DES_fcrypt(const char *buf, const char *salt, char *ret) | ||
| 103 | { | ||
| 104 | unsigned int i,j,x,y; | ||
| 105 | DES_LONG Eswap0,Eswap1; | ||
| 106 | DES_LONG out[2],ll; | ||
| 107 | DES_cblock key; | ||
| 108 | DES_key_schedule ks; | ||
| 109 | unsigned char bb[9]; | ||
| 110 | unsigned char *b=bb; | ||
| 111 | unsigned char c,u; | ||
| 112 | |||
| 113 | /* eay 25/08/92 | ||
| 114 | * If you call crypt("pwd","*") as often happens when you | ||
| 115 | * have * as the pwd field in /etc/passwd, the function | ||
| 116 | * returns *\0XXXXXXXXX | ||
| 117 | * The \0 makes the string look like * so the pwd "*" would | ||
| 118 | * crypt to "*". This was found when replacing the crypt in | ||
| 119 | * our shared libraries. People found that the disabled | ||
| 120 | * accounts effectively had no passwd :-(. */ | ||
| 121 | #ifndef CHARSET_EBCDIC | ||
| 122 | x=ret[0]=((salt[0] == '\0')?'A':salt[0]); | ||
| 123 | Eswap0=con_salt[x]<<2; | ||
| 124 | x=ret[1]=((salt[1] == '\0')?'A':salt[1]); | ||
| 125 | Eswap1=con_salt[x]<<6; | ||
| 126 | #else | ||
| 127 | x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]); | ||
| 128 | Eswap0=con_salt[x]<<2; | ||
| 129 | x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]); | ||
| 130 | Eswap1=con_salt[x]<<6; | ||
| 131 | #endif | ||
| 132 | |||
| 133 | /* EAY | ||
| 134 | r=strlen(buf); | ||
| 135 | r=(r+7)/8; | ||
| 136 | */ | ||
| 137 | for (i=0; i<8; i++) | ||
| 138 | { | ||
| 139 | c= *(buf++); | ||
| 140 | if (!c) break; | ||
| 141 | key[i]=(c<<1); | ||
| 142 | } | ||
| 143 | for (; i<8; i++) | ||
| 144 | key[i]=0; | ||
| 145 | |||
| 146 | DES_set_key_unchecked(&key,&ks); | ||
| 147 | fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1); | ||
| 148 | |||
| 149 | ll=out[0]; l2c(ll,b); | ||
| 150 | ll=out[1]; l2c(ll,b); | ||
| 151 | y=0; | ||
| 152 | u=0x80; | ||
| 153 | bb[8]=0; | ||
| 154 | for (i=2; i<13; i++) | ||
| 155 | { | ||
| 156 | c=0; | ||
| 157 | for (j=0; j<6; j++) | ||
| 158 | { | ||
| 159 | c<<=1; | ||
| 160 | if (bb[y] & u) c|=1; | ||
| 161 | u>>=1; | ||
| 162 | if (!u) | ||
| 163 | { | ||
| 164 | y++; | ||
| 165 | u=0x80; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | ret[i]=cov_2char[c]; | ||
| 169 | } | ||
| 170 | ret[13]='\0'; | ||
| 171 | return(ret); | ||
| 172 | } | ||
| 173 | |||
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c deleted file mode 100644 index 1390138787..0000000000 --- a/src/lib/libcrypto/des/fcrypt_b.c +++ /dev/null | |||
| @@ -1,145 +0,0 @@ | |||
| 1 | /* crypto/des/fcrypt_b.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | |||
| 61 | /* This version of crypt has been developed from my MIT compatible | ||
| 62 | * DES library. | ||
| 63 | * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au | ||
| 64 | * Eric Young (eay@cryptsoft.com) | ||
| 65 | */ | ||
| 66 | |||
| 67 | #define DES_FCRYPT | ||
| 68 | #include "des_locl.h" | ||
| 69 | #undef DES_FCRYPT | ||
| 70 | |||
| 71 | #undef PERM_OP | ||
| 72 | #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
| 73 | (b)^=(t),\ | ||
| 74 | (a)^=((t)<<(n))) | ||
| 75 | |||
| 76 | #undef HPERM_OP | ||
| 77 | #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ | ||
| 78 | (a)=(a)^(t)^(t>>(16-(n))))\ | ||
| 79 | |||
| 80 | void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, | ||
| 81 | DES_LONG Eswap1) | ||
| 82 | { | ||
| 83 | register DES_LONG l,r,t,u; | ||
| 84 | #ifdef DES_PTR | ||
| 85 | register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; | ||
| 86 | #endif | ||
| 87 | register DES_LONG *s; | ||
| 88 | register int j; | ||
| 89 | register DES_LONG E0,E1; | ||
| 90 | |||
| 91 | l=0; | ||
| 92 | r=0; | ||
| 93 | |||
| 94 | s=(DES_LONG *)ks; | ||
| 95 | E0=Eswap0; | ||
| 96 | E1=Eswap1; | ||
| 97 | |||
| 98 | for (j=0; j<25; j++) | ||
| 99 | { | ||
| 100 | #ifndef DES_UNROLL | ||
| 101 | register int i; | ||
| 102 | |||
| 103 | for (i=0; i<32; i+=8) | ||
| 104 | { | ||
| 105 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
| 106 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
| 107 | D_ENCRYPT(l,r,i+4); /* 1 */ | ||
| 108 | D_ENCRYPT(r,l,i+6); /* 2 */ | ||
| 109 | } | ||
| 110 | #else | ||
| 111 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
| 112 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
| 113 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
| 114 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
| 115 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
| 116 | D_ENCRYPT(r,l,10); /* 6 */ | ||
| 117 | D_ENCRYPT(l,r,12); /* 7 */ | ||
| 118 | D_ENCRYPT(r,l,14); /* 8 */ | ||
| 119 | D_ENCRYPT(l,r,16); /* 9 */ | ||
| 120 | D_ENCRYPT(r,l,18); /* 10 */ | ||
| 121 | D_ENCRYPT(l,r,20); /* 11 */ | ||
| 122 | D_ENCRYPT(r,l,22); /* 12 */ | ||
| 123 | D_ENCRYPT(l,r,24); /* 13 */ | ||
| 124 | D_ENCRYPT(r,l,26); /* 14 */ | ||
| 125 | D_ENCRYPT(l,r,28); /* 15 */ | ||
| 126 | D_ENCRYPT(r,l,30); /* 16 */ | ||
| 127 | #endif | ||
| 128 | |||
| 129 | t=l; | ||
| 130 | l=r; | ||
| 131 | r=t; | ||
| 132 | } | ||
| 133 | l=ROTATE(l,3)&0xffffffffL; | ||
| 134 | r=ROTATE(r,3)&0xffffffffL; | ||
| 135 | |||
| 136 | PERM_OP(l,r,t, 1,0x55555555L); | ||
| 137 | PERM_OP(r,l,t, 8,0x00ff00ffL); | ||
| 138 | PERM_OP(l,r,t, 2,0x33333333L); | ||
| 139 | PERM_OP(r,l,t,16,0x0000ffffL); | ||
| 140 | PERM_OP(l,r,t, 4,0x0f0f0f0fL); | ||
| 141 | |||
| 142 | out[0]=r; | ||
| 143 | out[1]=l; | ||
| 144 | } | ||
| 145 | |||
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c deleted file mode 100644 index fda23d522f..0000000000 --- a/src/lib/libcrypto/des/ncbc_enc.c +++ /dev/null | |||
| @@ -1,148 +0,0 @@ | |||
| 1 | /* crypto/des/ncbc_enc.c */ | ||
| 2 | /* | ||
| 3 | * #included by: | ||
| 4 | * cbc_enc.c (DES_cbc_encrypt) | ||
| 5 | * des_enc.c (DES_ncbc_encrypt) | ||
| 6 | */ | ||
| 7 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 8 | * All rights reserved. | ||
| 9 | * | ||
| 10 | * This package is an SSL implementation written | ||
| 11 | * by Eric Young (eay@cryptsoft.com). | ||
| 12 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 13 | * | ||
| 14 | * This library is free for commercial and non-commercial use as long as | ||
| 15 | * the following conditions are aheared to. The following conditions | ||
| 16 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 17 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 18 | * included with this distribution is covered by the same copyright terms | ||
| 19 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 20 | * | ||
| 21 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 22 | * the code are not to be removed. | ||
| 23 | * If this package is used in a product, Eric Young should be given attribution | ||
| 24 | * as the author of the parts of the library used. | ||
| 25 | * This can be in the form of a textual message at program startup or | ||
| 26 | * in documentation (online or textual) provided with the package. | ||
| 27 | * | ||
| 28 | * Redistribution and use in source and binary forms, with or without | ||
| 29 | * modification, are permitted provided that the following conditions | ||
| 30 | * are met: | ||
| 31 | * 1. Redistributions of source code must retain the copyright | ||
| 32 | * notice, this list of conditions and the following disclaimer. | ||
| 33 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 34 | * notice, this list of conditions and the following disclaimer in the | ||
| 35 | * documentation and/or other materials provided with the distribution. | ||
| 36 | * 3. All advertising materials mentioning features or use of this software | ||
| 37 | * must display the following acknowledgement: | ||
| 38 | * "This product includes cryptographic software written by | ||
| 39 | * Eric Young (eay@cryptsoft.com)" | ||
| 40 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 41 | * being used are not cryptographic related :-). | ||
| 42 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 43 | * the apps directory (application code) you must include an acknowledgement: | ||
| 44 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 45 | * | ||
| 46 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 47 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 48 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 49 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 50 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 51 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 52 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 53 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 54 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 55 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 56 | * SUCH DAMAGE. | ||
| 57 | * | ||
| 58 | * The licence and distribution terms for any publically available version or | ||
| 59 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 60 | * copied and put under another distribution licence | ||
| 61 | * [including the GNU Public Licence.] | ||
| 62 | */ | ||
| 63 | |||
| 64 | #include "des_locl.h" | ||
| 65 | |||
| 66 | #ifdef CBC_ENC_C__DONT_UPDATE_IV | ||
| 67 | void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | ||
| 68 | DES_key_schedule *_schedule, DES_cblock *ivec, int enc) | ||
| 69 | #else | ||
| 70 | void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, | ||
| 71 | DES_key_schedule *_schedule, DES_cblock *ivec, int enc) | ||
| 72 | #endif | ||
| 73 | { | ||
| 74 | register DES_LONG tin0,tin1; | ||
| 75 | register DES_LONG tout0,tout1,xor0,xor1; | ||
| 76 | register long l=length; | ||
| 77 | DES_LONG tin[2]; | ||
| 78 | unsigned char *iv; | ||
| 79 | |||
| 80 | iv = &(*ivec)[0]; | ||
| 81 | |||
| 82 | if (enc) | ||
| 83 | { | ||
| 84 | c2l(iv,tout0); | ||
| 85 | c2l(iv,tout1); | ||
| 86 | for (l-=8; l>=0; l-=8) | ||
| 87 | { | ||
| 88 | c2l(in,tin0); | ||
| 89 | c2l(in,tin1); | ||
| 90 | tin0^=tout0; tin[0]=tin0; | ||
| 91 | tin1^=tout1; tin[1]=tin1; | ||
| 92 | DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT); | ||
| 93 | tout0=tin[0]; l2c(tout0,out); | ||
| 94 | tout1=tin[1]; l2c(tout1,out); | ||
| 95 | } | ||
| 96 | if (l != -8) | ||
| 97 | { | ||
| 98 | c2ln(in,tin0,tin1,l+8); | ||
| 99 | tin0^=tout0; tin[0]=tin0; | ||
| 100 | tin1^=tout1; tin[1]=tin1; | ||
| 101 | DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT); | ||
| 102 | tout0=tin[0]; l2c(tout0,out); | ||
| 103 | tout1=tin[1]; l2c(tout1,out); | ||
| 104 | } | ||
| 105 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
| 106 | iv = &(*ivec)[0]; | ||
| 107 | l2c(tout0,iv); | ||
| 108 | l2c(tout1,iv); | ||
| 109 | #endif | ||
| 110 | } | ||
| 111 | else | ||
| 112 | { | ||
| 113 | c2l(iv,xor0); | ||
| 114 | c2l(iv,xor1); | ||
| 115 | for (l-=8; l>=0; l-=8) | ||
| 116 | { | ||
| 117 | c2l(in,tin0); tin[0]=tin0; | ||
| 118 | c2l(in,tin1); tin[1]=tin1; | ||
| 119 | DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); | ||
| 120 | tout0=tin[0]^xor0; | ||
| 121 | tout1=tin[1]^xor1; | ||
| 122 | l2c(tout0,out); | ||
| 123 | l2c(tout1,out); | ||
| 124 | xor0=tin0; | ||
| 125 | xor1=tin1; | ||
| 126 | } | ||
| 127 | if (l != -8) | ||
| 128 | { | ||
| 129 | c2l(in,tin0); tin[0]=tin0; | ||
| 130 | c2l(in,tin1); tin[1]=tin1; | ||
| 131 | DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); | ||
| 132 | tout0=tin[0]^xor0; | ||
| 133 | tout1=tin[1]^xor1; | ||
| 134 | l2cn(tout0,tout1,out,l+8); | ||
| 135 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
| 136 | xor0=tin0; | ||
| 137 | xor1=tin1; | ||
| 138 | #endif | ||
| 139 | } | ||
| 140 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
| 141 | iv = &(*ivec)[0]; | ||
| 142 | l2c(xor0,iv); | ||
| 143 | l2c(xor1,iv); | ||
| 144 | #endif | ||
| 145 | } | ||
| 146 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
| 147 | tin[0]=tin[1]=0; | ||
| 148 | } | ||
diff --git a/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c deleted file mode 100644 index 26bbf9a6a7..0000000000 --- a/src/lib/libcrypto/des/ofb64ede.c +++ /dev/null | |||
| @@ -1,125 +0,0 @@ | |||
| 1 | /* crypto/des/ofb64ede.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output encrypted as though 64bit ofb mode is being | ||
| 62 | * used. The extra state information to record how much of the | ||
| 63 | * 64bit block we have used is contained in *num; | ||
| 64 | */ | ||
| 65 | void DES_ede3_ofb64_encrypt(register const unsigned char *in, | ||
| 66 | register unsigned char *out, long length, | ||
| 67 | DES_key_schedule *k1, DES_key_schedule *k2, | ||
| 68 | DES_key_schedule *k3, DES_cblock *ivec, | ||
| 69 | int *num) | ||
| 70 | { | ||
| 71 | register DES_LONG v0,v1; | ||
| 72 | register int n= *num; | ||
| 73 | register long l=length; | ||
| 74 | DES_cblock d; | ||
| 75 | register char *dp; | ||
| 76 | DES_LONG ti[2]; | ||
| 77 | unsigned char *iv; | ||
| 78 | int save=0; | ||
| 79 | |||
| 80 | iv = &(*ivec)[0]; | ||
| 81 | c2l(iv,v0); | ||
| 82 | c2l(iv,v1); | ||
| 83 | ti[0]=v0; | ||
| 84 | ti[1]=v1; | ||
| 85 | dp=(char *)d; | ||
| 86 | l2c(v0,dp); | ||
| 87 | l2c(v1,dp); | ||
| 88 | while (l--) | ||
| 89 | { | ||
| 90 | if (n == 0) | ||
| 91 | { | ||
| 92 | /* ti[0]=v0; */ | ||
| 93 | /* ti[1]=v1; */ | ||
| 94 | DES_encrypt3(ti,k1,k2,k3); | ||
| 95 | v0=ti[0]; | ||
| 96 | v1=ti[1]; | ||
| 97 | |||
| 98 | dp=(char *)d; | ||
| 99 | l2c(v0,dp); | ||
| 100 | l2c(v1,dp); | ||
| 101 | save++; | ||
| 102 | } | ||
| 103 | *(out++)= *(in++)^d[n]; | ||
| 104 | n=(n+1)&0x07; | ||
| 105 | } | ||
| 106 | if (save) | ||
| 107 | { | ||
| 108 | /* v0=ti[0]; | ||
| 109 | v1=ti[1];*/ | ||
| 110 | iv = &(*ivec)[0]; | ||
| 111 | l2c(v0,iv); | ||
| 112 | l2c(v1,iv); | ||
| 113 | } | ||
| 114 | v0=v1=ti[0]=ti[1]=0; | ||
| 115 | *num=n; | ||
| 116 | } | ||
| 117 | |||
| 118 | #ifdef undef /* MACRO */ | ||
| 119 | void DES_ede2_ofb64_encrypt(register unsigned char *in, | ||
| 120 | register unsigned char *out, long length, DES_key_schedule k1, | ||
| 121 | DES_key_schedule k2, DES_cblock (*ivec), int *num) | ||
| 122 | { | ||
| 123 | DES_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); | ||
| 124 | } | ||
| 125 | #endif | ||
diff --git a/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c deleted file mode 100644 index 8ca3d49dea..0000000000 --- a/src/lib/libcrypto/des/ofb64enc.c +++ /dev/null | |||
| @@ -1,110 +0,0 @@ | |||
| 1 | /* crypto/des/ofb64enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output encrypted as though 64bit ofb mode is being | ||
| 62 | * used. The extra state information to record how much of the | ||
| 63 | * 64bit block we have used is contained in *num; | ||
| 64 | */ | ||
| 65 | void DES_ofb64_encrypt(register const unsigned char *in, | ||
| 66 | register unsigned char *out, long length, | ||
| 67 | DES_key_schedule *schedule, DES_cblock *ivec, int *num) | ||
| 68 | { | ||
| 69 | register DES_LONG v0,v1,t; | ||
| 70 | register int n= *num; | ||
| 71 | register long l=length; | ||
| 72 | DES_cblock d; | ||
| 73 | register unsigned char *dp; | ||
| 74 | DES_LONG ti[2]; | ||
| 75 | unsigned char *iv; | ||
| 76 | int save=0; | ||
| 77 | |||
| 78 | iv = &(*ivec)[0]; | ||
| 79 | c2l(iv,v0); | ||
| 80 | c2l(iv,v1); | ||
| 81 | ti[0]=v0; | ||
| 82 | ti[1]=v1; | ||
| 83 | dp=d; | ||
| 84 | l2c(v0,dp); | ||
| 85 | l2c(v1,dp); | ||
| 86 | while (l--) | ||
| 87 | { | ||
| 88 | if (n == 0) | ||
| 89 | { | ||
| 90 | DES_encrypt1(ti,schedule,DES_ENCRYPT); | ||
| 91 | dp=d; | ||
| 92 | t=ti[0]; l2c(t,dp); | ||
| 93 | t=ti[1]; l2c(t,dp); | ||
| 94 | save++; | ||
| 95 | } | ||
| 96 | *(out++)= *(in++)^d[n]; | ||
| 97 | n=(n+1)&0x07; | ||
| 98 | } | ||
| 99 | if (save) | ||
| 100 | { | ||
| 101 | v0=ti[0]; | ||
| 102 | v1=ti[1]; | ||
| 103 | iv = &(*ivec)[0]; | ||
| 104 | l2c(v0,iv); | ||
| 105 | l2c(v1,iv); | ||
| 106 | } | ||
| 107 | t=v0=v1=ti[0]=ti[1]=0; | ||
| 108 | *num=n; | ||
| 109 | } | ||
| 110 | |||
diff --git a/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c deleted file mode 100644 index e887a3c6f4..0000000000 --- a/src/lib/libcrypto/des/ofb_enc.c +++ /dev/null | |||
| @@ -1,135 +0,0 @@ | |||
| 1 | /* crypto/des/ofb_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* The input and output are loaded in multiples of 8 bits. | ||
| 62 | * What this means is that if you hame numbits=12 and length=2 | ||
| 63 | * the first 12 bits will be retrieved from the first byte and half | ||
| 64 | * the second. The second 12 bits will come from the 3rd and half the 4th | ||
| 65 | * byte. | ||
| 66 | */ | ||
| 67 | void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | ||
| 68 | long length, DES_key_schedule *schedule, | ||
| 69 | DES_cblock *ivec) | ||
| 70 | { | ||
| 71 | register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; | ||
| 72 | register DES_LONG mask0,mask1; | ||
| 73 | register long l=length; | ||
| 74 | register int num=numbits; | ||
| 75 | DES_LONG ti[2]; | ||
| 76 | unsigned char *iv; | ||
| 77 | |||
| 78 | if (num > 64) return; | ||
| 79 | if (num > 32) | ||
| 80 | { | ||
| 81 | mask0=0xffffffffL; | ||
| 82 | if (num >= 64) | ||
| 83 | mask1=mask0; | ||
| 84 | else | ||
| 85 | mask1=(1L<<(num-32))-1; | ||
| 86 | } | ||
| 87 | else | ||
| 88 | { | ||
| 89 | if (num == 32) | ||
| 90 | mask0=0xffffffffL; | ||
| 91 | else | ||
| 92 | mask0=(1L<<num)-1; | ||
| 93 | mask1=0x00000000L; | ||
| 94 | } | ||
| 95 | |||
| 96 | iv = &(*ivec)[0]; | ||
| 97 | c2l(iv,v0); | ||
| 98 | c2l(iv,v1); | ||
| 99 | ti[0]=v0; | ||
| 100 | ti[1]=v1; | ||
| 101 | while (l-- > 0) | ||
| 102 | { | ||
| 103 | ti[0]=v0; | ||
| 104 | ti[1]=v1; | ||
| 105 | DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
| 106 | vv0=ti[0]; | ||
| 107 | vv1=ti[1]; | ||
| 108 | c2ln(in,d0,d1,n); | ||
| 109 | in+=n; | ||
| 110 | d0=(d0^vv0)&mask0; | ||
| 111 | d1=(d1^vv1)&mask1; | ||
| 112 | l2cn(d0,d1,out,n); | ||
| 113 | out+=n; | ||
| 114 | |||
| 115 | if (num == 32) | ||
| 116 | { v0=v1; v1=vv0; } | ||
| 117 | else if (num == 64) | ||
| 118 | { v0=vv0; v1=vv1; } | ||
| 119 | else if (num > 32) /* && num != 64 */ | ||
| 120 | { | ||
| 121 | v0=((v1>>(num-32))|(vv0<<(64-num)))&0xffffffffL; | ||
| 122 | v1=((vv0>>(num-32))|(vv1<<(64-num)))&0xffffffffL; | ||
| 123 | } | ||
| 124 | else /* num < 32 */ | ||
| 125 | { | ||
| 126 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
| 127 | v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | iv = &(*ivec)[0]; | ||
| 131 | l2c(v0,iv); | ||
| 132 | l2c(v1,iv); | ||
| 133 | v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0; | ||
| 134 | } | ||
| 135 | |||
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c deleted file mode 100644 index 17a40f9520..0000000000 --- a/src/lib/libcrypto/des/pcbc_enc.c +++ /dev/null | |||
| @@ -1,123 +0,0 @@ | |||
| 1 | /* crypto/des/pcbc_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, | ||
| 62 | long length, DES_key_schedule *schedule, | ||
| 63 | DES_cblock *ivec, int enc) | ||
| 64 | { | ||
| 65 | register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; | ||
| 66 | DES_LONG tin[2]; | ||
| 67 | const unsigned char *in; | ||
| 68 | unsigned char *out,*iv; | ||
| 69 | |||
| 70 | in=input; | ||
| 71 | out=output; | ||
| 72 | iv = &(*ivec)[0]; | ||
| 73 | |||
| 74 | if (enc) | ||
| 75 | { | ||
| 76 | c2l(iv,xor0); | ||
| 77 | c2l(iv,xor1); | ||
| 78 | for (; length>0; length-=8) | ||
| 79 | { | ||
| 80 | if (length >= 8) | ||
| 81 | { | ||
| 82 | c2l(in,sin0); | ||
| 83 | c2l(in,sin1); | ||
| 84 | } | ||
| 85 | else | ||
| 86 | c2ln(in,sin0,sin1,length); | ||
| 87 | tin[0]=sin0^xor0; | ||
| 88 | tin[1]=sin1^xor1; | ||
| 89 | DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
| 90 | tout0=tin[0]; | ||
| 91 | tout1=tin[1]; | ||
| 92 | xor0=sin0^tout0; | ||
| 93 | xor1=sin1^tout1; | ||
| 94 | l2c(tout0,out); | ||
| 95 | l2c(tout1,out); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | else | ||
| 99 | { | ||
| 100 | c2l(iv,xor0); c2l(iv,xor1); | ||
| 101 | for (; length>0; length-=8) | ||
| 102 | { | ||
| 103 | c2l(in,sin0); | ||
| 104 | c2l(in,sin1); | ||
| 105 | tin[0]=sin0; | ||
| 106 | tin[1]=sin1; | ||
| 107 | DES_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); | ||
| 108 | tout0=tin[0]^xor0; | ||
| 109 | tout1=tin[1]^xor1; | ||
| 110 | if (length >= 8) | ||
| 111 | { | ||
| 112 | l2c(tout0,out); | ||
| 113 | l2c(tout1,out); | ||
| 114 | } | ||
| 115 | else | ||
| 116 | l2cn(tout0,tout1,out,length); | ||
| 117 | xor0=tout0^sin0; | ||
| 118 | xor1=tout1^sin1; | ||
| 119 | } | ||
| 120 | } | ||
| 121 | tin[0]=tin[1]=0; | ||
| 122 | sin0=sin1=xor0=xor1=tout0=tout1=0; | ||
| 123 | } | ||
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c deleted file mode 100644 index dac201227e..0000000000 --- a/src/lib/libcrypto/des/qud_cksm.c +++ /dev/null | |||
| @@ -1,139 +0,0 @@ | |||
| 1 | /* crypto/des/qud_cksm.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | /* From "Message Authentication" R.R. Jueneman, S.M. Matyas, C.H. Meyer | ||
| 60 | * IEEE Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40 | ||
| 61 | * This module in only based on the code in this paper and is | ||
| 62 | * almost definitely not the same as the MIT implementation. | ||
| 63 | */ | ||
| 64 | #include "des_locl.h" | ||
| 65 | |||
| 66 | /* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */ | ||
| 67 | #define Q_B0(a) (((DES_LONG)(a))) | ||
| 68 | #define Q_B1(a) (((DES_LONG)(a))<<8) | ||
| 69 | #define Q_B2(a) (((DES_LONG)(a))<<16) | ||
| 70 | #define Q_B3(a) (((DES_LONG)(a))<<24) | ||
| 71 | |||
| 72 | /* used to scramble things a bit */ | ||
| 73 | /* Got the value MIT uses via brute force :-) 2/10/90 eay */ | ||
| 74 | #define NOISE ((DES_LONG)83653421L) | ||
| 75 | |||
| 76 | DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], | ||
| 77 | long length, int out_count, DES_cblock *seed) | ||
| 78 | { | ||
| 79 | DES_LONG z0,z1,t0,t1; | ||
| 80 | int i; | ||
| 81 | long l; | ||
| 82 | const unsigned char *cp; | ||
| 83 | #ifdef _CRAY | ||
| 84 | struct lp_st { int a:32; int b:32; } *lp; | ||
| 85 | #else | ||
| 86 | DES_LONG *lp; | ||
| 87 | #endif | ||
| 88 | |||
| 89 | if (out_count < 1) out_count=1; | ||
| 90 | #ifdef _CRAY | ||
| 91 | lp = (struct lp_st *) &(output[0])[0]; | ||
| 92 | #else | ||
| 93 | lp = (DES_LONG *) &(output[0])[0]; | ||
| 94 | #endif | ||
| 95 | |||
| 96 | z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); | ||
| 97 | z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); | ||
| 98 | |||
| 99 | for (i=0; ((i<4)&&(i<out_count)); i++) | ||
| 100 | { | ||
| 101 | cp=input; | ||
| 102 | l=length; | ||
| 103 | while (l > 0) | ||
| 104 | { | ||
| 105 | if (l > 1) | ||
| 106 | { | ||
| 107 | t0= (DES_LONG)(*(cp++)); | ||
| 108 | t0|=(DES_LONG)Q_B1(*(cp++)); | ||
| 109 | l--; | ||
| 110 | } | ||
| 111 | else | ||
| 112 | t0= (DES_LONG)(*(cp++)); | ||
| 113 | l--; | ||
| 114 | /* add */ | ||
| 115 | t0+=z0; | ||
| 116 | t0&=0xffffffffL; | ||
| 117 | t1=z1; | ||
| 118 | /* square, well sort of square */ | ||
| 119 | z0=((((t0*t0)&0xffffffffL)+((t1*t1)&0xffffffffL)) | ||
| 120 | &0xffffffffL)%0x7fffffffL; | ||
| 121 | z1=((t0*((t1+NOISE)&0xffffffffL))&0xffffffffL)%0x7fffffffL; | ||
| 122 | } | ||
| 123 | if (lp != NULL) | ||
| 124 | { | ||
| 125 | /* The MIT library assumes that the checksum is | ||
| 126 | * composed of 2*out_count 32 bit ints */ | ||
| 127 | #ifdef _CRAY | ||
| 128 | (*lp).a = z0; | ||
| 129 | (*lp).b = z1; | ||
| 130 | lp++; | ||
| 131 | #else | ||
| 132 | *lp++ = z0; | ||
| 133 | *lp++ = z1; | ||
| 134 | #endif | ||
| 135 | } | ||
| 136 | } | ||
| 137 | return(z0); | ||
| 138 | } | ||
| 139 | |||
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c deleted file mode 100644 index 2398165568..0000000000 --- a/src/lib/libcrypto/des/rand_key.c +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 1 | /* crypto/des/rand_key.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@openssl.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | #include <openssl/des.h> | ||
| 57 | #include <openssl/rand.h> | ||
| 58 | |||
| 59 | int DES_random_key(DES_cblock *ret) | ||
| 60 | { | ||
| 61 | do | ||
| 62 | { | ||
| 63 | if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1) | ||
| 64 | return (0); | ||
| 65 | } while (DES_is_weak_key(ret)); | ||
| 66 | DES_set_odd_parity(ret); | ||
| 67 | return (1); | ||
| 68 | } | ||
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c deleted file mode 100644 index 143008ed9c..0000000000 --- a/src/lib/libcrypto/des/set_key.c +++ /dev/null | |||
| @@ -1,407 +0,0 @@ | |||
| 1 | /* crypto/des/set_key.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | /* set_key.c v 1.4 eay 24/9/91 | ||
| 60 | * 1.4 Speed up by 400% :-) | ||
| 61 | * 1.3 added register declarations. | ||
| 62 | * 1.2 unrolled make_key_sched a bit more | ||
| 63 | * 1.1 added norm_expand_bits | ||
| 64 | * 1.0 First working version | ||
| 65 | */ | ||
| 66 | #include "des_locl.h" | ||
| 67 | |||
| 68 | OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ | ||
| 69 | |||
| 70 | static const unsigned char odd_parity[256]={ | ||
| 71 | 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, | ||
| 72 | 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, | ||
| 73 | 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, | ||
| 74 | 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, | ||
| 75 | 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, | ||
| 76 | 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, | ||
| 77 | 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, | ||
| 78 | 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, | ||
| 79 | 128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, | ||
| 80 | 145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, | ||
| 81 | 161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, | ||
| 82 | 176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, | ||
| 83 | 193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, | ||
| 84 | 208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, | ||
| 85 | 224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, | ||
| 86 | 241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; | ||
| 87 | |||
| 88 | void DES_set_odd_parity(DES_cblock *key) | ||
| 89 | { | ||
| 90 | int i; | ||
| 91 | |||
| 92 | for (i=0; i<DES_KEY_SZ; i++) | ||
| 93 | (*key)[i]=odd_parity[(*key)[i]]; | ||
| 94 | } | ||
| 95 | |||
| 96 | int DES_check_key_parity(const_DES_cblock *key) | ||
| 97 | { | ||
| 98 | int i; | ||
| 99 | |||
| 100 | for (i=0; i<DES_KEY_SZ; i++) | ||
| 101 | { | ||
| 102 | if ((*key)[i] != odd_parity[(*key)[i]]) | ||
| 103 | return(0); | ||
| 104 | } | ||
| 105 | return(1); | ||
| 106 | } | ||
| 107 | |||
| 108 | /* Weak and semi week keys as take from | ||
| 109 | * %A D.W. Davies | ||
| 110 | * %A W.L. Price | ||
| 111 | * %T Security for Computer Networks | ||
| 112 | * %I John Wiley & Sons | ||
| 113 | * %D 1984 | ||
| 114 | * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference | ||
| 115 | * (and actual cblock values). | ||
| 116 | */ | ||
| 117 | #define NUM_WEAK_KEY 16 | ||
| 118 | static DES_cblock weak_keys[NUM_WEAK_KEY]={ | ||
| 119 | /* weak keys */ | ||
| 120 | {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, | ||
| 121 | {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, | ||
| 122 | {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, | ||
| 123 | {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1}, | ||
| 124 | /* semi-weak keys */ | ||
| 125 | {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE}, | ||
| 126 | {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01}, | ||
| 127 | {0x1F,0xE0,0x1F,0xE0,0x0E,0xF1,0x0E,0xF1}, | ||
| 128 | {0xE0,0x1F,0xE0,0x1F,0xF1,0x0E,0xF1,0x0E}, | ||
| 129 | {0x01,0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1}, | ||
| 130 | {0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1,0x01}, | ||
| 131 | {0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E,0xFE}, | ||
| 132 | {0xFE,0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E}, | ||
| 133 | {0x01,0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E}, | ||
| 134 | {0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E,0x01}, | ||
| 135 | {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, | ||
| 136 | {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; | ||
| 137 | |||
| 138 | int DES_is_weak_key(const_DES_cblock *key) | ||
| 139 | { | ||
| 140 | int i; | ||
| 141 | |||
| 142 | for (i=0; i<NUM_WEAK_KEY; i++) | ||
| 143 | /* Added == 0 to comparison, I obviously don't run | ||
| 144 | * this section very often :-(, thanks to | ||
| 145 | * engineering@MorningStar.Com for the fix | ||
| 146 | * eay 93/06/29 | ||
| 147 | * Another problem, I was comparing only the first 4 | ||
| 148 | * bytes, 97/03/18 */ | ||
| 149 | if (memcmp(weak_keys[i],key,sizeof(DES_cblock)) == 0) return(1); | ||
| 150 | return(0); | ||
| 151 | } | ||
| 152 | |||
| 153 | /* NOW DEFINED IN des_local.h | ||
| 154 | * See ecb_encrypt.c for a pseudo description of these macros. | ||
| 155 | * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
| 156 | * (b)^=(t),\ | ||
| 157 | * (a)=((a)^((t)<<(n)))) | ||
| 158 | */ | ||
| 159 | |||
| 160 | #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ | ||
| 161 | (a)=(a)^(t)^(t>>(16-(n)))) | ||
| 162 | |||
| 163 | static const DES_LONG des_skb[8][64]={ | ||
| 164 | { | ||
| 165 | /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | ||
| 166 | 0x00000000L,0x00000010L,0x20000000L,0x20000010L, | ||
| 167 | 0x00010000L,0x00010010L,0x20010000L,0x20010010L, | ||
| 168 | 0x00000800L,0x00000810L,0x20000800L,0x20000810L, | ||
| 169 | 0x00010800L,0x00010810L,0x20010800L,0x20010810L, | ||
| 170 | 0x00000020L,0x00000030L,0x20000020L,0x20000030L, | ||
| 171 | 0x00010020L,0x00010030L,0x20010020L,0x20010030L, | ||
| 172 | 0x00000820L,0x00000830L,0x20000820L,0x20000830L, | ||
| 173 | 0x00010820L,0x00010830L,0x20010820L,0x20010830L, | ||
| 174 | 0x00080000L,0x00080010L,0x20080000L,0x20080010L, | ||
| 175 | 0x00090000L,0x00090010L,0x20090000L,0x20090010L, | ||
| 176 | 0x00080800L,0x00080810L,0x20080800L,0x20080810L, | ||
| 177 | 0x00090800L,0x00090810L,0x20090800L,0x20090810L, | ||
| 178 | 0x00080020L,0x00080030L,0x20080020L,0x20080030L, | ||
| 179 | 0x00090020L,0x00090030L,0x20090020L,0x20090030L, | ||
| 180 | 0x00080820L,0x00080830L,0x20080820L,0x20080830L, | ||
| 181 | 0x00090820L,0x00090830L,0x20090820L,0x20090830L, | ||
| 182 | },{ | ||
| 183 | /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ | ||
| 184 | 0x00000000L,0x02000000L,0x00002000L,0x02002000L, | ||
| 185 | 0x00200000L,0x02200000L,0x00202000L,0x02202000L, | ||
| 186 | 0x00000004L,0x02000004L,0x00002004L,0x02002004L, | ||
| 187 | 0x00200004L,0x02200004L,0x00202004L,0x02202004L, | ||
| 188 | 0x00000400L,0x02000400L,0x00002400L,0x02002400L, | ||
| 189 | 0x00200400L,0x02200400L,0x00202400L,0x02202400L, | ||
| 190 | 0x00000404L,0x02000404L,0x00002404L,0x02002404L, | ||
| 191 | 0x00200404L,0x02200404L,0x00202404L,0x02202404L, | ||
| 192 | 0x10000000L,0x12000000L,0x10002000L,0x12002000L, | ||
| 193 | 0x10200000L,0x12200000L,0x10202000L,0x12202000L, | ||
| 194 | 0x10000004L,0x12000004L,0x10002004L,0x12002004L, | ||
| 195 | 0x10200004L,0x12200004L,0x10202004L,0x12202004L, | ||
| 196 | 0x10000400L,0x12000400L,0x10002400L,0x12002400L, | ||
| 197 | 0x10200400L,0x12200400L,0x10202400L,0x12202400L, | ||
| 198 | 0x10000404L,0x12000404L,0x10002404L,0x12002404L, | ||
| 199 | 0x10200404L,0x12200404L,0x10202404L,0x12202404L, | ||
| 200 | },{ | ||
| 201 | /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ | ||
| 202 | 0x00000000L,0x00000001L,0x00040000L,0x00040001L, | ||
| 203 | 0x01000000L,0x01000001L,0x01040000L,0x01040001L, | ||
| 204 | 0x00000002L,0x00000003L,0x00040002L,0x00040003L, | ||
| 205 | 0x01000002L,0x01000003L,0x01040002L,0x01040003L, | ||
| 206 | 0x00000200L,0x00000201L,0x00040200L,0x00040201L, | ||
| 207 | 0x01000200L,0x01000201L,0x01040200L,0x01040201L, | ||
| 208 | 0x00000202L,0x00000203L,0x00040202L,0x00040203L, | ||
| 209 | 0x01000202L,0x01000203L,0x01040202L,0x01040203L, | ||
| 210 | 0x08000000L,0x08000001L,0x08040000L,0x08040001L, | ||
| 211 | 0x09000000L,0x09000001L,0x09040000L,0x09040001L, | ||
| 212 | 0x08000002L,0x08000003L,0x08040002L,0x08040003L, | ||
| 213 | 0x09000002L,0x09000003L,0x09040002L,0x09040003L, | ||
| 214 | 0x08000200L,0x08000201L,0x08040200L,0x08040201L, | ||
| 215 | 0x09000200L,0x09000201L,0x09040200L,0x09040201L, | ||
| 216 | 0x08000202L,0x08000203L,0x08040202L,0x08040203L, | ||
| 217 | 0x09000202L,0x09000203L,0x09040202L,0x09040203L, | ||
| 218 | },{ | ||
| 219 | /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ | ||
| 220 | 0x00000000L,0x00100000L,0x00000100L,0x00100100L, | ||
| 221 | 0x00000008L,0x00100008L,0x00000108L,0x00100108L, | ||
| 222 | 0x00001000L,0x00101000L,0x00001100L,0x00101100L, | ||
| 223 | 0x00001008L,0x00101008L,0x00001108L,0x00101108L, | ||
| 224 | 0x04000000L,0x04100000L,0x04000100L,0x04100100L, | ||
| 225 | 0x04000008L,0x04100008L,0x04000108L,0x04100108L, | ||
| 226 | 0x04001000L,0x04101000L,0x04001100L,0x04101100L, | ||
| 227 | 0x04001008L,0x04101008L,0x04001108L,0x04101108L, | ||
| 228 | 0x00020000L,0x00120000L,0x00020100L,0x00120100L, | ||
| 229 | 0x00020008L,0x00120008L,0x00020108L,0x00120108L, | ||
| 230 | 0x00021000L,0x00121000L,0x00021100L,0x00121100L, | ||
| 231 | 0x00021008L,0x00121008L,0x00021108L,0x00121108L, | ||
| 232 | 0x04020000L,0x04120000L,0x04020100L,0x04120100L, | ||
| 233 | 0x04020008L,0x04120008L,0x04020108L,0x04120108L, | ||
| 234 | 0x04021000L,0x04121000L,0x04021100L,0x04121100L, | ||
| 235 | 0x04021008L,0x04121008L,0x04021108L,0x04121108L, | ||
| 236 | },{ | ||
| 237 | /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | ||
| 238 | 0x00000000L,0x10000000L,0x00010000L,0x10010000L, | ||
| 239 | 0x00000004L,0x10000004L,0x00010004L,0x10010004L, | ||
| 240 | 0x20000000L,0x30000000L,0x20010000L,0x30010000L, | ||
| 241 | 0x20000004L,0x30000004L,0x20010004L,0x30010004L, | ||
| 242 | 0x00100000L,0x10100000L,0x00110000L,0x10110000L, | ||
| 243 | 0x00100004L,0x10100004L,0x00110004L,0x10110004L, | ||
| 244 | 0x20100000L,0x30100000L,0x20110000L,0x30110000L, | ||
| 245 | 0x20100004L,0x30100004L,0x20110004L,0x30110004L, | ||
| 246 | 0x00001000L,0x10001000L,0x00011000L,0x10011000L, | ||
| 247 | 0x00001004L,0x10001004L,0x00011004L,0x10011004L, | ||
| 248 | 0x20001000L,0x30001000L,0x20011000L,0x30011000L, | ||
| 249 | 0x20001004L,0x30001004L,0x20011004L,0x30011004L, | ||
| 250 | 0x00101000L,0x10101000L,0x00111000L,0x10111000L, | ||
| 251 | 0x00101004L,0x10101004L,0x00111004L,0x10111004L, | ||
| 252 | 0x20101000L,0x30101000L,0x20111000L,0x30111000L, | ||
| 253 | 0x20101004L,0x30101004L,0x20111004L,0x30111004L, | ||
| 254 | },{ | ||
| 255 | /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ | ||
| 256 | 0x00000000L,0x08000000L,0x00000008L,0x08000008L, | ||
| 257 | 0x00000400L,0x08000400L,0x00000408L,0x08000408L, | ||
| 258 | 0x00020000L,0x08020000L,0x00020008L,0x08020008L, | ||
| 259 | 0x00020400L,0x08020400L,0x00020408L,0x08020408L, | ||
| 260 | 0x00000001L,0x08000001L,0x00000009L,0x08000009L, | ||
| 261 | 0x00000401L,0x08000401L,0x00000409L,0x08000409L, | ||
| 262 | 0x00020001L,0x08020001L,0x00020009L,0x08020009L, | ||
| 263 | 0x00020401L,0x08020401L,0x00020409L,0x08020409L, | ||
| 264 | 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, | ||
| 265 | 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, | ||
| 266 | 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, | ||
| 267 | 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, | ||
| 268 | 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, | ||
| 269 | 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, | ||
| 270 | 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, | ||
| 271 | 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, | ||
| 272 | },{ | ||
| 273 | /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ | ||
| 274 | 0x00000000L,0x00000100L,0x00080000L,0x00080100L, | ||
| 275 | 0x01000000L,0x01000100L,0x01080000L,0x01080100L, | ||
| 276 | 0x00000010L,0x00000110L,0x00080010L,0x00080110L, | ||
| 277 | 0x01000010L,0x01000110L,0x01080010L,0x01080110L, | ||
| 278 | 0x00200000L,0x00200100L,0x00280000L,0x00280100L, | ||
| 279 | 0x01200000L,0x01200100L,0x01280000L,0x01280100L, | ||
| 280 | 0x00200010L,0x00200110L,0x00280010L,0x00280110L, | ||
| 281 | 0x01200010L,0x01200110L,0x01280010L,0x01280110L, | ||
| 282 | 0x00000200L,0x00000300L,0x00080200L,0x00080300L, | ||
| 283 | 0x01000200L,0x01000300L,0x01080200L,0x01080300L, | ||
| 284 | 0x00000210L,0x00000310L,0x00080210L,0x00080310L, | ||
| 285 | 0x01000210L,0x01000310L,0x01080210L,0x01080310L, | ||
| 286 | 0x00200200L,0x00200300L,0x00280200L,0x00280300L, | ||
| 287 | 0x01200200L,0x01200300L,0x01280200L,0x01280300L, | ||
| 288 | 0x00200210L,0x00200310L,0x00280210L,0x00280310L, | ||
| 289 | 0x01200210L,0x01200310L,0x01280210L,0x01280310L, | ||
| 290 | },{ | ||
| 291 | /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ | ||
| 292 | 0x00000000L,0x04000000L,0x00040000L,0x04040000L, | ||
| 293 | 0x00000002L,0x04000002L,0x00040002L,0x04040002L, | ||
| 294 | 0x00002000L,0x04002000L,0x00042000L,0x04042000L, | ||
| 295 | 0x00002002L,0x04002002L,0x00042002L,0x04042002L, | ||
| 296 | 0x00000020L,0x04000020L,0x00040020L,0x04040020L, | ||
| 297 | 0x00000022L,0x04000022L,0x00040022L,0x04040022L, | ||
| 298 | 0x00002020L,0x04002020L,0x00042020L,0x04042020L, | ||
| 299 | 0x00002022L,0x04002022L,0x00042022L,0x04042022L, | ||
| 300 | 0x00000800L,0x04000800L,0x00040800L,0x04040800L, | ||
| 301 | 0x00000802L,0x04000802L,0x00040802L,0x04040802L, | ||
| 302 | 0x00002800L,0x04002800L,0x00042800L,0x04042800L, | ||
| 303 | 0x00002802L,0x04002802L,0x00042802L,0x04042802L, | ||
| 304 | 0x00000820L,0x04000820L,0x00040820L,0x04040820L, | ||
| 305 | 0x00000822L,0x04000822L,0x00040822L,0x04040822L, | ||
| 306 | 0x00002820L,0x04002820L,0x00042820L,0x04042820L, | ||
| 307 | 0x00002822L,0x04002822L,0x00042822L,0x04042822L, | ||
| 308 | }}; | ||
| 309 | |||
| 310 | int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) | ||
| 311 | { | ||
| 312 | if (DES_check_key) | ||
| 313 | { | ||
| 314 | return DES_set_key_checked(key, schedule); | ||
| 315 | } | ||
| 316 | else | ||
| 317 | { | ||
| 318 | DES_set_key_unchecked(key, schedule); | ||
| 319 | return 0; | ||
| 320 | } | ||
| 321 | } | ||
| 322 | |||
| 323 | /* return 0 if key parity is odd (correct), | ||
| 324 | * return -1 if key parity error, | ||
| 325 | * return -2 if illegal weak key. | ||
| 326 | */ | ||
| 327 | int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) | ||
| 328 | { | ||
| 329 | if (!DES_check_key_parity(key)) | ||
| 330 | return(-1); | ||
| 331 | if (DES_is_weak_key(key)) | ||
| 332 | return(-2); | ||
| 333 | DES_set_key_unchecked(key, schedule); | ||
| 334 | return 0; | ||
| 335 | } | ||
| 336 | |||
| 337 | void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) | ||
| 338 | { | ||
| 339 | static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; | ||
| 340 | register DES_LONG c,d,t,s,t2; | ||
| 341 | register const unsigned char *in; | ||
| 342 | register DES_LONG *k; | ||
| 343 | register int i; | ||
| 344 | |||
| 345 | #ifdef OPENBSD_DEV_CRYPTO | ||
| 346 | memcpy(schedule->key,key,sizeof schedule->key); | ||
| 347 | schedule->session=NULL; | ||
| 348 | #endif | ||
| 349 | k = &schedule->ks->deslong[0]; | ||
| 350 | in = &(*key)[0]; | ||
| 351 | |||
| 352 | c2l(in,c); | ||
| 353 | c2l(in,d); | ||
| 354 | |||
| 355 | /* do PC1 in 47 simple operations :-) | ||
| 356 | * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) | ||
| 357 | * for the inspiration. :-) */ | ||
| 358 | PERM_OP (d,c,t,4,0x0f0f0f0fL); | ||
| 359 | HPERM_OP(c,t,-2,0xcccc0000L); | ||
| 360 | HPERM_OP(d,t,-2,0xcccc0000L); | ||
| 361 | PERM_OP (d,c,t,1,0x55555555L); | ||
| 362 | PERM_OP (c,d,t,8,0x00ff00ffL); | ||
| 363 | PERM_OP (d,c,t,1,0x55555555L); | ||
| 364 | d= (((d&0x000000ffL)<<16L)| (d&0x0000ff00L) | | ||
| 365 | ((d&0x00ff0000L)>>16L)|((c&0xf0000000L)>>4L)); | ||
| 366 | c&=0x0fffffffL; | ||
| 367 | |||
| 368 | for (i=0; i<ITERATIONS; i++) | ||
| 369 | { | ||
| 370 | if (shifts2[i]) | ||
| 371 | { c=((c>>2L)|(c<<26L)); d=((d>>2L)|(d<<26L)); } | ||
| 372 | else | ||
| 373 | { c=((c>>1L)|(c<<27L)); d=((d>>1L)|(d<<27L)); } | ||
| 374 | c&=0x0fffffffL; | ||
| 375 | d&=0x0fffffffL; | ||
| 376 | /* could be a few less shifts but I am to lazy at this | ||
| 377 | * point in time to investigate */ | ||
| 378 | s= des_skb[0][ (c )&0x3f ]| | ||
| 379 | des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]| | ||
| 380 | des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]| | ||
| 381 | des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) | | ||
| 382 | ((c>>22L)&0x38)]; | ||
| 383 | t= des_skb[4][ (d )&0x3f ]| | ||
| 384 | des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| | ||
| 385 | des_skb[6][ (d>>15L)&0x3f ]| | ||
| 386 | des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; | ||
| 387 | |||
| 388 | /* table contained 0213 4657 */ | ||
| 389 | t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; | ||
| 390 | *(k++)=ROTATE(t2,30)&0xffffffffL; | ||
| 391 | |||
| 392 | t2=((s>>16L)|(t&0xffff0000L)); | ||
| 393 | *(k++)=ROTATE(t2,26)&0xffffffffL; | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule) | ||
| 398 | { | ||
| 399 | return(DES_set_key(key,schedule)); | ||
| 400 | } | ||
| 401 | /* | ||
| 402 | #undef des_fixup_key_parity | ||
| 403 | void des_fixup_key_parity(des_cblock *key) | ||
| 404 | { | ||
| 405 | des_set_odd_parity(key); | ||
| 406 | } | ||
| 407 | */ | ||
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h deleted file mode 100644 index b91936a5a5..0000000000 --- a/src/lib/libcrypto/des/spr.h +++ /dev/null | |||
| @@ -1,204 +0,0 @@ | |||
| 1 | /* crypto/des/spr.h */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64]={ | ||
| 60 | { | ||
| 61 | /* nibble 0 */ | ||
| 62 | 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, | ||
| 63 | 0x02000000L, 0x00080802L, 0x00080002L, 0x02000002L, | ||
| 64 | 0x00080802L, 0x02080800L, 0x02080000L, 0x00000802L, | ||
| 65 | 0x02000802L, 0x02000000L, 0x00000000L, 0x00080002L, | ||
| 66 | 0x00080000L, 0x00000002L, 0x02000800L, 0x00080800L, | ||
| 67 | 0x02080802L, 0x02080000L, 0x00000802L, 0x02000800L, | ||
| 68 | 0x00000002L, 0x00000800L, 0x00080800L, 0x02080002L, | ||
| 69 | 0x00000800L, 0x02000802L, 0x02080002L, 0x00000000L, | ||
| 70 | 0x00000000L, 0x02080802L, 0x02000800L, 0x00080002L, | ||
| 71 | 0x02080800L, 0x00080000L, 0x00000802L, 0x02000800L, | ||
| 72 | 0x02080002L, 0x00000800L, 0x00080800L, 0x02000002L, | ||
| 73 | 0x00080802L, 0x00000002L, 0x02000002L, 0x02080000L, | ||
| 74 | 0x02080802L, 0x00080800L, 0x02080000L, 0x02000802L, | ||
| 75 | 0x02000000L, 0x00000802L, 0x00080002L, 0x00000000L, | ||
| 76 | 0x00080000L, 0x02000000L, 0x02000802L, 0x02080800L, | ||
| 77 | 0x00000002L, 0x02080002L, 0x00000800L, 0x00080802L, | ||
| 78 | },{ | ||
| 79 | /* nibble 1 */ | ||
| 80 | 0x40108010L, 0x00000000L, 0x00108000L, 0x40100000L, | ||
| 81 | 0x40000010L, 0x00008010L, 0x40008000L, 0x00108000L, | ||
| 82 | 0x00008000L, 0x40100010L, 0x00000010L, 0x40008000L, | ||
| 83 | 0x00100010L, 0x40108000L, 0x40100000L, 0x00000010L, | ||
| 84 | 0x00100000L, 0x40008010L, 0x40100010L, 0x00008000L, | ||
| 85 | 0x00108010L, 0x40000000L, 0x00000000L, 0x00100010L, | ||
| 86 | 0x40008010L, 0x00108010L, 0x40108000L, 0x40000010L, | ||
| 87 | 0x40000000L, 0x00100000L, 0x00008010L, 0x40108010L, | ||
| 88 | 0x00100010L, 0x40108000L, 0x40008000L, 0x00108010L, | ||
| 89 | 0x40108010L, 0x00100010L, 0x40000010L, 0x00000000L, | ||
| 90 | 0x40000000L, 0x00008010L, 0x00100000L, 0x40100010L, | ||
| 91 | 0x00008000L, 0x40000000L, 0x00108010L, 0x40008010L, | ||
| 92 | 0x40108000L, 0x00008000L, 0x00000000L, 0x40000010L, | ||
| 93 | 0x00000010L, 0x40108010L, 0x00108000L, 0x40100000L, | ||
| 94 | 0x40100010L, 0x00100000L, 0x00008010L, 0x40008000L, | ||
| 95 | 0x40008010L, 0x00000010L, 0x40100000L, 0x00108000L, | ||
| 96 | },{ | ||
| 97 | /* nibble 2 */ | ||
| 98 | 0x04000001L, 0x04040100L, 0x00000100L, 0x04000101L, | ||
| 99 | 0x00040001L, 0x04000000L, 0x04000101L, 0x00040100L, | ||
| 100 | 0x04000100L, 0x00040000L, 0x04040000L, 0x00000001L, | ||
| 101 | 0x04040101L, 0x00000101L, 0x00000001L, 0x04040001L, | ||
| 102 | 0x00000000L, 0x00040001L, 0x04040100L, 0x00000100L, | ||
| 103 | 0x00000101L, 0x04040101L, 0x00040000L, 0x04000001L, | ||
| 104 | 0x04040001L, 0x04000100L, 0x00040101L, 0x04040000L, | ||
| 105 | 0x00040100L, 0x00000000L, 0x04000000L, 0x00040101L, | ||
| 106 | 0x04040100L, 0x00000100L, 0x00000001L, 0x00040000L, | ||
| 107 | 0x00000101L, 0x00040001L, 0x04040000L, 0x04000101L, | ||
| 108 | 0x00000000L, 0x04040100L, 0x00040100L, 0x04040001L, | ||
| 109 | 0x00040001L, 0x04000000L, 0x04040101L, 0x00000001L, | ||
| 110 | 0x00040101L, 0x04000001L, 0x04000000L, 0x04040101L, | ||
| 111 | 0x00040000L, 0x04000100L, 0x04000101L, 0x00040100L, | ||
| 112 | 0x04000100L, 0x00000000L, 0x04040001L, 0x00000101L, | ||
| 113 | 0x04000001L, 0x00040101L, 0x00000100L, 0x04040000L, | ||
| 114 | },{ | ||
| 115 | /* nibble 3 */ | ||
| 116 | 0x00401008L, 0x10001000L, 0x00000008L, 0x10401008L, | ||
| 117 | 0x00000000L, 0x10400000L, 0x10001008L, 0x00400008L, | ||
| 118 | 0x10401000L, 0x10000008L, 0x10000000L, 0x00001008L, | ||
| 119 | 0x10000008L, 0x00401008L, 0x00400000L, 0x10000000L, | ||
| 120 | 0x10400008L, 0x00401000L, 0x00001000L, 0x00000008L, | ||
| 121 | 0x00401000L, 0x10001008L, 0x10400000L, 0x00001000L, | ||
| 122 | 0x00001008L, 0x00000000L, 0x00400008L, 0x10401000L, | ||
| 123 | 0x10001000L, 0x10400008L, 0x10401008L, 0x00400000L, | ||
| 124 | 0x10400008L, 0x00001008L, 0x00400000L, 0x10000008L, | ||
| 125 | 0x00401000L, 0x10001000L, 0x00000008L, 0x10400000L, | ||
| 126 | 0x10001008L, 0x00000000L, 0x00001000L, 0x00400008L, | ||
| 127 | 0x00000000L, 0x10400008L, 0x10401000L, 0x00001000L, | ||
| 128 | 0x10000000L, 0x10401008L, 0x00401008L, 0x00400000L, | ||
| 129 | 0x10401008L, 0x00000008L, 0x10001000L, 0x00401008L, | ||
| 130 | 0x00400008L, 0x00401000L, 0x10400000L, 0x10001008L, | ||
| 131 | 0x00001008L, 0x10000000L, 0x10000008L, 0x10401000L, | ||
| 132 | },{ | ||
| 133 | /* nibble 4 */ | ||
| 134 | 0x08000000L, 0x00010000L, 0x00000400L, 0x08010420L, | ||
| 135 | 0x08010020L, 0x08000400L, 0x00010420L, 0x08010000L, | ||
| 136 | 0x00010000L, 0x00000020L, 0x08000020L, 0x00010400L, | ||
| 137 | 0x08000420L, 0x08010020L, 0x08010400L, 0x00000000L, | ||
| 138 | 0x00010400L, 0x08000000L, 0x00010020L, 0x00000420L, | ||
| 139 | 0x08000400L, 0x00010420L, 0x00000000L, 0x08000020L, | ||
| 140 | 0x00000020L, 0x08000420L, 0x08010420L, 0x00010020L, | ||
| 141 | 0x08010000L, 0x00000400L, 0x00000420L, 0x08010400L, | ||
| 142 | 0x08010400L, 0x08000420L, 0x00010020L, 0x08010000L, | ||
| 143 | 0x00010000L, 0x00000020L, 0x08000020L, 0x08000400L, | ||
| 144 | 0x08000000L, 0x00010400L, 0x08010420L, 0x00000000L, | ||
| 145 | 0x00010420L, 0x08000000L, 0x00000400L, 0x00010020L, | ||
| 146 | 0x08000420L, 0x00000400L, 0x00000000L, 0x08010420L, | ||
| 147 | 0x08010020L, 0x08010400L, 0x00000420L, 0x00010000L, | ||
| 148 | 0x00010400L, 0x08010020L, 0x08000400L, 0x00000420L, | ||
| 149 | 0x00000020L, 0x00010420L, 0x08010000L, 0x08000020L, | ||
| 150 | },{ | ||
| 151 | /* nibble 5 */ | ||
| 152 | 0x80000040L, 0x00200040L, 0x00000000L, 0x80202000L, | ||
| 153 | 0x00200040L, 0x00002000L, 0x80002040L, 0x00200000L, | ||
| 154 | 0x00002040L, 0x80202040L, 0x00202000L, 0x80000000L, | ||
| 155 | 0x80002000L, 0x80000040L, 0x80200000L, 0x00202040L, | ||
| 156 | 0x00200000L, 0x80002040L, 0x80200040L, 0x00000000L, | ||
| 157 | 0x00002000L, 0x00000040L, 0x80202000L, 0x80200040L, | ||
| 158 | 0x80202040L, 0x80200000L, 0x80000000L, 0x00002040L, | ||
| 159 | 0x00000040L, 0x00202000L, 0x00202040L, 0x80002000L, | ||
| 160 | 0x00002040L, 0x80000000L, 0x80002000L, 0x00202040L, | ||
| 161 | 0x80202000L, 0x00200040L, 0x00000000L, 0x80002000L, | ||
| 162 | 0x80000000L, 0x00002000L, 0x80200040L, 0x00200000L, | ||
| 163 | 0x00200040L, 0x80202040L, 0x00202000L, 0x00000040L, | ||
| 164 | 0x80202040L, 0x00202000L, 0x00200000L, 0x80002040L, | ||
| 165 | 0x80000040L, 0x80200000L, 0x00202040L, 0x00000000L, | ||
| 166 | 0x00002000L, 0x80000040L, 0x80002040L, 0x80202000L, | ||
| 167 | 0x80200000L, 0x00002040L, 0x00000040L, 0x80200040L, | ||
| 168 | },{ | ||
| 169 | /* nibble 6 */ | ||
| 170 | 0x00004000L, 0x00000200L, 0x01000200L, 0x01000004L, | ||
| 171 | 0x01004204L, 0x00004004L, 0x00004200L, 0x00000000L, | ||
| 172 | 0x01000000L, 0x01000204L, 0x00000204L, 0x01004000L, | ||
| 173 | 0x00000004L, 0x01004200L, 0x01004000L, 0x00000204L, | ||
| 174 | 0x01000204L, 0x00004000L, 0x00004004L, 0x01004204L, | ||
| 175 | 0x00000000L, 0x01000200L, 0x01000004L, 0x00004200L, | ||
| 176 | 0x01004004L, 0x00004204L, 0x01004200L, 0x00000004L, | ||
| 177 | 0x00004204L, 0x01004004L, 0x00000200L, 0x01000000L, | ||
| 178 | 0x00004204L, 0x01004000L, 0x01004004L, 0x00000204L, | ||
| 179 | 0x00004000L, 0x00000200L, 0x01000000L, 0x01004004L, | ||
| 180 | 0x01000204L, 0x00004204L, 0x00004200L, 0x00000000L, | ||
| 181 | 0x00000200L, 0x01000004L, 0x00000004L, 0x01000200L, | ||
| 182 | 0x00000000L, 0x01000204L, 0x01000200L, 0x00004200L, | ||
| 183 | 0x00000204L, 0x00004000L, 0x01004204L, 0x01000000L, | ||
| 184 | 0x01004200L, 0x00000004L, 0x00004004L, 0x01004204L, | ||
| 185 | 0x01000004L, 0x01004200L, 0x01004000L, 0x00004004L, | ||
| 186 | },{ | ||
| 187 | /* nibble 7 */ | ||
| 188 | 0x20800080L, 0x20820000L, 0x00020080L, 0x00000000L, | ||
| 189 | 0x20020000L, 0x00800080L, 0x20800000L, 0x20820080L, | ||
| 190 | 0x00000080L, 0x20000000L, 0x00820000L, 0x00020080L, | ||
| 191 | 0x00820080L, 0x20020080L, 0x20000080L, 0x20800000L, | ||
| 192 | 0x00020000L, 0x00820080L, 0x00800080L, 0x20020000L, | ||
| 193 | 0x20820080L, 0x20000080L, 0x00000000L, 0x00820000L, | ||
| 194 | 0x20000000L, 0x00800000L, 0x20020080L, 0x20800080L, | ||
| 195 | 0x00800000L, 0x00020000L, 0x20820000L, 0x00000080L, | ||
| 196 | 0x00800000L, 0x00020000L, 0x20000080L, 0x20820080L, | ||
| 197 | 0x00020080L, 0x20000000L, 0x00000000L, 0x00820000L, | ||
| 198 | 0x20800080L, 0x20020080L, 0x20020000L, 0x00800080L, | ||
| 199 | 0x20820000L, 0x00000080L, 0x00800080L, 0x20020000L, | ||
| 200 | 0x20820080L, 0x00800000L, 0x20800000L, 0x20000080L, | ||
| 201 | 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, | ||
| 202 | 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, | ||
| 203 | 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, | ||
| 204 | }}; | ||
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c deleted file mode 100644 index 36c3f81d99..0000000000 --- a/src/lib/libcrypto/des/str2key.c +++ /dev/null | |||
| @@ -1,173 +0,0 @@ | |||
| 1 | /* crypto/des/str2key.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | void DES_string_to_key(const char *str, DES_cblock *key) | ||
| 62 | { | ||
| 63 | DES_key_schedule ks; | ||
| 64 | int i,length; | ||
| 65 | register unsigned char j; | ||
| 66 | |||
| 67 | memset(key,0,8); | ||
| 68 | length=strlen(str); | ||
| 69 | #ifdef OLD_STR_TO_KEY | ||
| 70 | for (i=0; i<length; i++) | ||
| 71 | (*key)[i%8]^=(str[i]<<1); | ||
| 72 | #else /* MIT COMPATIBLE */ | ||
| 73 | for (i=0; i<length; i++) | ||
| 74 | { | ||
| 75 | j=str[i]; | ||
| 76 | if ((i%16) < 8) | ||
| 77 | (*key)[i%8]^=(j<<1); | ||
| 78 | else | ||
| 79 | { | ||
| 80 | /* Reverse the bit order 05/05/92 eay */ | ||
| 81 | j=((j<<4)&0xf0)|((j>>4)&0x0f); | ||
| 82 | j=((j<<2)&0xcc)|((j>>2)&0x33); | ||
| 83 | j=((j<<1)&0xaa)|((j>>1)&0x55); | ||
| 84 | (*key)[7-(i%8)]^=j; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | #endif | ||
| 88 | DES_set_odd_parity(key); | ||
| 89 | #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY | ||
| 90 | if(DES_is_weak_key(key)) | ||
| 91 | (*key)[7] ^= 0xF0; | ||
| 92 | DES_set_key(key,&ks); | ||
| 93 | #else | ||
| 94 | DES_set_key_unchecked(key,&ks); | ||
| 95 | #endif | ||
| 96 | DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); | ||
| 97 | memset(&ks,0,sizeof(ks)); | ||
| 98 | DES_set_odd_parity(key); | ||
| 99 | } | ||
| 100 | |||
| 101 | void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) | ||
| 102 | { | ||
| 103 | DES_key_schedule ks; | ||
| 104 | int i,length; | ||
| 105 | register unsigned char j; | ||
| 106 | |||
| 107 | memset(key1,0,8); | ||
| 108 | memset(key2,0,8); | ||
| 109 | length=strlen(str); | ||
| 110 | #ifdef OLD_STR_TO_KEY | ||
| 111 | if (length <= 8) | ||
| 112 | { | ||
| 113 | for (i=0; i<length; i++) | ||
| 114 | { | ||
| 115 | (*key2)[i]=(*key1)[i]=(str[i]<<1); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | else | ||
| 119 | { | ||
| 120 | for (i=0; i<length; i++) | ||
| 121 | { | ||
| 122 | if ((i/8)&1) | ||
| 123 | (*key2)[i%8]^=(str[i]<<1); | ||
| 124 | else | ||
| 125 | (*key1)[i%8]^=(str[i]<<1); | ||
| 126 | } | ||
| 127 | } | ||
| 128 | #else /* MIT COMPATIBLE */ | ||
| 129 | for (i=0; i<length; i++) | ||
| 130 | { | ||
| 131 | j=str[i]; | ||
| 132 | if ((i%32) < 16) | ||
| 133 | { | ||
| 134 | if ((i%16) < 8) | ||
| 135 | (*key1)[i%8]^=(j<<1); | ||
| 136 | else | ||
| 137 | (*key2)[i%8]^=(j<<1); | ||
| 138 | } | ||
| 139 | else | ||
| 140 | { | ||
| 141 | j=((j<<4)&0xf0)|((j>>4)&0x0f); | ||
| 142 | j=((j<<2)&0xcc)|((j>>2)&0x33); | ||
| 143 | j=((j<<1)&0xaa)|((j>>1)&0x55); | ||
| 144 | if ((i%16) < 8) | ||
| 145 | (*key1)[7-(i%8)]^=j; | ||
| 146 | else | ||
| 147 | (*key2)[7-(i%8)]^=j; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | if (length <= 8) memcpy(key2,key1,8); | ||
| 151 | #endif | ||
| 152 | DES_set_odd_parity(key1); | ||
| 153 | DES_set_odd_parity(key2); | ||
| 154 | #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY | ||
| 155 | if(DES_is_weak_key(key1)) | ||
| 156 | (*key1)[7] ^= 0xF0; | ||
| 157 | DES_set_key(key1,&ks); | ||
| 158 | #else | ||
| 159 | DES_set_key_unchecked(key1,&ks); | ||
| 160 | #endif | ||
| 161 | DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1); | ||
| 162 | #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY | ||
| 163 | if(DES_is_weak_key(key2)) | ||
| 164 | (*key2)[7] ^= 0xF0; | ||
| 165 | DES_set_key(key2,&ks); | ||
| 166 | #else | ||
| 167 | DES_set_key_unchecked(key2,&ks); | ||
| 168 | #endif | ||
| 169 | DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); | ||
| 170 | memset(&ks,0,sizeof(ks)); | ||
| 171 | DES_set_odd_parity(key1); | ||
| 172 | DES_set_odd_parity(key2); | ||
| 173 | } | ||
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c deleted file mode 100644 index 47246eb466..0000000000 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ /dev/null | |||
| @@ -1,195 +0,0 @@ | |||
| 1 | /* crypto/des/xcbc_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include "des_locl.h" | ||
| 60 | |||
| 61 | /* RSA's DESX */ | ||
| 62 | |||
| 63 | static unsigned char desx_white_in2out[256]={ | ||
| 64 | 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, | ||
| 65 | 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, | ||
| 66 | 0x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, | ||
| 67 | 0x3E,0xEE,0xFB,0x95,0x1A,0xFE,0xCE,0xA8,0x34,0xA9,0x13,0xF0,0xA6,0x3F,0xD8,0x0C, | ||
| 68 | 0x78,0x24,0xAF,0x23,0x52,0xC1,0x67,0x17,0xF5,0x66,0x90,0xE7,0xE8,0x07,0xB8,0x60, | ||
| 69 | 0x48,0xE6,0x1E,0x53,0xF3,0x92,0xA4,0x72,0x8C,0x08,0x15,0x6E,0x86,0x00,0x84,0xFA, | ||
| 70 | 0xF4,0x7F,0x8A,0x42,0x19,0xF6,0xDB,0xCD,0x14,0x8D,0x50,0x12,0xBA,0x3C,0x06,0x4E, | ||
| 71 | 0xEC,0xB3,0x35,0x11,0xA1,0x88,0x8E,0x2B,0x94,0x99,0xB7,0x71,0x74,0xD3,0xE4,0xBF, | ||
| 72 | 0x3A,0xDE,0x96,0x0E,0xBC,0x0A,0xED,0x77,0xFC,0x37,0x6B,0x03,0x79,0x89,0x62,0xC6, | ||
| 73 | 0xD7,0xC0,0xD2,0x7C,0x6A,0x8B,0x22,0xA3,0x5B,0x05,0x5D,0x02,0x75,0xD5,0x61,0xE3, | ||
| 74 | 0x18,0x8F,0x55,0x51,0xAD,0x1F,0x0B,0x5E,0x85,0xE5,0xC2,0x57,0x63,0xCA,0x3D,0x6C, | ||
| 75 | 0xB4,0xC5,0xCC,0x70,0xB2,0x91,0x59,0x0D,0x47,0x20,0xC8,0x4F,0x58,0xE0,0x01,0xE2, | ||
| 76 | 0x16,0x38,0xC4,0x6F,0x3B,0x0F,0x65,0x46,0xBE,0x7E,0x2D,0x7B,0x82,0xF9,0x40,0xB5, | ||
| 77 | 0x1D,0x73,0xF8,0xEB,0x26,0xC7,0x87,0x97,0x25,0x54,0xB1,0x28,0xAA,0x98,0x9D,0xA5, | ||
| 78 | 0x64,0x6D,0x7A,0xD4,0x10,0x81,0x44,0xEF,0x49,0xD6,0xAE,0x2E,0xDD,0x76,0x5C,0x2F, | ||
| 79 | 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, | ||
| 80 | }; | ||
| 81 | |||
| 82 | void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, | ||
| 83 | DES_cblock *out_white) | ||
| 84 | { | ||
| 85 | int out0,out1; | ||
| 86 | int i; | ||
| 87 | const unsigned char *key = &(*des_key)[0]; | ||
| 88 | const unsigned char *in = &(*in_white)[0]; | ||
| 89 | unsigned char *out = &(*out_white)[0]; | ||
| 90 | |||
| 91 | out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; | ||
| 92 | out0=out1=0; | ||
| 93 | for (i=0; i<8; i++) | ||
| 94 | { | ||
| 95 | out[i]=key[i]^desx_white_in2out[out0^out1]; | ||
| 96 | out0=out1; | ||
| 97 | out1=(int)out[i&0x07]; | ||
| 98 | } | ||
| 99 | |||
| 100 | out0=out[0]; | ||
| 101 | out1=out[i]; | ||
| 102 | for (i=0; i<8; i++) | ||
| 103 | { | ||
| 104 | out[i]=in[i]^desx_white_in2out[out0^out1]; | ||
| 105 | out0=out1; | ||
| 106 | out1=(int)out[i&0x07]; | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, | ||
| 111 | long length, DES_key_schedule *schedule, | ||
| 112 | DES_cblock *ivec, const_DES_cblock *inw, | ||
| 113 | const_DES_cblock *outw, int enc) | ||
| 114 | { | ||
| 115 | register DES_LONG tin0,tin1; | ||
| 116 | register DES_LONG tout0,tout1,xor0,xor1; | ||
| 117 | register DES_LONG inW0,inW1,outW0,outW1; | ||
| 118 | register const unsigned char *in2; | ||
| 119 | register long l=length; | ||
| 120 | DES_LONG tin[2]; | ||
| 121 | unsigned char *iv; | ||
| 122 | |||
| 123 | in2 = &(*inw)[0]; | ||
| 124 | c2l(in2,inW0); | ||
| 125 | c2l(in2,inW1); | ||
| 126 | in2 = &(*outw)[0]; | ||
| 127 | c2l(in2,outW0); | ||
| 128 | c2l(in2,outW1); | ||
| 129 | |||
| 130 | iv = &(*ivec)[0]; | ||
| 131 | |||
| 132 | if (enc) | ||
| 133 | { | ||
| 134 | c2l(iv,tout0); | ||
| 135 | c2l(iv,tout1); | ||
| 136 | for (l-=8; l>=0; l-=8) | ||
| 137 | { | ||
| 138 | c2l(in,tin0); | ||
| 139 | c2l(in,tin1); | ||
| 140 | tin0^=tout0^inW0; tin[0]=tin0; | ||
| 141 | tin1^=tout1^inW1; tin[1]=tin1; | ||
| 142 | DES_encrypt1(tin,schedule,DES_ENCRYPT); | ||
| 143 | tout0=tin[0]^outW0; l2c(tout0,out); | ||
| 144 | tout1=tin[1]^outW1; l2c(tout1,out); | ||
| 145 | } | ||
| 146 | if (l != -8) | ||
| 147 | { | ||
| 148 | c2ln(in,tin0,tin1,l+8); | ||
| 149 | tin0^=tout0^inW0; tin[0]=tin0; | ||
| 150 | tin1^=tout1^inW1; tin[1]=tin1; | ||
| 151 | DES_encrypt1(tin,schedule,DES_ENCRYPT); | ||
| 152 | tout0=tin[0]^outW0; l2c(tout0,out); | ||
| 153 | tout1=tin[1]^outW1; l2c(tout1,out); | ||
| 154 | } | ||
| 155 | iv = &(*ivec)[0]; | ||
| 156 | l2c(tout0,iv); | ||
| 157 | l2c(tout1,iv); | ||
| 158 | } | ||
| 159 | else | ||
| 160 | { | ||
| 161 | c2l(iv,xor0); | ||
| 162 | c2l(iv,xor1); | ||
| 163 | for (l-=8; l>0; l-=8) | ||
| 164 | { | ||
| 165 | c2l(in,tin0); tin[0]=tin0^outW0; | ||
| 166 | c2l(in,tin1); tin[1]=tin1^outW1; | ||
| 167 | DES_encrypt1(tin,schedule,DES_DECRYPT); | ||
| 168 | tout0=tin[0]^xor0^inW0; | ||
| 169 | tout1=tin[1]^xor1^inW1; | ||
| 170 | l2c(tout0,out); | ||
| 171 | l2c(tout1,out); | ||
| 172 | xor0=tin0; | ||
| 173 | xor1=tin1; | ||
| 174 | } | ||
| 175 | if (l != -8) | ||
| 176 | { | ||
| 177 | c2l(in,tin0); tin[0]=tin0^outW0; | ||
| 178 | c2l(in,tin1); tin[1]=tin1^outW1; | ||
| 179 | DES_encrypt1(tin,schedule,DES_DECRYPT); | ||
| 180 | tout0=tin[0]^xor0^inW0; | ||
| 181 | tout1=tin[1]^xor1^inW1; | ||
| 182 | l2cn(tout0,tout1,out,l+8); | ||
| 183 | xor0=tin0; | ||
| 184 | xor1=tin1; | ||
| 185 | } | ||
| 186 | |||
| 187 | iv = &(*ivec)[0]; | ||
| 188 | l2c(xor0,iv); | ||
| 189 | l2c(xor1,iv); | ||
| 190 | } | ||
| 191 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
| 192 | inW0=inW1=outW0=outW1=0; | ||
| 193 | tin[0]=tin[1]=0; | ||
| 194 | } | ||
| 195 | |||
