2 # Copyright 2022 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 # $output is the last argument if it looks like a file (it has an extension)
11 # $flavour is the first argument if it doesn't look like a file
12 ($zero,$ra,$tp,$sp)=map("\$r$_",(0..3));
13 ($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$r$_",(4..11));
14 ($t0,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9)=map("\$r$_",(12..21));
15 ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$r$_",(23..30));
16 ($vr0,$vr1,$vr2,$vr3,$vr4,$vr5,$vr6,$vr7,$vr8,$vr9,$vr10,$vr11,$vr12,$vr13,$vr14,$vr15,$vr16,$vr17,$vr18,$vr19)=map("\$vr$_",(0..19));
17 ($fp)=map("\$r$_",(22));
20 for (@ARGV) { $output=$_ if (/\w[\w\-]*\.\w+$/); }
21 open STDOUT,">$output";
22 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
23 open STDOUT,">$output";
26 my ($in_a,$in_b,$len,$m,$temp1,$temp2) = ($a0,$a1,$a2,$t0,$t1,$t2);
28 ################################################################################
29 # int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len)
30 ################################################################################
34 .type CRYPTO_memcmp,\@function
37 beqz $len,2f # len == 0
44 xor $temp1,$temp1,$temp2
53 my ($ptr,$len,$temp1,$temp2) = ($a0,$a1,$t0,$t1);
55 ################################################################################
56 # void OPENSSL_cleanse(void *ptr, size_t len)
57 ################################################################################
60 .globl OPENSSL_cleanse
61 .type OPENSSL_cleanse,\@function
63 beqz $len,2f # len == 0, return
65 bnez $temp1,3f # len > 15
67 1: # Store <= 15 individual bytes
75 3: # Store individual bytes until we are aligned
83 4: # Store aligned dwords
89 bge $len,$temp2,4b # if len>=8 loop
90 bnez $len,1b # if len<8 and len != 0, store remaining bytes
96 ################################################################################
97 # uint32_t OPENSSL_rdtsc(void)
98 ################################################################################
102 .type OPENSSL_rdtsc,\@function
109 $code =~ s/\`([^\`]*)\`/eval($1)/gem;
113 close STDOUT or die "error closing STDOUT: $!";