aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2019-08-15 05:00:53 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-08-22 00:39:40 -0400
commitf4ed68609798211f6503e66d7d371230ea18cf14 (patch)
tree4d7734de60b3b40709267d2dc9c6d14ccc37d060 /drivers/crypto
parent00cd6b233fc89463d4f4eddeb9abf1e009cc09c0 (diff)
crypto: hifn/des - switch to new verification routines
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/hifn_795x.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 5c3f02e4aece..a18e62df68d9 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -21,7 +21,7 @@
21#include <linux/ktime.h> 21#include <linux/ktime.h>
22 22
23#include <crypto/algapi.h> 23#include <crypto/algapi.h>
24#include <crypto/des.h> 24#include <crypto/internal/des.h>
25 25
26static char hifn_pll_ref[sizeof("extNNN")] = "ext"; 26static char hifn_pll_ref[sizeof("extNNN")] = "ext";
27module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444); 27module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
@@ -1939,25 +1939,13 @@ static void hifn_flush(struct hifn_device *dev)
1939static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key, 1939static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
1940 unsigned int len) 1940 unsigned int len)
1941{ 1941{
1942 struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 1942 struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher);
1943 struct hifn_context *ctx = crypto_tfm_ctx(tfm);
1944 struct hifn_device *dev = ctx->dev; 1943 struct hifn_device *dev = ctx->dev;
1944 int err;
1945 1945
1946 if (len > HIFN_MAX_CRYPT_KEY_LENGTH) { 1946 err = verify_ablkcipher_des_key(cipher, key);
1947 crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); 1947 if (err)
1948 return -1; 1948 return err;
1949 }
1950
1951 if (len == HIFN_DES_KEY_LENGTH) {
1952 u32 tmp[DES_EXPKEY_WORDS];
1953 int ret = des_ekey(tmp, key);
1954
1955 if (unlikely(ret == 0) &&
1956 (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
1957 tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
1958 return -EINVAL;
1959 }
1960 }
1961 1949
1962 dev->flags &= ~HIFN_FLAG_OLD_KEY; 1950 dev->flags &= ~HIFN_FLAG_OLD_KEY;
1963 1951
@@ -1972,15 +1960,11 @@ static int hifn_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
1972{ 1960{
1973 struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher); 1961 struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher);
1974 struct hifn_device *dev = ctx->dev; 1962 struct hifn_device *dev = ctx->dev;
1975 u32 flags;
1976 int err; 1963 int err;
1977 1964
1978 flags = crypto_ablkcipher_get_flags(cipher); 1965 err = verify_ablkcipher_des3_key(cipher, key);
1979 err = __des3_verify_key(&flags, key); 1966 if (err)
1980 if (unlikely(err)) {
1981 crypto_ablkcipher_set_flags(cipher, flags);
1982 return err; 1967 return err;
1983 }
1984 1968
1985 dev->flags &= ~HIFN_FLAG_OLD_KEY; 1969 dev->flags &= ~HIFN_FLAG_OLD_KEY;
1986 1970