2 # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
11 push(@INC,"${dir}","${dir}../../perlasm");
16 open STDOUT,">$output";
18 &asm_init($ARGV[0],"rc5-586.pl");
21 $RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4;
30 &RC5_32_encrypt("RC5_32_encrypt",1);
31 &RC5_32_encrypt("RC5_32_decrypt",0);
32 &cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1);
41 &function_begin_B($name,"");
48 &mov($tmp4,&wparam(0));
51 &comment("Load the 2 words");
52 &mov($A,&DWP(0,$tmp4,"",0));
53 &mov($B,&DWP(4,$tmp4,"",0));
56 &mov($r, &DWP(0,$S,"",0));
62 &add($A, &DWP(4+0,$S,"",0));
63 &add($B, &DWP(4+4,$S,"",0));
65 for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
68 &mov($tmp1, &DWP(12+$i*8,$S,"",0));
70 &rotl($A, &LB("ecx"));
74 &mov($tmp1, &DWP(16+$i*8,$S,"",0));
76 &rotl($B, &LB("ecx"));
78 if (($i == 7) || ($i == 11))
81 &je(&label("rc5_exit"));
88 &je(&label("rc5_dec_12"));
90 &je(&label("rc5_dec_8"));
91 for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
93 &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8);
94 &mov($tmp1, &DWP($i*8+8,$S,"",0));
97 &rotr($B, &LB("ecx"));
100 &mov($tmp1, &DWP($i*8+4,$S,"",0));
103 &rotr($A, &LB("ecx"));
106 &sub($B, &DWP(4+4,$S,"",0));
107 &sub($A, &DWP(4+0,$S,"",0));
110 &set_label("rc5_exit");
111 &mov(&DWP(0,$tmp4,"",0),$A);
112 &mov(&DWP(4,$tmp4,"",0),$B);
119 &function_end_B($name);