xref: /openbmc/linux/arch/x86/crypto/serpent-sse2.h (revision a04ea6f7)
1*a04ea6f7SArd Biesheuvel /* SPDX-License-Identifier: GPL-2.0 */
2*a04ea6f7SArd Biesheuvel #ifndef ASM_X86_SERPENT_SSE2_H
3*a04ea6f7SArd Biesheuvel #define ASM_X86_SERPENT_SSE2_H
4*a04ea6f7SArd Biesheuvel 
5*a04ea6f7SArd Biesheuvel #include <linux/crypto.h>
6*a04ea6f7SArd Biesheuvel #include <crypto/serpent.h>
7*a04ea6f7SArd Biesheuvel 
8*a04ea6f7SArd Biesheuvel #ifdef CONFIG_X86_32
9*a04ea6f7SArd Biesheuvel 
10*a04ea6f7SArd Biesheuvel #define SERPENT_PARALLEL_BLOCKS 4
11*a04ea6f7SArd Biesheuvel 
12*a04ea6f7SArd Biesheuvel asmlinkage void __serpent_enc_blk_4way(const struct serpent_ctx *ctx, u8 *dst,
13*a04ea6f7SArd Biesheuvel 				       const u8 *src, bool xor);
14*a04ea6f7SArd Biesheuvel asmlinkage void serpent_dec_blk_4way(const struct serpent_ctx *ctx, u8 *dst,
15*a04ea6f7SArd Biesheuvel 				     const u8 *src);
16*a04ea6f7SArd Biesheuvel 
serpent_enc_blk_xway(const void * ctx,u8 * dst,const u8 * src)17*a04ea6f7SArd Biesheuvel static inline void serpent_enc_blk_xway(const void *ctx, u8 *dst, const u8 *src)
18*a04ea6f7SArd Biesheuvel {
19*a04ea6f7SArd Biesheuvel 	__serpent_enc_blk_4way(ctx, dst, src, false);
20*a04ea6f7SArd Biesheuvel }
21*a04ea6f7SArd Biesheuvel 
serpent_enc_blk_xway_xor(const struct serpent_ctx * ctx,u8 * dst,const u8 * src)22*a04ea6f7SArd Biesheuvel static inline void serpent_enc_blk_xway_xor(const struct serpent_ctx *ctx,
23*a04ea6f7SArd Biesheuvel 					    u8 *dst, const u8 *src)
24*a04ea6f7SArd Biesheuvel {
25*a04ea6f7SArd Biesheuvel 	__serpent_enc_blk_4way(ctx, dst, src, true);
26*a04ea6f7SArd Biesheuvel }
27*a04ea6f7SArd Biesheuvel 
serpent_dec_blk_xway(const void * ctx,u8 * dst,const u8 * src)28*a04ea6f7SArd Biesheuvel static inline void serpent_dec_blk_xway(const void *ctx, u8 *dst, const u8 *src)
29*a04ea6f7SArd Biesheuvel {
30*a04ea6f7SArd Biesheuvel 	serpent_dec_blk_4way(ctx, dst, src);
31*a04ea6f7SArd Biesheuvel }
32*a04ea6f7SArd Biesheuvel 
33*a04ea6f7SArd Biesheuvel #else
34*a04ea6f7SArd Biesheuvel 
35*a04ea6f7SArd Biesheuvel #define SERPENT_PARALLEL_BLOCKS 8
36*a04ea6f7SArd Biesheuvel 
37*a04ea6f7SArd Biesheuvel asmlinkage void __serpent_enc_blk_8way(const struct serpent_ctx *ctx, u8 *dst,
38*a04ea6f7SArd Biesheuvel 				       const u8 *src, bool xor);
39*a04ea6f7SArd Biesheuvel asmlinkage void serpent_dec_blk_8way(const struct serpent_ctx *ctx, u8 *dst,
40*a04ea6f7SArd Biesheuvel 				     const u8 *src);
41*a04ea6f7SArd Biesheuvel 
serpent_enc_blk_xway(const void * ctx,u8 * dst,const u8 * src)42*a04ea6f7SArd Biesheuvel static inline void serpent_enc_blk_xway(const void *ctx, u8 *dst, const u8 *src)
43*a04ea6f7SArd Biesheuvel {
44*a04ea6f7SArd Biesheuvel 	__serpent_enc_blk_8way(ctx, dst, src, false);
45*a04ea6f7SArd Biesheuvel }
46*a04ea6f7SArd Biesheuvel 
serpent_enc_blk_xway_xor(const struct serpent_ctx * ctx,u8 * dst,const u8 * src)47*a04ea6f7SArd Biesheuvel static inline void serpent_enc_blk_xway_xor(const struct serpent_ctx *ctx,
48*a04ea6f7SArd Biesheuvel 					    u8 *dst, const u8 *src)
49*a04ea6f7SArd Biesheuvel {
50*a04ea6f7SArd Biesheuvel 	__serpent_enc_blk_8way(ctx, dst, src, true);
51*a04ea6f7SArd Biesheuvel }
52*a04ea6f7SArd Biesheuvel 
serpent_dec_blk_xway(const void * ctx,u8 * dst,const u8 * src)53*a04ea6f7SArd Biesheuvel static inline void serpent_dec_blk_xway(const void *ctx, u8 *dst, const u8 *src)
54*a04ea6f7SArd Biesheuvel {
55*a04ea6f7SArd Biesheuvel 	serpent_dec_blk_8way(ctx, dst, src);
56*a04ea6f7SArd Biesheuvel }
57*a04ea6f7SArd Biesheuvel 
58*a04ea6f7SArd Biesheuvel #endif
59*a04ea6f7SArd Biesheuvel 
60*a04ea6f7SArd Biesheuvel #endif
61