| .. | .. |
|---|
| 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; |
|---|
| 49 | + bool fpu_enabled = false; |
|---|
| 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(false, &walk, nbytes); |
|---|
| 64 | + fpu_enabled = cast5_fpu_begin(fpu_enabled, &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: |
|---|
| 108 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 109 | 93 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 110 | 94 | } |
|---|
| 95 | + |
|---|
| 96 | + cast5_fpu_end(fpu_enabled); |
|---|
| 111 | 97 | return err; |
|---|
| 112 | 98 | } |
|---|
| 113 | 99 | |
|---|
| .. | .. |
|---|
| 211 | 197 | { |
|---|
| 212 | 198 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
|---|
| 213 | 199 | struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 214 | | - bool fpu_enabled; |
|---|
| 200 | + bool fpu_enabled = false; |
|---|
| 215 | 201 | struct skcipher_walk walk; |
|---|
| 216 | 202 | unsigned int nbytes; |
|---|
| 217 | 203 | int err; |
|---|
| .. | .. |
|---|
| 219 | 205 | err = skcipher_walk_virt(&walk, req, false); |
|---|
| 220 | 206 | |
|---|
| 221 | 207 | while ((nbytes = walk.nbytes)) { |
|---|
| 222 | | - fpu_enabled = cast5_fpu_begin(false, &walk, nbytes); |
|---|
| 208 | + fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes); |
|---|
| 223 | 209 | nbytes = __cbc_decrypt(ctx, &walk); |
|---|
| 224 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 225 | 210 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 226 | 211 | } |
|---|
| 212 | + |
|---|
| 213 | + cast5_fpu_end(fpu_enabled); |
|---|
| 227 | 214 | return err; |
|---|
| 228 | 215 | } |
|---|
| 229 | 216 | |
|---|
| .. | .. |
|---|
| 290 | 277 | { |
|---|
| 291 | 278 | struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
|---|
| 292 | 279 | struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm); |
|---|
| 293 | | - bool fpu_enabled; |
|---|
| 280 | + bool fpu_enabled = false; |
|---|
| 294 | 281 | struct skcipher_walk walk; |
|---|
| 295 | 282 | unsigned int nbytes; |
|---|
| 296 | 283 | int err; |
|---|
| .. | .. |
|---|
| 298 | 285 | err = skcipher_walk_virt(&walk, req, false); |
|---|
| 299 | 286 | |
|---|
| 300 | 287 | while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) { |
|---|
| 301 | | - fpu_enabled = cast5_fpu_begin(false, &walk, nbytes); |
|---|
| 288 | + fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes); |
|---|
| 302 | 289 | nbytes = __ctr_crypt(&walk, ctx); |
|---|
| 303 | | - cast5_fpu_end(fpu_enabled); |
|---|
| 304 | 290 | err = skcipher_walk_done(&walk, nbytes); |
|---|
| 305 | 291 | } |
|---|
| 306 | 292 | |
|---|
| 293 | + cast5_fpu_end(fpu_enabled); |
|---|
| 294 | + |
|---|
| 307 | 295 | if (walk.nbytes) { |
|---|
| 308 | 296 | ctr_crypt_final(&walk, ctx); |
|---|
| 309 | 297 | err = skcipher_walk_done(&walk, 0); |
|---|