diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/md5/asm/md5-586.pl | 307 | ||||
| -rw-r--r-- | src/lib/libcrypto/md5/md5.c | 375 | ||||
| -rw-r--r-- | src/lib/libcrypto/md5/md5.h | 99 | ||||
| -rw-r--r-- | src/lib/libcrypto/md5/md5_amd64_generic.S | 237 |
4 files changed, 0 insertions, 1018 deletions
diff --git a/src/lib/libcrypto/md5/asm/md5-586.pl b/src/lib/libcrypto/md5/asm/md5-586.pl deleted file mode 100644 index a039efd899..0000000000 --- a/src/lib/libcrypto/md5/asm/md5-586.pl +++ /dev/null | |||
| @@ -1,307 +0,0 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | # Normal is the | ||
| 4 | # md5_block_x86(MD5_CTX *c, ULONG *X); | ||
| 5 | # version, non-normal is the | ||
| 6 | # md5_block_x86(MD5_CTX *c, ULONG *X,int blocks); | ||
| 7 | |||
| 8 | $normal=0; | ||
| 9 | |||
| 10 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; | ||
| 11 | push(@INC,"${dir}","${dir}../../perlasm"); | ||
| 12 | require "x86asm.pl"; | ||
| 13 | |||
| 14 | &asm_init($ARGV[0],$0); | ||
| 15 | |||
| 16 | $A="eax"; | ||
| 17 | $B="ebx"; | ||
| 18 | $C="ecx"; | ||
| 19 | $D="edx"; | ||
| 20 | $tmp1="edi"; | ||
| 21 | $tmp2="ebp"; | ||
| 22 | $X="esi"; | ||
| 23 | |||
| 24 | # What we need to load into $tmp for the next round | ||
| 25 | %Ltmp1=("R0",&Np($C), "R1",&Np($C), "R2",&Np($C), "R3",&Np($D)); | ||
| 26 | @xo=( | ||
| 27 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, # R0 | ||
| 28 | 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, # R1 | ||
| 29 | 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, # R2 | ||
| 30 | 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, # R3 | ||
| 31 | ); | ||
| 32 | |||
| 33 | &md5_block("md5_block_data_order"); | ||
| 34 | &asm_finish(); | ||
| 35 | |||
| 36 | sub Np | ||
| 37 | { | ||
| 38 | local($p)=@_; | ||
| 39 | local(%n)=($A,$D,$B,$A,$C,$B,$D,$C); | ||
| 40 | return($n{$p}); | ||
| 41 | } | ||
| 42 | |||
| 43 | sub R0 | ||
| 44 | { | ||
| 45 | local($pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_; | ||
| 46 | |||
| 47 | &mov($tmp1,$C) if $pos < 0; | ||
| 48 | &mov($tmp2,&DWP($xo[$ki]*4,$K,"",0)) if $pos < 0; # very first one | ||
| 49 | |||
| 50 | # body proper | ||
| 51 | |||
| 52 | &comment("R0 $ki"); | ||
| 53 | &xor($tmp1,$d); # F function - part 2 | ||
| 54 | |||
| 55 | &and($tmp1,$b); # F function - part 3 | ||
| 56 | &lea($a,&DWP($t,$a,$tmp2,1)); | ||
| 57 | |||
| 58 | &xor($tmp1,$d); # F function - part 4 | ||
| 59 | |||
| 60 | &add($a,$tmp1); | ||
| 61 | &mov($tmp1,&Np($c)) if $pos < 1; # next tmp1 for R0 | ||
| 62 | &mov($tmp1,&Np($c)) if $pos == 1; # next tmp1 for R1 | ||
| 63 | |||
| 64 | &rotl($a,$s); | ||
| 65 | |||
| 66 | &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2); | ||
| 67 | |||
| 68 | &add($a,$b); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub R1 | ||
| 72 | { | ||
| 73 | local($pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_; | ||
| 74 | |||
| 75 | &comment("R1 $ki"); | ||
| 76 | |||
| 77 | &lea($a,&DWP($t,$a,$tmp2,1)); | ||
| 78 | |||
| 79 | &xor($tmp1,$b); # G function - part 2 | ||
| 80 | &and($tmp1,$d); # G function - part 3 | ||
| 81 | |||
| 82 | &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2); | ||
| 83 | &xor($tmp1,$c); # G function - part 4 | ||
| 84 | |||
| 85 | &add($a,$tmp1); | ||
| 86 | &mov($tmp1,&Np($c)) if $pos < 1; # G function - part 1 | ||
| 87 | &mov($tmp1,&Np($c)) if $pos == 1; # G function - part 1 | ||
| 88 | |||
| 89 | &rotl($a,$s); | ||
| 90 | |||
| 91 | &add($a,$b); | ||
| 92 | } | ||
| 93 | |||
| 94 | sub R2 | ||
| 95 | { | ||
| 96 | local($n,$pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_; | ||
| 97 | # This one is different, only 3 logical operations | ||
| 98 | |||
| 99 | if (($n & 1) == 0) | ||
| 100 | { | ||
| 101 | &comment("R2 $ki"); | ||
| 102 | # make sure to do 'D' first, not 'B', else we clash with | ||
| 103 | # the last add from the previous round. | ||
| 104 | |||
| 105 | &xor($tmp1,$d); # H function - part 2 | ||
| 106 | |||
| 107 | &xor($tmp1,$b); # H function - part 3 | ||
| 108 | &lea($a,&DWP($t,$a,$tmp2,1)); | ||
| 109 | |||
| 110 | &add($a,$tmp1); | ||
| 111 | |||
| 112 | &rotl($a,$s); | ||
| 113 | |||
| 114 | &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)); | ||
| 115 | &mov($tmp1,&Np($c)); | ||
| 116 | } | ||
| 117 | else | ||
| 118 | { | ||
| 119 | &comment("R2 $ki"); | ||
| 120 | # make sure to do 'D' first, not 'B', else we clash with | ||
| 121 | # the last add from the previous round. | ||
| 122 | |||
| 123 | &lea($a,&DWP($t,$a,$tmp2,1)); | ||
| 124 | |||
| 125 | &add($b,$c); # MOVED FORWARD | ||
| 126 | &xor($tmp1,$d); # H function - part 2 | ||
| 127 | |||
| 128 | &xor($tmp1,$b); # H function - part 3 | ||
| 129 | &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2); | ||
| 130 | |||
| 131 | &add($a,$tmp1); | ||
| 132 | &mov($tmp1,&Np($c)) if $pos < 1; # H function - part 1 | ||
| 133 | &mov($tmp1,-1) if $pos == 1; # I function - part 1 | ||
| 134 | |||
| 135 | &rotl($a,$s); | ||
| 136 | |||
| 137 | &add($a,$b); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | sub R3 | ||
| 142 | { | ||
| 143 | local($pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_; | ||
| 144 | |||
| 145 | &comment("R3 $ki"); | ||
| 146 | |||
| 147 | # ¬($tmp1) | ||
| 148 | &xor($tmp1,$d) if $pos < 0; # I function - part 2 | ||
| 149 | |||
| 150 | &or($tmp1,$b); # I function - part 3 | ||
| 151 | &lea($a,&DWP($t,$a,$tmp2,1)); | ||
| 152 | |||
| 153 | &xor($tmp1,$c); # I function - part 4 | ||
| 154 | &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if $pos != 2; # load X/k value | ||
| 155 | &mov($tmp2,&wparam(0)) if $pos == 2; | ||
| 156 | |||
| 157 | &add($a,$tmp1); | ||
| 158 | &mov($tmp1,-1) if $pos < 1; # H function - part 1 | ||
| 159 | &add($K,64) if $pos >=1 && !$normal; | ||
| 160 | |||
| 161 | &rotl($a,$s); | ||
| 162 | |||
| 163 | &xor($tmp1,&Np($d)) if $pos <= 0; # I function - part = first time | ||
| 164 | &mov($tmp1,&DWP( 0,$tmp2,"",0)) if $pos > 0; | ||
| 165 | &add($a,$b); | ||
| 166 | } | ||
| 167 | |||
| 168 | |||
| 169 | sub md5_block | ||
| 170 | { | ||
| 171 | local($name)=@_; | ||
| 172 | |||
| 173 | &function_begin_B($name,"",3); | ||
| 174 | |||
| 175 | # parameter 1 is the MD5_CTX structure. | ||
| 176 | # A 0 | ||
| 177 | # B 4 | ||
| 178 | # C 8 | ||
| 179 | # D 12 | ||
| 180 | |||
| 181 | &push("esi"); | ||
| 182 | &push("edi"); | ||
| 183 | &mov($tmp1, &wparam(0)); # edi | ||
| 184 | &mov($X, &wparam(1)); # esi | ||
| 185 | &mov($C, &wparam(2)); | ||
| 186 | &push("ebp"); | ||
| 187 | &shl($C, 6); | ||
| 188 | &push("ebx"); | ||
| 189 | &add($C, $X); # offset we end at | ||
| 190 | &sub($C, 64); | ||
| 191 | &mov($A, &DWP( 0,$tmp1,"",0)); | ||
| 192 | &push($C); # Put on the TOS | ||
| 193 | &mov($B, &DWP( 4,$tmp1,"",0)); | ||
| 194 | &mov($C, &DWP( 8,$tmp1,"",0)); | ||
| 195 | &mov($D, &DWP(12,$tmp1,"",0)); | ||
| 196 | |||
| 197 | &set_label("start") unless $normal; | ||
| 198 | &comment(""); | ||
| 199 | &comment("R0 section"); | ||
| 200 | |||
| 201 | &R0(-2,$A,$B,$C,$D,$X, 0, 7,0xd76aa478); | ||
| 202 | &R0( 0,$D,$A,$B,$C,$X, 1,12,0xe8c7b756); | ||
| 203 | &R0( 0,$C,$D,$A,$B,$X, 2,17,0x242070db); | ||
| 204 | &R0( 0,$B,$C,$D,$A,$X, 3,22,0xc1bdceee); | ||
| 205 | &R0( 0,$A,$B,$C,$D,$X, 4, 7,0xf57c0faf); | ||
| 206 | &R0( 0,$D,$A,$B,$C,$X, 5,12,0x4787c62a); | ||
| 207 | &R0( 0,$C,$D,$A,$B,$X, 6,17,0xa8304613); | ||
| 208 | &R0( 0,$B,$C,$D,$A,$X, 7,22,0xfd469501); | ||
| 209 | &R0( 0,$A,$B,$C,$D,$X, 8, 7,0x698098d8); | ||
| 210 | &R0( 0,$D,$A,$B,$C,$X, 9,12,0x8b44f7af); | ||
| 211 | &R0( 0,$C,$D,$A,$B,$X,10,17,0xffff5bb1); | ||
| 212 | &R0( 0,$B,$C,$D,$A,$X,11,22,0x895cd7be); | ||
| 213 | &R0( 0,$A,$B,$C,$D,$X,12, 7,0x6b901122); | ||
| 214 | &R0( 0,$D,$A,$B,$C,$X,13,12,0xfd987193); | ||
| 215 | &R0( 0,$C,$D,$A,$B,$X,14,17,0xa679438e); | ||
| 216 | &R0( 1,$B,$C,$D,$A,$X,15,22,0x49b40821); | ||
| 217 | |||
| 218 | &comment(""); | ||
| 219 | &comment("R1 section"); | ||
| 220 | &R1(-1,$A,$B,$C,$D,$X,16, 5,0xf61e2562); | ||
| 221 | &R1( 0,$D,$A,$B,$C,$X,17, 9,0xc040b340); | ||
| 222 | &R1( 0,$C,$D,$A,$B,$X,18,14,0x265e5a51); | ||
| 223 | &R1( 0,$B,$C,$D,$A,$X,19,20,0xe9b6c7aa); | ||
| 224 | &R1( 0,$A,$B,$C,$D,$X,20, 5,0xd62f105d); | ||
| 225 | &R1( 0,$D,$A,$B,$C,$X,21, 9,0x02441453); | ||
| 226 | &R1( 0,$C,$D,$A,$B,$X,22,14,0xd8a1e681); | ||
| 227 | &R1( 0,$B,$C,$D,$A,$X,23,20,0xe7d3fbc8); | ||
| 228 | &R1( 0,$A,$B,$C,$D,$X,24, 5,0x21e1cde6); | ||
| 229 | &R1( 0,$D,$A,$B,$C,$X,25, 9,0xc33707d6); | ||
| 230 | &R1( 0,$C,$D,$A,$B,$X,26,14,0xf4d50d87); | ||
| 231 | &R1( 0,$B,$C,$D,$A,$X,27,20,0x455a14ed); | ||
| 232 | &R1( 0,$A,$B,$C,$D,$X,28, 5,0xa9e3e905); | ||
| 233 | &R1( 0,$D,$A,$B,$C,$X,29, 9,0xfcefa3f8); | ||
| 234 | &R1( 0,$C,$D,$A,$B,$X,30,14,0x676f02d9); | ||
| 235 | &R1( 1,$B,$C,$D,$A,$X,31,20,0x8d2a4c8a); | ||
| 236 | |||
| 237 | &comment(""); | ||
| 238 | &comment("R2 section"); | ||
| 239 | &R2( 0,-1,$A,$B,$C,$D,$X,32, 4,0xfffa3942); | ||
| 240 | &R2( 1, 0,$D,$A,$B,$C,$X,33,11,0x8771f681); | ||
| 241 | &R2( 2, 0,$C,$D,$A,$B,$X,34,16,0x6d9d6122); | ||
| 242 | &R2( 3, 0,$B,$C,$D,$A,$X,35,23,0xfde5380c); | ||
| 243 | &R2( 4, 0,$A,$B,$C,$D,$X,36, 4,0xa4beea44); | ||
| 244 | &R2( 5, 0,$D,$A,$B,$C,$X,37,11,0x4bdecfa9); | ||
| 245 | &R2( 6, 0,$C,$D,$A,$B,$X,38,16,0xf6bb4b60); | ||
| 246 | &R2( 7, 0,$B,$C,$D,$A,$X,39,23,0xbebfbc70); | ||
| 247 | &R2( 8, 0,$A,$B,$C,$D,$X,40, 4,0x289b7ec6); | ||
| 248 | &R2( 9, 0,$D,$A,$B,$C,$X,41,11,0xeaa127fa); | ||
| 249 | &R2(10, 0,$C,$D,$A,$B,$X,42,16,0xd4ef3085); | ||
| 250 | &R2(11, 0,$B,$C,$D,$A,$X,43,23,0x04881d05); | ||
| 251 | &R2(12, 0,$A,$B,$C,$D,$X,44, 4,0xd9d4d039); | ||
| 252 | &R2(13, 0,$D,$A,$B,$C,$X,45,11,0xe6db99e5); | ||
| 253 | &R2(14, 0,$C,$D,$A,$B,$X,46,16,0x1fa27cf8); | ||
| 254 | &R2(15, 1,$B,$C,$D,$A,$X,47,23,0xc4ac5665); | ||
| 255 | |||
| 256 | &comment(""); | ||
| 257 | &comment("R3 section"); | ||
| 258 | &R3(-1,$A,$B,$C,$D,$X,48, 6,0xf4292244); | ||
| 259 | &R3( 0,$D,$A,$B,$C,$X,49,10,0x432aff97); | ||
| 260 | &R3( 0,$C,$D,$A,$B,$X,50,15,0xab9423a7); | ||
| 261 | &R3( 0,$B,$C,$D,$A,$X,51,21,0xfc93a039); | ||
| 262 | &R3( 0,$A,$B,$C,$D,$X,52, 6,0x655b59c3); | ||
| 263 | &R3( 0,$D,$A,$B,$C,$X,53,10,0x8f0ccc92); | ||
| 264 | &R3( 0,$C,$D,$A,$B,$X,54,15,0xffeff47d); | ||
| 265 | &R3( 0,$B,$C,$D,$A,$X,55,21,0x85845dd1); | ||
| 266 | &R3( 0,$A,$B,$C,$D,$X,56, 6,0x6fa87e4f); | ||
| 267 | &R3( 0,$D,$A,$B,$C,$X,57,10,0xfe2ce6e0); | ||
| 268 | &R3( 0,$C,$D,$A,$B,$X,58,15,0xa3014314); | ||
| 269 | &R3( 0,$B,$C,$D,$A,$X,59,21,0x4e0811a1); | ||
| 270 | &R3( 0,$A,$B,$C,$D,$X,60, 6,0xf7537e82); | ||
| 271 | &R3( 0,$D,$A,$B,$C,$X,61,10,0xbd3af235); | ||
| 272 | &R3( 0,$C,$D,$A,$B,$X,62,15,0x2ad7d2bb); | ||
| 273 | &R3( 2,$B,$C,$D,$A,$X,63,21,0xeb86d391); | ||
| 274 | |||
| 275 | # &mov($tmp2,&wparam(0)); # done in the last R3 | ||
| 276 | # &mov($tmp1, &DWP( 0,$tmp2,"",0)); # done is the last R3 | ||
| 277 | |||
| 278 | &add($A,$tmp1); | ||
| 279 | &mov($tmp1, &DWP( 4,$tmp2,"",0)); | ||
| 280 | |||
| 281 | &add($B,$tmp1); | ||
| 282 | &mov($tmp1, &DWP( 8,$tmp2,"",0)); | ||
| 283 | |||
| 284 | &add($C,$tmp1); | ||
| 285 | &mov($tmp1, &DWP(12,$tmp2,"",0)); | ||
| 286 | |||
| 287 | &add($D,$tmp1); | ||
| 288 | &mov(&DWP( 0,$tmp2,"",0),$A); | ||
| 289 | |||
| 290 | &mov(&DWP( 4,$tmp2,"",0),$B); | ||
| 291 | &mov($tmp1,&swtmp(0)) unless $normal; | ||
| 292 | |||
| 293 | &mov(&DWP( 8,$tmp2,"",0),$C); | ||
| 294 | &mov(&DWP(12,$tmp2,"",0),$D); | ||
| 295 | |||
| 296 | &cmp($tmp1,$X) unless $normal; # check count | ||
| 297 | &jae(&label("start")) unless $normal; | ||
| 298 | |||
| 299 | &pop("eax"); # pop the temp variable off the stack | ||
| 300 | &pop("ebx"); | ||
| 301 | &pop("ebp"); | ||
| 302 | &pop("edi"); | ||
| 303 | &pop("esi"); | ||
| 304 | &ret(); | ||
| 305 | &function_end_B($name); | ||
| 306 | } | ||
| 307 | |||
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c deleted file mode 100644 index f1c9223d86..0000000000 --- a/src/lib/libcrypto/md5/md5.c +++ /dev/null | |||
| @@ -1,375 +0,0 @@ | |||
| 1 | /* $OpenBSD: md5.c,v 1.25 2025/01/24 13:35:04 jsing Exp $ */ | ||
| 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 <stdint.h> | ||
| 61 | #include <stdlib.h> | ||
| 62 | #include <string.h> | ||
| 63 | |||
| 64 | #include <openssl/opensslconf.h> | ||
| 65 | |||
| 66 | #include <openssl/md5.h> | ||
| 67 | |||
| 68 | #include "crypto_internal.h" | ||
| 69 | |||
| 70 | /* Ensure that MD5_LONG and uint32_t are equivalent size. */ | ||
| 71 | CTASSERT(sizeof(MD5_LONG) == sizeof(uint32_t)); | ||
| 72 | |||
| 73 | #ifdef MD5_ASM | ||
| 74 | void md5_block_data_order(MD5_CTX *c, const void *p, size_t num); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | #ifndef MD5_ASM | ||
| 78 | static inline uint32_t | ||
| 79 | md5_F(uint32_t x, uint32_t y, uint32_t z) | ||
| 80 | { | ||
| 81 | return (x & y) | (~x & z); | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline uint32_t | ||
| 85 | md5_G(uint32_t x, uint32_t y, uint32_t z) | ||
| 86 | { | ||
| 87 | return (x & z) | (y & ~z); | ||
| 88 | } | ||
| 89 | |||
| 90 | static inline uint32_t | ||
| 91 | md5_H(uint32_t x, uint32_t y, uint32_t z) | ||
| 92 | { | ||
| 93 | return x ^ y ^ z; | ||
| 94 | } | ||
| 95 | |||
| 96 | static inline uint32_t | ||
| 97 | md5_I(uint32_t x, uint32_t y, uint32_t z) | ||
| 98 | { | ||
| 99 | return y ^ (x | ~z); | ||
| 100 | } | ||
| 101 | |||
| 102 | static inline void | ||
| 103 | md5_round1(uint32_t *a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, | ||
| 104 | uint32_t t, uint32_t s) | ||
| 105 | { | ||
| 106 | *a = b + crypto_rol_u32(*a + md5_F(b, c, d) + x + t, s); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline void | ||
| 110 | md5_round2(uint32_t *a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, | ||
| 111 | uint32_t t, uint32_t s) | ||
| 112 | { | ||
| 113 | *a = b + crypto_rol_u32(*a + md5_G(b, c, d) + x + t, s); | ||
| 114 | } | ||
| 115 | |||
| 116 | static inline void | ||
| 117 | md5_round3(uint32_t *a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, | ||
| 118 | uint32_t t, uint32_t s) | ||
| 119 | { | ||
| 120 | *a = b + crypto_rol_u32(*a + md5_H(b, c, d) + x + t, s); | ||
| 121 | } | ||
| 122 | |||
| 123 | static inline void | ||
| 124 | md5_round4(uint32_t *a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, | ||
| 125 | uint32_t t, uint32_t s) | ||
| 126 | { | ||
| 127 | *a = b + crypto_rol_u32(*a + md5_I(b, c, d) + x + t, s); | ||
| 128 | } | ||
| 129 | |||
| 130 | static void | ||
| 131 | md5_block_data_order(MD5_CTX *c, const void *_in, size_t num) | ||
| 132 | { | ||
| 133 | const uint8_t *in = _in; | ||
| 134 | const MD5_LONG *in32; | ||
| 135 | MD5_LONG A, B, C, D; | ||
| 136 | MD5_LONG X0, X1, X2, X3, X4, X5, X6, X7, | ||
| 137 | X8, X9, X10, X11, X12, X13, X14, X15; | ||
| 138 | |||
| 139 | while (num-- > 0) { | ||
| 140 | A = c->A; | ||
| 141 | B = c->B; | ||
| 142 | C = c->C; | ||
| 143 | D = c->D; | ||
| 144 | |||
| 145 | if ((uintptr_t)in % 4 == 0) { | ||
| 146 | /* Input is 32 bit aligned. */ | ||
| 147 | in32 = (const MD5_LONG *)in; | ||
| 148 | X0 = le32toh(in32[0]); | ||
| 149 | X1 = le32toh(in32[1]); | ||
| 150 | X2 = le32toh(in32[2]); | ||
| 151 | X3 = le32toh(in32[3]); | ||
| 152 | X4 = le32toh(in32[4]); | ||
| 153 | X5 = le32toh(in32[5]); | ||
| 154 | X6 = le32toh(in32[6]); | ||
| 155 | X7 = le32toh(in32[7]); | ||
| 156 | X8 = le32toh(in32[8]); | ||
| 157 | X9 = le32toh(in32[9]); | ||
| 158 | X10 = le32toh(in32[10]); | ||
| 159 | X11 = le32toh(in32[11]); | ||
| 160 | X12 = le32toh(in32[12]); | ||
| 161 | X13 = le32toh(in32[13]); | ||
| 162 | X14 = le32toh(in32[14]); | ||
| 163 | X15 = le32toh(in32[15]); | ||
| 164 | } else { | ||
| 165 | /* Input is not 32 bit aligned. */ | ||
| 166 | X0 = crypto_load_le32toh(&in[0 * 4]); | ||
| 167 | X1 = crypto_load_le32toh(&in[1 * 4]); | ||
| 168 | X2 = crypto_load_le32toh(&in[2 * 4]); | ||
| 169 | X3 = crypto_load_le32toh(&in[3 * 4]); | ||
| 170 | X4 = crypto_load_le32toh(&in[4 * 4]); | ||
| 171 | X5 = crypto_load_le32toh(&in[5 * 4]); | ||
| 172 | X6 = crypto_load_le32toh(&in[6 * 4]); | ||
| 173 | X7 = crypto_load_le32toh(&in[7 * 4]); | ||
| 174 | X8 = crypto_load_le32toh(&in[8 * 4]); | ||
| 175 | X9 = crypto_load_le32toh(&in[9 * 4]); | ||
| 176 | X10 = crypto_load_le32toh(&in[10 * 4]); | ||
| 177 | X11 = crypto_load_le32toh(&in[11 * 4]); | ||
| 178 | X12 = crypto_load_le32toh(&in[12 * 4]); | ||
| 179 | X13 = crypto_load_le32toh(&in[13 * 4]); | ||
| 180 | X14 = crypto_load_le32toh(&in[14 * 4]); | ||
| 181 | X15 = crypto_load_le32toh(&in[15 * 4]); | ||
| 182 | } | ||
| 183 | in += MD5_CBLOCK; | ||
| 184 | |||
| 185 | md5_round1(&A, B, C, D, X0, 0xd76aa478L, 7); | ||
| 186 | md5_round1(&D, A, B, C, X1, 0xe8c7b756L, 12); | ||
| 187 | md5_round1(&C, D, A, B, X2, 0x242070dbL, 17); | ||
| 188 | md5_round1(&B, C, D, A, X3, 0xc1bdceeeL, 22); | ||
| 189 | md5_round1(&A, B, C, D, X4, 0xf57c0fafL, 7); | ||
| 190 | md5_round1(&D, A, B, C, X5, 0x4787c62aL, 12); | ||
| 191 | md5_round1(&C, D, A, B, X6, 0xa8304613L, 17); | ||
| 192 | md5_round1(&B, C, D, A, X7, 0xfd469501L, 22); | ||
| 193 | md5_round1(&A, B, C, D, X8, 0x698098d8L, 7); | ||
| 194 | md5_round1(&D, A, B, C, X9, 0x8b44f7afL, 12); | ||
| 195 | md5_round1(&C, D, A, B, X10, 0xffff5bb1L, 17); | ||
| 196 | md5_round1(&B, C, D, A, X11, 0x895cd7beL, 22); | ||
| 197 | md5_round1(&A, B, C, D, X12, 0x6b901122L, 7); | ||
| 198 | md5_round1(&D, A, B, C, X13, 0xfd987193L, 12); | ||
| 199 | md5_round1(&C, D, A, B, X14, 0xa679438eL, 17); | ||
| 200 | md5_round1(&B, C, D, A, X15, 0x49b40821L, 22); | ||
| 201 | |||
| 202 | md5_round2(&A, B, C, D, X1, 0xf61e2562L, 5); | ||
| 203 | md5_round2(&D, A, B, C, X6, 0xc040b340L, 9); | ||
| 204 | md5_round2(&C, D, A, B, X11, 0x265e5a51L, 14); | ||
| 205 | md5_round2(&B, C, D, A, X0, 0xe9b6c7aaL, 20); | ||
| 206 | md5_round2(&A, B, C, D, X5, 0xd62f105dL, 5); | ||
| 207 | md5_round2(&D, A, B, C, X10, 0x02441453L, 9); | ||
| 208 | md5_round2(&C, D, A, B, X15, 0xd8a1e681L, 14); | ||
| 209 | md5_round2(&B, C, D, A, X4, 0xe7d3fbc8L, 20); | ||
| 210 | md5_round2(&A, B, C, D, X9, 0x21e1cde6L, 5); | ||
| 211 | md5_round2(&D, A, B, C, X14, 0xc33707d6L, 9); | ||
| 212 | md5_round2(&C, D, A, B, X3, 0xf4d50d87L, 14); | ||
| 213 | md5_round2(&B, C, D, A, X8, 0x455a14edL, 20); | ||
| 214 | md5_round2(&A, B, C, D, X13, 0xa9e3e905L, 5); | ||
| 215 | md5_round2(&D, A, B, C, X2, 0xfcefa3f8L, 9); | ||
| 216 | md5_round2(&C, D, A, B, X7, 0x676f02d9L, 14); | ||
| 217 | md5_round2(&B, C, D, A, X12, 0x8d2a4c8aL, 20); | ||
| 218 | |||
| 219 | md5_round3(&A, B, C, D, X5, 0xfffa3942L, 4); | ||
| 220 | md5_round3(&D, A, B, C, X8, 0x8771f681L, 11); | ||
| 221 | md5_round3(&C, D, A, B, X11, 0x6d9d6122L, 16); | ||
| 222 | md5_round3(&B, C, D, A, X14, 0xfde5380cL, 23); | ||
| 223 | md5_round3(&A, B, C, D, X1, 0xa4beea44L, 4); | ||
| 224 | md5_round3(&D, A, B, C, X4, 0x4bdecfa9L, 11); | ||
| 225 | md5_round3(&C, D, A, B, X7, 0xf6bb4b60L, 16); | ||
| 226 | md5_round3(&B, C, D, A, X10, 0xbebfbc70L, 23); | ||
| 227 | md5_round3(&A, B, C, D, X13, 0x289b7ec6L, 4); | ||
| 228 | md5_round3(&D, A, B, C, X0, 0xeaa127faL, 11); | ||
| 229 | md5_round3(&C, D, A, B, X3, 0xd4ef3085L, 16); | ||
| 230 | md5_round3(&B, C, D, A, X6, 0x04881d05L, 23); | ||
| 231 | md5_round3(&A, B, C, D, X9, 0xd9d4d039L, 4); | ||
| 232 | md5_round3(&D, A, B, C, X12, 0xe6db99e5L, 11); | ||
| 233 | md5_round3(&C, D, A, B, X15, 0x1fa27cf8L, 16); | ||
| 234 | md5_round3(&B, C, D, A, X2, 0xc4ac5665L, 23); | ||
| 235 | |||
| 236 | md5_round4(&A, B, C, D, X0, 0xf4292244L, 6); | ||
| 237 | md5_round4(&D, A, B, C, X7, 0x432aff97L, 10); | ||
| 238 | md5_round4(&C, D, A, B, X14, 0xab9423a7L, 15); | ||
| 239 | md5_round4(&B, C, D, A, X5, 0xfc93a039L, 21); | ||
| 240 | md5_round4(&A, B, C, D, X12, 0x655b59c3L, 6); | ||
| 241 | md5_round4(&D, A, B, C, X3, 0x8f0ccc92L, 10); | ||
| 242 | md5_round4(&C, D, A, B, X10, 0xffeff47dL, 15); | ||
| 243 | md5_round4(&B, C, D, A, X1, 0x85845dd1L, 21); | ||
| 244 | md5_round4(&A, B, C, D, X8, 0x6fa87e4fL, 6); | ||
| 245 | md5_round4(&D, A, B, C, X15, 0xfe2ce6e0L, 10); | ||
| 246 | md5_round4(&C, D, A, B, X6, 0xa3014314L, 15); | ||
| 247 | md5_round4(&B, C, D, A, X13, 0x4e0811a1L, 21); | ||
| 248 | md5_round4(&A, B, C, D, X4, 0xf7537e82L, 6); | ||
| 249 | md5_round4(&D, A, B, C, X11, 0xbd3af235L, 10); | ||
| 250 | md5_round4(&C, D, A, B, X2, 0x2ad7d2bbL, 15); | ||
| 251 | md5_round4(&B, C, D, A, X9, 0xeb86d391L, 21); | ||
| 252 | |||
| 253 | c->A += A; | ||
| 254 | c->B += B; | ||
| 255 | c->C += C; | ||
| 256 | c->D += D; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | #endif | ||
| 260 | |||
| 261 | int | ||
| 262 | MD5_Init(MD5_CTX *c) | ||
| 263 | { | ||
| 264 | memset(c, 0, sizeof(*c)); | ||
| 265 | |||
| 266 | c->A = 0x67452301UL; | ||
| 267 | c->B = 0xefcdab89UL; | ||
| 268 | c->C = 0x98badcfeUL; | ||
| 269 | c->D = 0x10325476UL; | ||
| 270 | |||
| 271 | return 1; | ||
| 272 | } | ||
| 273 | LCRYPTO_ALIAS(MD5_Init); | ||
| 274 | |||
| 275 | int | ||
| 276 | MD5_Update(MD5_CTX *c, const void *data_, size_t len) | ||
| 277 | { | ||
| 278 | const unsigned char *data = data_; | ||
| 279 | unsigned char *p; | ||
| 280 | size_t n; | ||
| 281 | |||
| 282 | if (len == 0) | ||
| 283 | return 1; | ||
| 284 | |||
| 285 | /* Update message bit counter. */ | ||
| 286 | crypto_add_u32dw_u64(&c->Nh, &c->Nl, (uint64_t)len << 3); | ||
| 287 | |||
| 288 | n = c->num; | ||
| 289 | if (n != 0) { | ||
| 290 | p = (unsigned char *)c->data; | ||
| 291 | |||
| 292 | if (len >= MD5_CBLOCK || len + n >= MD5_CBLOCK) { | ||
| 293 | memcpy(p + n, data, MD5_CBLOCK - n); | ||
| 294 | md5_block_data_order(c, p, 1); | ||
| 295 | n = MD5_CBLOCK - n; | ||
| 296 | data += n; | ||
| 297 | len -= n; | ||
| 298 | c->num = 0; | ||
| 299 | memset(p, 0, MD5_CBLOCK); /* keep it zeroed */ | ||
| 300 | } else { | ||
| 301 | memcpy(p + n, data, len); | ||
| 302 | c->num += (unsigned int)len; | ||
| 303 | return 1; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | n = len/MD5_CBLOCK; | ||
| 308 | if (n > 0) { | ||
| 309 | md5_block_data_order(c, data, n); | ||
| 310 | n *= MD5_CBLOCK; | ||
| 311 | data += n; | ||
| 312 | len -= n; | ||
| 313 | } | ||
| 314 | |||
| 315 | if (len != 0) { | ||
| 316 | p = (unsigned char *)c->data; | ||
| 317 | c->num = (unsigned int)len; | ||
| 318 | memcpy(p, data, len); | ||
| 319 | } | ||
| 320 | return 1; | ||
| 321 | } | ||
| 322 | LCRYPTO_ALIAS(MD5_Update); | ||
| 323 | |||
| 324 | void | ||
| 325 | MD5_Transform(MD5_CTX *c, const unsigned char *data) | ||
| 326 | { | ||
| 327 | md5_block_data_order(c, data, 1); | ||
| 328 | } | ||
| 329 | LCRYPTO_ALIAS(MD5_Transform); | ||
| 330 | |||
| 331 | int | ||
| 332 | MD5_Final(unsigned char *md, MD5_CTX *c) | ||
| 333 | { | ||
| 334 | unsigned char *p = (unsigned char *)c->data; | ||
| 335 | size_t n = c->num; | ||
| 336 | |||
| 337 | p[n] = 0x80; /* there is always room for one */ | ||
| 338 | n++; | ||
| 339 | |||
| 340 | if (n > (MD5_CBLOCK - 8)) { | ||
| 341 | memset(p + n, 0, MD5_CBLOCK - n); | ||
| 342 | n = 0; | ||
| 343 | md5_block_data_order(c, p, 1); | ||
| 344 | } | ||
| 345 | |||
| 346 | memset(p + n, 0, MD5_CBLOCK - 8 - n); | ||
| 347 | c->data[MD5_LBLOCK - 2] = htole32(c->Nl); | ||
| 348 | c->data[MD5_LBLOCK - 1] = htole32(c->Nh); | ||
| 349 | |||
| 350 | md5_block_data_order(c, p, 1); | ||
| 351 | c->num = 0; | ||
| 352 | memset(p, 0, MD5_CBLOCK); | ||
| 353 | |||
| 354 | crypto_store_htole32(&md[0 * 4], c->A); | ||
| 355 | crypto_store_htole32(&md[1 * 4], c->B); | ||
| 356 | crypto_store_htole32(&md[2 * 4], c->C); | ||
| 357 | crypto_store_htole32(&md[3 * 4], c->D); | ||
| 358 | |||
| 359 | return 1; | ||
| 360 | } | ||
| 361 | LCRYPTO_ALIAS(MD5_Final); | ||
| 362 | |||
| 363 | unsigned char * | ||
| 364 | MD5(const unsigned char *d, size_t n, unsigned char *md) | ||
| 365 | { | ||
| 366 | MD5_CTX c; | ||
| 367 | |||
| 368 | if (!MD5_Init(&c)) | ||
| 369 | return NULL; | ||
| 370 | MD5_Update(&c, d, n); | ||
| 371 | MD5_Final(md, &c); | ||
| 372 | explicit_bzero(&c, sizeof(c)); | ||
| 373 | return (md); | ||
| 374 | } | ||
| 375 | LCRYPTO_ALIAS(MD5); | ||
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h deleted file mode 100644 index 4d94c84ba6..0000000000 --- a/src/lib/libcrypto/md5/md5.h +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /* $OpenBSD: md5.h,v 1.25 2025/01/25 17:59:44 tb Exp $ */ | ||
| 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 <stddef.h> | ||
| 60 | |||
| 61 | #ifndef HEADER_MD5_H | ||
| 62 | #define HEADER_MD5_H | ||
| 63 | |||
| 64 | #include <openssl/opensslconf.h> | ||
| 65 | |||
| 66 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__) | ||
| 67 | #define __bounded__(x, y, z) | ||
| 68 | #endif | ||
| 69 | |||
| 70 | #ifdef __cplusplus | ||
| 71 | extern "C" { | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #define MD5_LONG unsigned int | ||
| 75 | |||
| 76 | #define MD5_CBLOCK 64 | ||
| 77 | #define MD5_LBLOCK (MD5_CBLOCK/4) | ||
| 78 | #define MD5_DIGEST_LENGTH 16 | ||
| 79 | |||
| 80 | typedef struct MD5state_st { | ||
| 81 | MD5_LONG A, B,C, D; | ||
| 82 | MD5_LONG Nl, Nh; | ||
| 83 | MD5_LONG data[MD5_LBLOCK]; | ||
| 84 | unsigned int num; | ||
| 85 | } MD5_CTX; | ||
| 86 | |||
| 87 | int MD5_Init(MD5_CTX *c); | ||
| 88 | int MD5_Update(MD5_CTX *c, const void *data, size_t len) | ||
| 89 | __attribute__ ((__bounded__(__buffer__, 2, 3))); | ||
| 90 | int MD5_Final(unsigned char *md, MD5_CTX *c); | ||
| 91 | unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) | ||
| 92 | __attribute__ ((__bounded__(__buffer__, 1, 2))) | ||
| 93 | __attribute__ ((__nonnull__(3))); | ||
| 94 | void MD5_Transform(MD5_CTX *c, const unsigned char *b); | ||
| 95 | #ifdef __cplusplus | ||
| 96 | } | ||
| 97 | #endif | ||
| 98 | |||
| 99 | #endif | ||
diff --git a/src/lib/libcrypto/md5/md5_amd64_generic.S b/src/lib/libcrypto/md5/md5_amd64_generic.S deleted file mode 100644 index e282d56ad8..0000000000 --- a/src/lib/libcrypto/md5/md5_amd64_generic.S +++ /dev/null | |||
| @@ -1,237 +0,0 @@ | |||
| 1 | /* $OpenBSD: md5_amd64_generic.S,v 1.1 2025/01/24 13:35:04 jsing Exp $ */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2025 Joel Sing <jsing@openbsd.org> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted, provided that the above | ||
| 7 | * copyright notice and this permission notice appear in all copies. | ||
| 8 | * | ||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifdef __CET__ | ||
| 19 | #include <cet.h> | ||
| 20 | #else | ||
| 21 | #define _CET_ENDBR | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #define ctx %rdi | ||
| 25 | #define in %rsi | ||
| 26 | #define num %rdx | ||
| 27 | |||
| 28 | #define end %rbp | ||
| 29 | |||
| 30 | #define A %eax | ||
| 31 | #define B %ebx | ||
| 32 | #define C %ecx | ||
| 33 | #define D %edx | ||
| 34 | |||
| 35 | #define AA %r8d | ||
| 36 | #define BB %r9d | ||
| 37 | #define CC %r10d | ||
| 38 | #define DD %r11d | ||
| 39 | |||
| 40 | #define tmp0 %r12d | ||
| 41 | #define tmp1 %r13d | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Compute MD5 round 1 as: | ||
| 45 | * | ||
| 46 | * a = b + rol(a + F(b, c, d) + x + t, s) | ||
| 47 | * F(x, y, z) = (x & y) | (~x & z) | ||
| 48 | * = ((y ^ z) & x) ^ z | ||
| 49 | */ | ||
| 50 | #define md5_round1(a, b, c, d, x, t, s) \ | ||
| 51 | addl (x*4)(in), a; \ | ||
| 52 | movl c, tmp0; \ | ||
| 53 | xorl d, tmp0; \ | ||
| 54 | andl b, tmp0; \ | ||
| 55 | xorl d, tmp0; \ | ||
| 56 | leal t(tmp0, a), a; \ | ||
| 57 | roll $s, a; \ | ||
| 58 | addl b, a; | ||
| 59 | |||
| 60 | /* | ||
| 61 | * Compute MD5 round 2 as: | ||
| 62 | * | ||
| 63 | * a = b + rol(a + G(b, c, d) + x + t, s) | ||
| 64 | * G(x, y, z) = (x & z) | (y & ~z) | ||
| 65 | */ | ||
| 66 | #define md5_round2(a, b, c, d, x, t, s) \ | ||
| 67 | addl (x*4)(in), a; \ | ||
| 68 | movl d, tmp0; \ | ||
| 69 | xorl $-1, tmp0; \ | ||
| 70 | andl c, tmp0; \ | ||
| 71 | addl tmp0, a; \ | ||
| 72 | movl d, tmp1; \ | ||
| 73 | andl b, tmp1; \ | ||
| 74 | leal t(tmp1, a), a; \ | ||
| 75 | roll $s, a; \ | ||
| 76 | addl b, a; | ||
| 77 | |||
| 78 | /* | ||
| 79 | * Compute MD5 round 3 as: | ||
| 80 | * | ||
| 81 | * a = b + rol(a + H(b, c, d) + x + t, s) | ||
| 82 | * H(x, y, z) = x ^ y ^ z; | ||
| 83 | */ | ||
| 84 | #define md5_round3(a, b, c, d, x, t, s) \ | ||
| 85 | addl (x*4)(in), a; \ | ||
| 86 | movl d, tmp0; \ | ||
| 87 | xorl c, tmp0; \ | ||
| 88 | xorl b, tmp0; \ | ||
| 89 | leal t(tmp0, a), a; \ | ||
| 90 | roll $s, a; \ | ||
| 91 | addl b, a; | ||
| 92 | |||
| 93 | /* | ||
| 94 | * Compute MD5 round 4 as: | ||
| 95 | * | ||
| 96 | * a = b + rol(a + I(b, c, d) + x + t, s) | ||
| 97 | * I(x, y, z) = y ^ (x | ~z) | ||
| 98 | */ | ||
| 99 | #define md5_round4(a, b, c, d, x, t, s) \ | ||
| 100 | addl (x*4)(in), a; \ | ||
| 101 | movl d, tmp0; \ | ||
| 102 | xorl $-1, tmp0; \ | ||
| 103 | orl b, tmp0; \ | ||
| 104 | xorl c, tmp0; \ | ||
| 105 | leal t(tmp0, a), a; \ | ||
| 106 | roll $s, a; \ | ||
| 107 | addl b, a; | ||
| 108 | |||
| 109 | .text | ||
| 110 | |||
| 111 | /* | ||
| 112 | * void md5_block_data_order(MD5_CTX *ctx, const void *in, size_t num); | ||
| 113 | * | ||
| 114 | * Standard x86-64 ABI: rdi = ctx, rsi = in, rdx = num | ||
| 115 | */ | ||
| 116 | .align 16 | ||
| 117 | .globl md5_block_data_order | ||
| 118 | .type md5_block_data_order,@function | ||
| 119 | md5_block_data_order: | ||
| 120 | _CET_ENDBR | ||
| 121 | |||
| 122 | /* Save callee save registers. */ | ||
| 123 | pushq %rbx | ||
| 124 | pushq %rbp | ||
| 125 | pushq %r12 | ||
| 126 | pushq %r13 | ||
| 127 | |||
| 128 | /* Compute end of message. */ | ||
| 129 | shlq $6, num | ||
| 130 | leaq (in, num, 1), end | ||
| 131 | |||
| 132 | /* Load current hash state from context. */ | ||
| 133 | movl (0*4)(ctx), AA | ||
| 134 | movl (1*4)(ctx), BB | ||
| 135 | movl (2*4)(ctx), CC | ||
| 136 | movl (3*4)(ctx), DD | ||
| 137 | |||
| 138 | jmp .Lblock_loop | ||
| 139 | |||
| 140 | .align 16 | ||
| 141 | .Lblock_loop: | ||
| 142 | movl AA, A | ||
| 143 | movl BB, B | ||
| 144 | movl CC, C | ||
| 145 | movl DD, D | ||
| 146 | |||
| 147 | md5_round1(A, B, C, D, 0, 0xd76aa478L, 7); | ||
| 148 | md5_round1(D, A, B, C, 1, 0xe8c7b756L, 12); | ||
| 149 | md5_round1(C, D, A, B, 2, 0x242070dbL, 17); | ||
| 150 | md5_round1(B, C, D, A, 3, 0xc1bdceeeL, 22); | ||
| 151 | md5_round1(A, B, C, D, 4, 0xf57c0fafL, 7); | ||
| 152 | md5_round1(D, A, B, C, 5, 0x4787c62aL, 12); | ||
| 153 | md5_round1(C, D, A, B, 6, 0xa8304613L, 17); | ||
| 154 | md5_round1(B, C, D, A, 7, 0xfd469501L, 22); | ||
| 155 | md5_round1(A, B, C, D, 8, 0x698098d8L, 7); | ||
| 156 | md5_round1(D, A, B, C, 9, 0x8b44f7afL, 12); | ||
| 157 | md5_round1(C, D, A, B, 10, 0xffff5bb1L, 17); | ||
| 158 | md5_round1(B, C, D, A, 11, 0x895cd7beL, 22); | ||
| 159 | md5_round1(A, B, C, D, 12, 0x6b901122L, 7); | ||
| 160 | md5_round1(D, A, B, C, 13, 0xfd987193L, 12); | ||
| 161 | md5_round1(C, D, A, B, 14, 0xa679438eL, 17); | ||
| 162 | md5_round1(B, C, D, A, 15, 0x49b40821L, 22); | ||
| 163 | |||
| 164 | md5_round2(A, B, C, D, 1, 0xf61e2562L, 5); | ||
| 165 | md5_round2(D, A, B, C, 6, 0xc040b340L, 9); | ||
| 166 | md5_round2(C, D, A, B, 11, 0x265e5a51L, 14); | ||
| 167 | md5_round2(B, C, D, A, 0, 0xe9b6c7aaL, 20); | ||
| 168 | md5_round2(A, B, C, D, 5, 0xd62f105dL, 5); | ||
| 169 | md5_round2(D, A, B, C, 10, 0x02441453L, 9); | ||
| 170 | md5_round2(C, D, A, B, 15, 0xd8a1e681L, 14); | ||
| 171 | md5_round2(B, C, D, A, 4, 0xe7d3fbc8L, 20); | ||
| 172 | md5_round2(A, B, C, D, 9, 0x21e1cde6L, 5); | ||
| 173 | md5_round2(D, A, B, C, 14, 0xc33707d6L, 9); | ||
| 174 | md5_round2(C, D, A, B, 3, 0xf4d50d87L, 14); | ||
| 175 | md5_round2(B, C, D, A, 8, 0x455a14edL, 20); | ||
| 176 | md5_round2(A, B, C, D, 13, 0xa9e3e905L, 5); | ||
| 177 | md5_round2(D, A, B, C, 2, 0xfcefa3f8L, 9); | ||
| 178 | md5_round2(C, D, A, B, 7, 0x676f02d9L, 14); | ||
| 179 | md5_round2(B, C, D, A, 12, 0x8d2a4c8aL, 20); | ||
| 180 | |||
| 181 | md5_round3(A, B, C, D, 5, 0xfffa3942L, 4); | ||
| 182 | md5_round3(D, A, B, C, 8, 0x8771f681L, 11); | ||
| 183 | md5_round3(C, D, A, B, 11, 0x6d9d6122L, 16); | ||
| 184 | md5_round3(B, C, D, A, 14, 0xfde5380cL, 23); | ||
| 185 | md5_round3(A, B, C, D, 1, 0xa4beea44L, 4); | ||
| 186 | md5_round3(D, A, B, C, 4, 0x4bdecfa9L, 11); | ||
| 187 | md5_round3(C, D, A, B, 7, 0xf6bb4b60L, 16); | ||
| 188 | md5_round3(B, C, D, A, 10, 0xbebfbc70L, 23); | ||
| 189 | md5_round3(A, B, C, D, 13, 0x289b7ec6L, 4); | ||
| 190 | md5_round3(D, A, B, C, 0, 0xeaa127faL, 11); | ||
| 191 | md5_round3(C, D, A, B, 3, 0xd4ef3085L, 16); | ||
| 192 | md5_round3(B, C, D, A, 6, 0x04881d05L, 23); | ||
| 193 | md5_round3(A, B, C, D, 9, 0xd9d4d039L, 4); | ||
| 194 | md5_round3(D, A, B, C, 12, 0xe6db99e5L, 11); | ||
| 195 | md5_round3(C, D, A, B, 15, 0x1fa27cf8L, 16); | ||
| 196 | md5_round3(B, C, D, A, 2, 0xc4ac5665L, 23); | ||
| 197 | |||
| 198 | md5_round4(A, B, C, D, 0, 0xf4292244L, 6); | ||
| 199 | md5_round4(D, A, B, C, 7, 0x432aff97L, 10); | ||
| 200 | md5_round4(C, D, A, B, 14, 0xab9423a7L, 15); | ||
| 201 | md5_round4(B, C, D, A, 5, 0xfc93a039L, 21); | ||
| 202 | md5_round4(A, B, C, D, 12, 0x655b59c3L, 6); | ||
| 203 | md5_round4(D, A, B, C, 3, 0x8f0ccc92L, 10); | ||
| 204 | md5_round4(C, D, A, B, 10, 0xffeff47dL, 15); | ||
| 205 | md5_round4(B, C, D, A, 1, 0x85845dd1L, 21); | ||
| 206 | md5_round4(A, B, C, D, 8, 0x6fa87e4fL, 6); | ||
| 207 | md5_round4(D, A, B, C, 15, 0xfe2ce6e0L, 10); | ||
| 208 | md5_round4(C, D, A, B, 6, 0xa3014314L, 15); | ||
| 209 | md5_round4(B, C, D, A, 13, 0x4e0811a1L, 21); | ||
| 210 | md5_round4(A, B, C, D, 4, 0xf7537e82L, 6); | ||
| 211 | md5_round4(D, A, B, C, 11, 0xbd3af235L, 10); | ||
| 212 | md5_round4(C, D, A, B, 2, 0x2ad7d2bbL, 15); | ||
| 213 | md5_round4(B, C, D, A, 9, 0xeb86d391L, 21); | ||
| 214 | |||
| 215 | /* Add intermediate state to hash state. */ | ||
| 216 | addl A, AA | ||
| 217 | addl B, BB | ||
| 218 | addl C, CC | ||
| 219 | addl D, DD | ||
| 220 | |||
| 221 | addq $64, in | ||
| 222 | cmpq end, in | ||
| 223 | jb .Lblock_loop | ||
| 224 | |||
| 225 | /* Store new hash state to context. */ | ||
| 226 | movl AA, (0*4)(ctx) | ||
| 227 | movl BB, (1*4)(ctx) | ||
| 228 | movl CC, (2*4)(ctx) | ||
| 229 | movl DD, (3*4)(ctx) | ||
| 230 | |||
| 231 | /* Restore callee save registers. */ | ||
| 232 | popq %r13 | ||
| 233 | popq %r12 | ||
| 234 | popq %rbp | ||
| 235 | popq %rbx | ||
| 236 | |||
| 237 | ret | ||
