1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
/*===---- riscv_crypto.h - RISC-V Zk* intrinsics ---------------------------===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
*===-----------------------------------------------------------------------===
*/
#ifndef __RISCV_CRYPTO_H
#define __RISCV_CRYPTO_H
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__riscv_zknd)
#if __riscv_xlen == 32
#define __riscv_aes32dsi(x, y, bs) __builtin_riscv_aes32dsi(x, y, bs)
#define __riscv_aes32dsmi(x, y, bs) __builtin_riscv_aes32dsmi(x, y, bs)
#endif
#if __riscv_xlen == 64
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64ds(uint64_t __x, uint64_t __y) {
return __builtin_riscv_aes64ds(__x, __y);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64dsm(uint64_t __x, uint64_t __y) {
return __builtin_riscv_aes64dsm(__x, __y);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64im(uint64_t __x) {
return __builtin_riscv_aes64im(__x);
}
#endif
#endif // defined(__riscv_zknd)
#if defined(__riscv_zkne)
#if __riscv_xlen == 32
#define __riscv_aes32esi(x, y, bs) __builtin_riscv_aes32esi(x, y, bs)
#define __riscv_aes32esmi(x, y, bs) __builtin_riscv_aes32esmi(x, y, bs)
#endif
#if __riscv_xlen == 64
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64es(uint64_t __x, uint64_t __y) {
return __builtin_riscv_aes64es(__x, __y);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64esm(uint64_t __x, uint64_t __y) {
return __builtin_riscv_aes64esm(__x, __y);
}
#endif
#endif // defined(__riscv_zkne)
#if defined(__riscv_zknd) || defined(__riscv_zkne)
#if __riscv_xlen == 64
#define __riscv_aes64ks1i(x, rnum) __builtin_riscv_aes64ks1i(x, rnum)
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_aes64ks2(uint64_t __x, uint64_t __y) {
return __builtin_riscv_aes64ks2(__x, __y);
}
#endif
#endif // defined(__riscv_zknd) || defined(__riscv_zkne)
#if defined(__riscv_zknh)
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha256sig0(uint32_t __x) {
return __builtin_riscv_sha256sig0(__x);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha256sig1(uint32_t __x) {
return __builtin_riscv_sha256sig1(__x);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha256sum0(uint32_t __x) {
return __builtin_riscv_sha256sum0(__x);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha256sum1(uint32_t __x) {
return __builtin_riscv_sha256sum1(__x);
}
#if __riscv_xlen == 32
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig0h(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sig0h(__x, __y);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig0l(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sig0l(__x, __y);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig1h(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sig1h(__x, __y);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig1l(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sig1l(__x, __y);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sum0r(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sum0r(__x, __y);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sum1r(uint32_t __x, uint32_t __y) {
return __builtin_riscv_sha512sum1r(__x, __y);
}
#endif
#if __riscv_xlen == 64
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig0(uint64_t __x) {
return __builtin_riscv_sha512sig0(__x);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sig1(uint64_t __x) {
return __builtin_riscv_sha512sig1(__x);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sum0(uint64_t __x) {
return __builtin_riscv_sha512sum0(__x);
}
static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
__riscv_sha512sum1(uint64_t __x) {
return __builtin_riscv_sha512sum1(__x);
}
#endif
#endif // defined(__riscv_zknh)
#if defined(__riscv_zksh)
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sm3p0(uint32_t __x) {
return __builtin_riscv_sm3p0(__x);
}
static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
__riscv_sm3p1(uint32_t __x) {
return __builtin_riscv_sm3p1(__x);
}
#endif // defined(__riscv_zksh)
#if defined(__riscv_zksed)
#define __riscv_sm4ed(x, y, bs) __builtin_riscv_sm4ed(x, y, bs);
#define __riscv_sm4ks(x, y, bs) __builtin_riscv_sm4ks(x, y, bs);
#endif // defined(__riscv_zksed)
#if defined(__cplusplus)
}
#endif
#endif
|