Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|---|
| 2 | /* |
| 3 | * SHA-1 optimized for ARM64 |
| 4 | * |
| 5 | * Copyright 2025 Google LLC |
| 6 | */ |
| 7 | #include <asm/simd.h> |
| 8 | #include <linux/cpufeature.h> |
| 9 | |
| 10 | static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_ce); |
| 11 | |
| 12 | asmlinkage size_t __sha1_ce_transform(struct sha1_block_state *state, |
| 13 | const u8 *data, size_t nblocks); |
| 14 | |
| 15 | static void sha1_blocks(struct sha1_block_state *state, |
| 16 | const u8 *data, size_t nblocks) |
| 17 | { |
| 18 | if (static_branch_likely(&have_ce) && likely(may_use_simd())) { |
| 19 | do { |
| 20 | size_t rem; |
| 21 | |
| 22 | scoped_ksimd() |
| 23 | rem = __sha1_ce_transform(state, data, nblocks); |
| 24 | |
| 25 | data += (nblocks - rem) * SHA1_BLOCK_SIZE; |
| 26 | nblocks = rem; |
| 27 | } while (nblocks); |
| 28 | } else { |
| 29 | sha1_blocks_generic(state, data, nblocks); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | #define sha1_mod_init_arch sha1_mod_init_arch |
| 34 | static void sha1_mod_init_arch(void) |
| 35 | { |
| 36 | if (cpu_have_named_feature(SHA1)) |
| 37 | static_branch_enable(&have_ce); |
| 38 | } |
| 39 |
Warning: This file is not a C or C++ file. It does not have highlighting.
