]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/arm64cpuid.pl
Implement EVP_MAC_do_all_ex()
[thirdparty/openssl.git] / crypto / arm64cpuid.pl
CommitLineData
e0a65194 1#! /usr/bin/env perl
6738bf14 2# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
e0a65194 3#
0e9725bc 4# Licensed under the Apache License 2.0 (the "License"). You may not use
e0a65194
RS
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
8
9b05cbc3
AP
9
10$flavour = shift;
11$output = shift;
12
13$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
14( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
15( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
16die "can't locate arm-xlate.pl";
17
18open OUT,"| \"$^X\" $xlate $flavour $output";
19*STDOUT=*OUT;
20
21$code.=<<___;
e8d93e34
AP
22#include "arm_arch.h"
23
24.text
25.arch armv8-a+crypto
26
27.align 5
9b05cbc3 28.globl _armv7_neon_probe
e8d93e34
AP
29.type _armv7_neon_probe,%function
30_armv7_neon_probe:
31 orr v15.16b, v15.16b, v15.16b
32 ret
33.size _armv7_neon_probe,.-_armv7_neon_probe
34
9b05cbc3 35.globl _armv7_tick
e8d93e34
AP
36.type _armv7_tick,%function
37_armv7_tick:
9b05cbc3
AP
38#ifdef __APPLE__
39 mrs x0, CNTPCT_EL0
40#else
e8d93e34 41 mrs x0, CNTVCT_EL0
9b05cbc3 42#endif
e8d93e34
AP
43 ret
44.size _armv7_tick,.-_armv7_tick
45
9b05cbc3 46.globl _armv8_aes_probe
e8d93e34
AP
47.type _armv8_aes_probe,%function
48_armv8_aes_probe:
49 aese v0.16b, v0.16b
50 ret
51.size _armv8_aes_probe,.-_armv8_aes_probe
52
9b05cbc3 53.globl _armv8_sha1_probe
e8d93e34
AP
54.type _armv8_sha1_probe,%function
55_armv8_sha1_probe:
56 sha1h s0, s0
57 ret
58.size _armv8_sha1_probe,.-_armv8_sha1_probe
59
9b05cbc3 60.globl _armv8_sha256_probe
e8d93e34
AP
61.type _armv8_sha256_probe,%function
62_armv8_sha256_probe:
63 sha256su0 v0.4s, v0.4s
64 ret
65.size _armv8_sha256_probe,.-_armv8_sha256_probe
77f3612e 66
9b05cbc3 67.globl _armv8_pmull_probe
e8d93e34
AP
68.type _armv8_pmull_probe,%function
69_armv8_pmull_probe:
70 pmull v0.1q, v0.1d, v0.1d
71 ret
72.size _armv8_pmull_probe,.-_armv8_pmull_probe
6133b4ed 73
77f3612e
AP
74.globl _armv8_sha512_probe
75.type _armv8_sha512_probe,%function
76_armv8_sha512_probe:
77 .long 0xcec08000 // sha512su0 v0.2d,v0.2d
78 ret
79.size _armv8_sha512_probe,.-_armv8_sha512_probe
80
6133b4ed
AP
81.globl OPENSSL_cleanse
82.type OPENSSL_cleanse,%function
83.align 5
84OPENSSL_cleanse:
85 cbz x1,.Lret // len==0?
86 cmp x1,#15
87 b.hi .Lot // len>15
88 nop
89.Little:
90 strb wzr,[x0],#1 // store byte-by-byte
91 subs x1,x1,#1
92 b.ne .Little
93.Lret: ret
94
95.align 4
96.Lot: tst x0,#7
97 b.eq .Laligned // inp is aligned
98 strb wzr,[x0],#1 // store byte-by-byte
99 sub x1,x1,#1
100 b .Lot
101
102.align 4
103.Laligned:
104 str xzr,[x0],#8 // store word-by-word
105 sub x1,x1,#8
106 tst x1,#-8
107 b.ne .Laligned // len>=8
108 cbnz x1,.Little // len!=0?
109 ret
110.size OPENSSL_cleanse,.-OPENSSL_cleanse
e33826f0
AP
111
112.globl CRYPTO_memcmp
113.type CRYPTO_memcmp,%function
114.align 4
115CRYPTO_memcmp:
116 eor w3,w3,w3
117 cbz x2,.Lno_data // len==0?
9a708bf9
AP
118 cmp x2,#16
119 b.ne .Loop_cmp
120 ldp x8,x9,[x0]
121 ldp x10,x11,[x1]
122 eor x8,x8,x10
123 eor x9,x9,x11
124 orr x8,x8,x9
125 mov x0,#1
126 cmp x8,#0
127 csel x0,xzr,x0,eq
128 ret
129
130.align 4
e33826f0
AP
131.Loop_cmp:
132 ldrb w4,[x0],#1
133 ldrb w5,[x1],#1
134 eor w4,w4,w5
135 orr w3,w3,w4
136 subs x2,x2,#1
137 b.ne .Loop_cmp
138
139.Lno_data:
140 neg w0,w3
141 lsr w0,w0,#31
142 ret
143.size CRYPTO_memcmp,.-CRYPTO_memcmp
9b05cbc3
AP
144___
145
146print $code;
147close STDOUT;