| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* Copyright (C) 2004-2006, Advanced Micro Devices, Inc. |
|---|
| 2 | | - * |
|---|
| 3 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 4 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 5 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 6 | | - * (at your option) any later version. |
|---|
| 7 | 3 | */ |
|---|
| 8 | 4 | |
|---|
| 9 | 5 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 14 | 10 | #include <linux/spinlock.h> |
|---|
| 15 | 11 | #include <crypto/algapi.h> |
|---|
| 16 | 12 | #include <crypto/aes.h> |
|---|
| 13 | +#include <crypto/internal/cipher.h> |
|---|
| 17 | 14 | #include <crypto/internal/skcipher.h> |
|---|
| 18 | 15 | |
|---|
| 19 | 16 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 114 | 111 | unsigned int len) |
|---|
| 115 | 112 | { |
|---|
| 116 | 113 | struct geode_aes_tfm_ctx *tctx = crypto_tfm_ctx(tfm); |
|---|
| 117 | | - unsigned int ret; |
|---|
| 118 | 114 | |
|---|
| 119 | 115 | tctx->keylen = len; |
|---|
| 120 | 116 | |
|---|
| .. | .. |
|---|
| 123 | 119 | return 0; |
|---|
| 124 | 120 | } |
|---|
| 125 | 121 | |
|---|
| 126 | | - if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) { |
|---|
| 122 | + if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) |
|---|
| 127 | 123 | /* not supported at all */ |
|---|
| 128 | | - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
|---|
| 129 | 124 | return -EINVAL; |
|---|
| 130 | | - } |
|---|
| 131 | 125 | |
|---|
| 132 | 126 | /* |
|---|
| 133 | 127 | * The requested key size is not supported by HW, do a fallback |
|---|
| .. | .. |
|---|
| 136 | 130 | tctx->fallback.cip->base.crt_flags |= |
|---|
| 137 | 131 | (tfm->crt_flags & CRYPTO_TFM_REQ_MASK); |
|---|
| 138 | 132 | |
|---|
| 139 | | - ret = crypto_cipher_setkey(tctx->fallback.cip, key, len); |
|---|
| 140 | | - if (ret) { |
|---|
| 141 | | - tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; |
|---|
| 142 | | - tfm->crt_flags |= (tctx->fallback.cip->base.crt_flags & |
|---|
| 143 | | - CRYPTO_TFM_RES_MASK); |
|---|
| 144 | | - } |
|---|
| 145 | | - return ret; |
|---|
| 133 | + return crypto_cipher_setkey(tctx->fallback.cip, key, len); |
|---|
| 146 | 134 | } |
|---|
| 147 | 135 | |
|---|
| 148 | 136 | static int geode_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, |
|---|
| 149 | 137 | unsigned int len) |
|---|
| 150 | 138 | { |
|---|
| 151 | 139 | struct geode_aes_tfm_ctx *tctx = crypto_skcipher_ctx(tfm); |
|---|
| 152 | | - unsigned int ret; |
|---|
| 153 | 140 | |
|---|
| 154 | 141 | tctx->keylen = len; |
|---|
| 155 | 142 | |
|---|
| .. | .. |
|---|
| 158 | 145 | return 0; |
|---|
| 159 | 146 | } |
|---|
| 160 | 147 | |
|---|
| 161 | | - if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) { |
|---|
| 148 | + if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) |
|---|
| 162 | 149 | /* not supported at all */ |
|---|
| 163 | | - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
|---|
| 164 | 150 | return -EINVAL; |
|---|
| 165 | | - } |
|---|
| 166 | 151 | |
|---|
| 167 | 152 | /* |
|---|
| 168 | 153 | * The requested key size is not supported by HW, do a fallback |
|---|
| .. | .. |
|---|
| 172 | 157 | crypto_skcipher_set_flags(tctx->fallback.skcipher, |
|---|
| 173 | 158 | crypto_skcipher_get_flags(tfm) & |
|---|
| 174 | 159 | CRYPTO_TFM_REQ_MASK); |
|---|
| 175 | | - ret = crypto_skcipher_setkey(tctx->fallback.skcipher, key, len); |
|---|
| 176 | | - crypto_skcipher_set_flags(tfm, |
|---|
| 177 | | - crypto_skcipher_get_flags(tctx->fallback.skcipher) & |
|---|
| 178 | | - CRYPTO_TFM_RES_MASK); |
|---|
| 179 | | - return ret; |
|---|
| 160 | + return crypto_skcipher_setkey(tctx->fallback.skcipher, key, len); |
|---|
| 180 | 161 | } |
|---|
| 181 | 162 | |
|---|
| 182 | 163 | static void |
|---|
| .. | .. |
|---|
| 454 | 435 | MODULE_AUTHOR("Advanced Micro Devices, Inc."); |
|---|
| 455 | 436 | MODULE_DESCRIPTION("Geode LX Hardware AES driver"); |
|---|
| 456 | 437 | MODULE_LICENSE("GPL"); |
|---|
| 438 | +MODULE_IMPORT_NS(CRYPTO_INTERNAL); |
|---|