| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | | - * Glue Code for the AVX assembler implemention of the Cast5 Cipher |
|---|
| 3 | + * Glue Code for the AVX assembler implementation of the Cast5 Cipher |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2012 Johannes Goetzfried |
|---|
| 5 | 6 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 9 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | | - * (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | | - * GNU General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|---|
| 20 | | - * USA |
|---|
| 21 | | - * |
|---|
| 22 | 7 | */ |
|---|
| 23 | 8 | |
|---|
| 24 | 9 | #include <asm/crypto/glue_helper.h> |
|---|
| .. | .. |
|---|
| 61 | 46 | |
|---|
| 62 | 47 | static int ecb_crypt(struct skcipher_request *req, bool enc) |
|---|
| 63 | 48 | { |
|---|
| 64 | | - bool fpu_enabled = false; |
|---|
| 49 | + bool fpu_enabled; |
|---|
| 65 | 50 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
|---|
| 66 | 51 | struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 67 | 52 | struct skcipher_walk walk; |
|---|
| .. | .. |
|---|
| 76 | 61 | u8 *wsrc = walk.src.virt.addr; |
|---|
| 77 | 62 | u8 *wdst = walk.dst.virt.addr; |
|---|
| 78 | 63 | |
|---|
| 79 | | - fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes); |
|---|
| 64 | + fpu_enabled = cast5_fpu_begin(false, &walk, nbytes); |
|---|
| 80 | 65 | |
|---|
| 81 | 66 | /* Process multi-block batch */ |
|---|
| 82 | 67 | if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { |
|---|
| .. | .. |
|---|
| 105 | 90 | } while (nbytes >= bsize); |
|---|
| 106 | 91 | |
|---|
| 107 | 92 | done: |
|---|
| 93 | + cast5_fpu_end(fpu_enabled); |
|---|
| 108 | 94 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 109 | 95 | } |
|---|
| 110 | | - |
|---|
| 111 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 112 | 96 | return err; |
|---|
| 113 | 97 | } |
|---|
| 114 | 98 | |
|---|
| .. | .. |
|---|
| 212 | 196 | { |
|---|
| 213 | 197 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
|---|
| 214 | 198 | struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 215 | | - bool fpu_enabled = false; |
|---|
| 199 | + bool fpu_enabled; |
|---|
| 216 | 200 | struct skcipher_walk walk; |
|---|
| 217 | 201 | unsigned int nbytes; |
|---|
| 218 | 202 | int err; |
|---|
| .. | .. |
|---|
| 220 | 204 | err = skcipher_walk_virt(&walk, req, false); |
|---|
| 221 | 205 | |
|---|
| 222 | 206 | while ((nbytes = walk.nbytes)) { |
|---|
| 223 | | - fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes); |
|---|
| 207 | + fpu_enabled = cast5_fpu_begin(false, &walk, nbytes); |
|---|
| 224 | 208 | nbytes = __cbc_decrypt(ctx, &walk); |
|---|
| 209 | + cast5_fpu_end(fpu_enabled); |
|---|
| 225 | 210 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 226 | 211 | } |
|---|
| 227 | | - |
|---|
| 228 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 229 | 212 | return err; |
|---|
| 230 | 213 | } |
|---|
| 231 | 214 | |
|---|
| .. | .. |
|---|
| 292 | 275 | { |
|---|
| 293 | 276 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
|---|
| 294 | 277 | struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 295 | | - bool fpu_enabled = false; |
|---|
| 278 | + bool fpu_enabled; |
|---|
| 296 | 279 | struct skcipher_walk walk; |
|---|
| 297 | 280 | unsigned int nbytes; |
|---|
| 298 | 281 | int err; |
|---|
| .. | .. |
|---|
| 300 | 283 | err = skcipher_walk_virt(&walk, req, false); |
|---|
| 301 | 284 | |
|---|
| 302 | 285 | while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) { |
|---|
| 303 | | - fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes); |
|---|
| 286 | + fpu_enabled = cast5_fpu_begin(false, &walk, nbytes); |
|---|
| 304 | 287 | nbytes = __ctr_crypt(&walk, ctx); |
|---|
| 288 | + cast5_fpu_end(fpu_enabled); |
|---|
| 305 | 289 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 306 | 290 | } |
|---|
| 307 | | - |
|---|
| 308 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 309 | 291 | |
|---|
| 310 | 292 | if (walk.nbytes) { |
|---|
| 311 | 293 | ctr_crypt_final(&walk, ctx); |
|---|