Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/lib/crypto/arm64/sha1.h
26285 views
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/neon.h>
8
#include <asm/simd.h>
9
#include <linux/cpufeature.h>
10
11
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_ce);
12
13
asmlinkage size_t __sha1_ce_transform(struct sha1_block_state *state,
14
const u8 *data, size_t nblocks);
15
16
static void sha1_blocks(struct sha1_block_state *state,
17
const u8 *data, size_t nblocks)
18
{
19
if (static_branch_likely(&have_ce) && likely(may_use_simd())) {
20
do {
21
size_t rem;
22
23
kernel_neon_begin();
24
rem = __sha1_ce_transform(state, data, nblocks);
25
kernel_neon_end();
26
data += (nblocks - rem) * SHA1_BLOCK_SIZE;
27
nblocks = rem;
28
} while (nblocks);
29
} else {
30
sha1_blocks_generic(state, data, nblocks);
31
}
32
}
33
34
#define sha1_mod_init_arch sha1_mod_init_arch
35
static inline void sha1_mod_init_arch(void)
36
{
37
if (cpu_have_named_feature(SHA1))
38
static_branch_enable(&have_ce);
39
}
40
41