Add master DRBG for reseeding
[openssl.git] / crypto / arm64cpuid.pl
1 #! /usr/bin/env perl
2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
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
8
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
16 die "can't locate arm-xlate.pl";
17
18 open OUT,"| \"$^X\" $xlate $flavour $output";
19 *STDOUT=*OUT;
20
21 $code.=<<___;
22 #include "arm_arch.h"
23
24 .text
25 .arch   armv8-a+crypto
26
27 .align  5
28 .globl  _armv7_neon_probe
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
35 .globl  _armv7_tick
36 .type   _armv7_tick,%function
37 _armv7_tick:
38 #ifdef  __APPLE__
39         mrs     x0, CNTPCT_EL0
40 #else
41         mrs     x0, CNTVCT_EL0
42 #endif
43         ret
44 .size   _armv7_tick,.-_armv7_tick
45
46 .globl  _armv8_aes_probe
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
53 .globl  _armv8_sha1_probe
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
60 .globl  _armv8_sha256_probe
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
66 .globl  _armv8_pmull_probe
67 .type   _armv8_pmull_probe,%function
68 _armv8_pmull_probe:
69         pmull   v0.1q, v0.1d, v0.1d
70         ret
71 .size   _armv8_pmull_probe,.-_armv8_pmull_probe
72
73 .globl  OPENSSL_cleanse
74 .type   OPENSSL_cleanse,%function
75 .align  5
76 OPENSSL_cleanse:
77         cbz     x1,.Lret        // len==0?
78         cmp     x1,#15
79         b.hi    .Lot            // len>15
80         nop
81 .Little:
82         strb    wzr,[x0],#1     // store byte-by-byte
83         subs    x1,x1,#1
84         b.ne    .Little
85 .Lret:  ret
86
87 .align  4
88 .Lot:   tst     x0,#7
89         b.eq    .Laligned       // inp is aligned
90         strb    wzr,[x0],#1     // store byte-by-byte
91         sub     x1,x1,#1
92         b       .Lot
93
94 .align  4
95 .Laligned:
96         str     xzr,[x0],#8     // store word-by-word
97         sub     x1,x1,#8
98         tst     x1,#-8
99         b.ne    .Laligned       // len>=8
100         cbnz    x1,.Little      // len!=0?
101         ret
102 .size   OPENSSL_cleanse,.-OPENSSL_cleanse
103
104 .globl  CRYPTO_memcmp
105 .type   CRYPTO_memcmp,%function
106 .align  4
107 CRYPTO_memcmp:
108         eor     w3,w3,w3
109         cbz     x2,.Lno_data    // len==0?
110 .Loop_cmp:
111         ldrb    w4,[x0],#1
112         ldrb    w5,[x1],#1
113         eor     w4,w4,w5
114         orr     w3,w3,w4
115         subs    x2,x2,#1
116         b.ne    .Loop_cmp
117
118 .Lno_data:
119         neg     w0,w3
120         lsr     w0,w0,#31
121         ret
122 .size   CRYPTO_memcmp,.-CRYPTO_memcmp
123 ___
124
125 print $code;
126 close STDOUT;