1 /* 2 * Copyright (c) 2019 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 // #include <Availability.h> 29 #include <sys/cdefs.h> 30 31 #if defined(__clang__) && ((defined(__apple_build_version__) && __apple_build_version__ > 5010000)) 32 #define __USES_V_CRYPTO_INTRINSICS 1 33 #else 34 #define __USES_V_CRYPTO_INTRINSICS 0 35 #endif 36 37 38 // AES INSTRUCTIONS 39 // aese.16b v0, v1 40 // aesd.16b v0, v1 41 // aesmc.16b v0, v1 42 // aesimc.16b v0, v1 43 44 // SHA1 INTRINSICS 45 // sha1su0.4s v0, v1, v2 46 // sha1su1.4s v0, v1 47 // sha1c.4s v0, v1, v2 // or q0, s1, v2.4s 48 // sha1m.4s v0, v1, v2 // or q0, s1, v2.4s 49 // sha1p.4s v0, v1, v2 // or q0, s1, v2.4s 50 // sha1h.4s v0, v1 // or s0, s1 51 52 // SHA256 INTRINSICS 53 // sha256su0.4s v0, v1 54 // sha256su1.4s v0, v1, v2 55 // sha256h.4s v0, v1, v2 // or q0, q1, v2.4s 56 // sha256h2.4s v0, v1, v2 // or q0, q1, v2.4s 57 58 59 #if __USES_V_CRYPTO_INTRINSICS == 1 60 .macro AESE 61 aese.16b v$0, v$1 62 .endm 63 64 .macro AESD 65 aesd.16b v$0, v$1 66 .endm 67 68 .macro AESMC 69 aesmc.16b v$0, v$1 70 .endm 71 72 .macro AESIMC 73 aesimc.16b v$0, v$1 74 .endm 75 76 77 #else 78 79 .macro AESE 80 aese q$0, q$1 81 .endm 82 83 .macro AESD 84 aesd q$0, q$1 85 .endm 86 87 .macro AESMC 88 aesmc q$0, q$1 89 .endm 90 91 .macro AESIMC 92 aesimc q$0, q$1 93 .endm 94 95 #endif 96 97 #if __USES_V_CRYPTO_INTRINSICS == 1 98 99 .macro SHA1SU0 100 sha1su0 v$0.4s, v$1.4s, v$2.4s 101 .endm 102 103 .macro SHA1SU1 104 sha1su1 v$0.4s, v$1.4s 105 .endm 106 107 .macro SHA1C 108 sha1c q$0, s$1, v$2.4s 109 .endm 110 111 .macro SHA1M 112 sha1m q$0, s$1, v$2.4s 113 .endm 114 115 .macro SHA1P 116 sha1p q$0, s$1, v$2.4s 117 .endm 118 119 .macro SHA1H 120 sha1h s$0, s$1 121 .endm 122 123 .macro SHA256SU0 124 sha256su0 v$0.4s, v$1.4s 125 .endm 126 127 .macro SHA256SU1 128 sha256su1 v$0.4s, v$1.4s, v$2.4s 129 .endm 130 131 .macro SHA256H 132 sha256h q$0, q$1, v$2.4s 133 .endm 134 135 .macro SHA256H2 136 sha256h2 q$0, q$1, v$2.4s 137 .endm 138 139 #else 140 141 .macro SHA1SU0 142 sha1su0 q$0, q$1, q$2 143 .endm 144 145 .macro SHA1SU1 146 sha1su1 q$0, q$1 147 .endm 148 149 .macro SHA1C 150 sha1c q$0, q$1, q$2 151 .endm 152 153 .macro SHA1M 154 sha1m q$0, q$1, q$2 155 .endm 156 157 .macro SHA1P 158 sha1p q$0, q$1, q$2 159 .endm 160 161 .macro SHA1H 162 sha1h q$0, q$1 163 .endm 164 165 .macro SHA256SU0 166 sha256su0 q$0, q$1 167 .endm 168 169 .macro SHA256SU1 170 sha256su1 q$0, q$1, q$2 171 .endm 172 173 .macro SHA256H 174 sha256h q$0, q$1, q$2 175 .endm 176 177 .macro SHA256H2 178 sha256h2 q$0, q$1, q$2 179 .endm 180 181 #endif 182