Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/lib/crypto/arm64/poly1305.h
49767 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
/*
3
* OpenSSL/Cryptogams accelerated Poly1305 transform for arm64
4
*
5
* Copyright (C) 2019 Linaro Ltd. <[email protected]>
6
*/
7
8
#include <asm/hwcap.h>
9
#include <asm/simd.h>
10
#include <linux/cpufeature.h>
11
#include <linux/jump_label.h>
12
#include <linux/kernel.h>
13
14
asmlinkage void poly1305_block_init(struct poly1305_block_state *state,
15
const u8 raw_key[POLY1305_BLOCK_SIZE]);
16
asmlinkage void poly1305_blocks_arm64(struct poly1305_block_state *state,
17
const u8 *src, u32 len, u32 hibit);
18
asmlinkage void poly1305_blocks_neon(struct poly1305_block_state *state,
19
const u8 *src, u32 len, u32 hibit);
20
asmlinkage void poly1305_emit(const struct poly1305_state *state,
21
u8 digest[POLY1305_DIGEST_SIZE],
22
const u32 nonce[4]);
23
24
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
25
26
static void poly1305_blocks(struct poly1305_block_state *state, const u8 *src,
27
unsigned int len, u32 padbit)
28
{
29
if (static_branch_likely(&have_neon) && likely(may_use_simd())) {
30
do {
31
unsigned int todo = min_t(unsigned int, len, SZ_4K);
32
33
scoped_ksimd()
34
poly1305_blocks_neon(state, src, todo, padbit);
35
36
len -= todo;
37
src += todo;
38
} while (len);
39
} else
40
poly1305_blocks_arm64(state, src, len, padbit);
41
}
42
43
#define poly1305_mod_init_arch poly1305_mod_init_arch
44
static void poly1305_mod_init_arch(void)
45
{
46
if (cpu_have_named_feature(ASIMD))
47
static_branch_enable(&have_neon);
48
}
49
50