6
6
*/
7
7
#include <asm/switch_to.h>
8
8
#include <crypto/internal/poly1305.h>
9
- #include <crypto/internal/simd.h>
10
9
#include <linux/cpufeature.h>
11
10
#include <linux/jump_label.h>
12
11
#include <linux/kernel.h>
@@ -19,11 +18,6 @@ asmlinkage void poly1305_emit_64(const struct poly1305_state *state, const u32 n
19
18
20
19
static __ro_after_init DEFINE_STATIC_KEY_FALSE (have_p10 );
21
20
22
- static inline bool is_state_base64 (struct poly1305_block_state * state )
23
- {
24
- return state -> core_r .precomputed_s .r64 [2 ];
25
- }
26
-
27
21
static void vsx_begin (void )
28
22
{
29
23
preempt_disable ();
@@ -36,35 +30,12 @@ static void vsx_end(void)
36
30
preempt_enable ();
37
31
}
38
32
39
- static void convert_to_base2_44 (struct poly1305_block_state * state )
40
- {
41
- u8 raw_key [POLY1305_BLOCK_SIZE ];
42
- u64 h0 , h1 , h2 ;
43
-
44
- if (!is_state_base64 (state ))
45
- return ;
46
-
47
- state -> core_r .precomputed_s .r64 [2 ] = 0 ;
48
- put_unaligned_le64 (state -> core_r .key .r64 [0 ], raw_key + 0 );
49
- put_unaligned_le64 (state -> core_r .key .r64 [1 ], raw_key + 8 );
50
- poly1305_core_setkey (& state -> core_r , raw_key );
51
-
52
- h0 = state -> h .h64 [0 ];
53
- h1 = state -> h .h64 [1 ];
54
- h2 = state -> h .h64 [2 ];
55
- state -> h .h64 [0 ] = h0 & 0xfffffffffffULL ;
56
- state -> h .h64 [1 ] = h0 >> 44 | (h1 & 0xffffffULL ) << 20 ;
57
- state -> h .h64 [2 ] = h1 >> 24 | h2 << 40 ;
58
- }
59
-
60
33
void poly1305_block_init_arch (struct poly1305_block_state * dctx ,
61
34
const u8 raw_key [POLY1305_BLOCK_SIZE ])
62
35
{
63
- dctx -> core_r .precomputed_s .r64 [2 ] = 0 ;
64
- if (!static_key_enabled (& have_p10 ) || !crypto_simd_usable ())
36
+ if (!static_key_enabled (& have_p10 ))
65
37
return poly1305_block_init_generic (dctx , raw_key );
66
38
67
- dctx -> core_r .precomputed_s .r64 [2 ] = 1 ;
68
39
dctx -> h = (struct poly1305_state ){};
69
40
dctx -> core_r .key .r64 [0 ] = get_unaligned_le64 (raw_key + 0 );
70
41
dctx -> core_r .key .r64 [1 ] = get_unaligned_le64 (raw_key + 8 );
@@ -74,11 +45,8 @@ EXPORT_SYMBOL_GPL(poly1305_block_init_arch);
74
45
void poly1305_blocks_arch (struct poly1305_block_state * state , const u8 * src ,
75
46
unsigned int len , u32 padbit )
76
47
{
77
- if (!static_key_enabled (& have_p10 ) || !is_state_base64 (state ) ||
78
- !crypto_simd_usable ()) {
79
- convert_to_base2_44 (state );
48
+ if (!static_key_enabled (& have_p10 ))
80
49
return poly1305_blocks_generic (state , src , len , padbit );
81
- }
82
50
vsx_begin ();
83
51
if (len >= POLY1305_BLOCK_SIZE * 4 ) {
84
52
poly1305_p10le_4blocks (state , src , len );
@@ -98,10 +66,7 @@ void poly1305_emit_arch(const struct poly1305_state *state,
98
66
u8 digest [POLY1305_DIGEST_SIZE ],
99
67
const u32 nonce [4 ])
100
68
{
101
- struct poly1305_block_state * dctx =
102
- container_of (state , struct poly1305_block_state , h );
103
-
104
- if (!static_key_enabled (& have_p10 ) || !is_state_base64 (dctx ))
69
+ if (!static_key_enabled (& have_p10 ))
105
70
return poly1305_emit_generic (state , digest , nonce );
106
71
poly1305_emit_64 (state , nonce , digest );
107
72
}
0 commit comments