2 # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (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");
15 $output = pop and open STDOUT,">$output";
20 $RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4;
29 &RC5_32_encrypt("RC5_32_encrypt",1);
30 &RC5_32_encrypt("RC5_32_decrypt",0);
31 &cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1);
40 &function_begin_B($name,"");
47 &mov($tmp4,&wparam(0));
50 &comment("Load the 2 words");
51 &mov($A,&DWP(0,$tmp4,"",0));
52 &mov($B,&DWP(4,$tmp4,"",0));
55 &mov($r, &DWP(0,$S,"",0));
61 &add($A, &DWP(4+0,$S,"",0));
62 &add($B, &DWP(4+4,$S,"",0));
64 for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
67 &mov($tmp1, &DWP(12+$i*8,$S,"",0));
69 &rotl($A, &LB("ecx"));
73 &mov($tmp1, &DWP(16+$i*8,$S,"",0));
75 &rotl($B, &LB("ecx"));
77 if (($i == 7) || ($i == 11))
80 &je(&label("rc5_exit"));
87 &je(&label("rc5_dec_12"));
89 &je(&label("rc5_dec_8"));
90 for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
92 &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8);
93 &mov($tmp1, &DWP($i*8+8,$S,"",0));
96 &rotr($B, &LB("ecx"));
99 &mov($tmp1, &DWP($i*8+4,$S,"",0));
102 &rotr($A, &LB("ecx"));
105 &sub($B, &DWP(4+4,$S,"",0));
106 &sub($A, &DWP(4+0,$S,"",0));
109 &set_label("rc5_exit");
110 &mov(&DWP(0,$tmp4,"",0),$A);
111 &mov(&DWP(4,$tmp4,"",0),$B);
118 &function_end_B($name);