| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Glue Code for 3-way parallel assembler optimized version of Twofish |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|---|
| 19 | | - * USA |
|---|
| 20 | | - * |
|---|
| 21 | 6 | */ |
|---|
| 22 | 7 | |
|---|
| 23 | 8 | #include <asm/crypto/glue_helper.h> |
|---|
| .. | .. |
|---|
| 40 | 25 | return twofish_setkey(&tfm->base, key, keylen); |
|---|
| 41 | 26 | } |
|---|
| 42 | 27 | |
|---|
| 43 | | -static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst, |
|---|
| 44 | | - const u8 *src) |
|---|
| 28 | +static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src) |
|---|
| 45 | 29 | { |
|---|
| 46 | 30 | __twofish_enc_blk_3way(ctx, dst, src, false); |
|---|
| 47 | 31 | } |
|---|
| 48 | 32 | |
|---|
| 49 | | -static inline void twofish_enc_blk_xor_3way(struct twofish_ctx *ctx, u8 *dst, |
|---|
| 33 | +static inline void twofish_enc_blk_xor_3way(const void *ctx, u8 *dst, |
|---|
| 50 | 34 | const u8 *src) |
|---|
| 51 | 35 | { |
|---|
| 52 | 36 | __twofish_enc_blk_3way(ctx, dst, src, true); |
|---|
| 53 | 37 | } |
|---|
| 54 | 38 | |
|---|
| 55 | | -void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src) |
|---|
| 39 | +void twofish_dec_blk_cbc_3way(const void *ctx, u8 *d, const u8 *s) |
|---|
| 56 | 40 | { |
|---|
| 57 | 41 | u128 ivs[2]; |
|---|
| 42 | + u128 *dst = (u128 *)d; |
|---|
| 43 | + const u128 *src = (const u128 *)s; |
|---|
| 58 | 44 | |
|---|
| 59 | 45 | ivs[0] = src[0]; |
|---|
| 60 | 46 | ivs[1] = src[1]; |
|---|
| .. | .. |
|---|
| 66 | 52 | } |
|---|
| 67 | 53 | EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); |
|---|
| 68 | 54 | |
|---|
| 69 | | -void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) |
|---|
| 55 | +void twofish_enc_blk_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) |
|---|
| 70 | 56 | { |
|---|
| 71 | 57 | be128 ctrblk; |
|---|
| 58 | + u128 *dst = (u128 *)d; |
|---|
| 59 | + const u128 *src = (const u128 *)s; |
|---|
| 72 | 60 | |
|---|
| 73 | 61 | if (dst != src) |
|---|
| 74 | 62 | *dst = *src; |
|---|
| .. | .. |
|---|
| 81 | 69 | } |
|---|
| 82 | 70 | EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr); |
|---|
| 83 | 71 | |
|---|
| 84 | | -void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, |
|---|
| 85 | | - le128 *iv) |
|---|
| 72 | +void twofish_enc_blk_ctr_3way(const void *ctx, u8 *d, const u8 *s, le128 *iv) |
|---|
| 86 | 73 | { |
|---|
| 87 | 74 | be128 ctrblks[3]; |
|---|
| 75 | + u128 *dst = (u128 *)d; |
|---|
| 76 | + const u128 *src = (const u128 *)s; |
|---|
| 88 | 77 | |
|---|
| 89 | 78 | if (dst != src) { |
|---|
| 90 | 79 | dst[0] = src[0]; |
|---|
| .. | .. |
|---|
| 109 | 98 | |
|---|
| 110 | 99 | .funcs = { { |
|---|
| 111 | 100 | .num_blocks = 3, |
|---|
| 112 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) } |
|---|
| 101 | + .fn_u = { .ecb = twofish_enc_blk_3way } |
|---|
| 113 | 102 | }, { |
|---|
| 114 | 103 | .num_blocks = 1, |
|---|
| 115 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) } |
|---|
| 104 | + .fn_u = { .ecb = twofish_enc_blk } |
|---|
| 116 | 105 | } } |
|---|
| 117 | 106 | }; |
|---|
| 118 | 107 | |
|---|
| .. | .. |
|---|
| 122 | 111 | |
|---|
| 123 | 112 | .funcs = { { |
|---|
| 124 | 113 | .num_blocks = 3, |
|---|
| 125 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr_3way) } |
|---|
| 114 | + .fn_u = { .ctr = twofish_enc_blk_ctr_3way } |
|---|
| 126 | 115 | }, { |
|---|
| 127 | 116 | .num_blocks = 1, |
|---|
| 128 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr) } |
|---|
| 117 | + .fn_u = { .ctr = twofish_enc_blk_ctr } |
|---|
| 129 | 118 | } } |
|---|
| 130 | 119 | }; |
|---|
| 131 | 120 | |
|---|
| .. | .. |
|---|
| 135 | 124 | |
|---|
| 136 | 125 | .funcs = { { |
|---|
| 137 | 126 | .num_blocks = 3, |
|---|
| 138 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) } |
|---|
| 127 | + .fn_u = { .ecb = twofish_dec_blk_3way } |
|---|
| 139 | 128 | }, { |
|---|
| 140 | 129 | .num_blocks = 1, |
|---|
| 141 | | - .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) } |
|---|
| 130 | + .fn_u = { .ecb = twofish_dec_blk } |
|---|
| 142 | 131 | } } |
|---|
| 143 | 132 | }; |
|---|
| 144 | 133 | |
|---|
| .. | .. |
|---|
| 148 | 137 | |
|---|
| 149 | 138 | .funcs = { { |
|---|
| 150 | 139 | .num_blocks = 3, |
|---|
| 151 | | - .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) } |
|---|
| 140 | + .fn_u = { .cbc = twofish_dec_blk_cbc_3way } |
|---|
| 152 | 141 | }, { |
|---|
| 153 | 142 | .num_blocks = 1, |
|---|
| 154 | | - .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) } |
|---|
| 143 | + .fn_u = { .cbc = twofish_dec_blk } |
|---|
| 155 | 144 | } } |
|---|
| 156 | 145 | }; |
|---|
| 157 | 146 | |
|---|
| .. | .. |
|---|
| 167 | 156 | |
|---|
| 168 | 157 | static int cbc_encrypt(struct skcipher_request *req) |
|---|
| 169 | 158 | { |
|---|
| 170 | | - return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(twofish_enc_blk), |
|---|
| 171 | | - req); |
|---|
| 159 | + return glue_cbc_encrypt_req_128bit(twofish_enc_blk, req); |
|---|
| 172 | 160 | } |
|---|
| 173 | 161 | |
|---|
| 174 | 162 | static int cbc_decrypt(struct skcipher_request *req) |
|---|