Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ard Biesheuvel and committed by
Herbert Xu
f4ed6860 00cd6b23

+8 -24
+8 -24
drivers/crypto/hifn_795x.c
··· 21 21 #include <linux/ktime.h> 22 22 23 23 #include <crypto/algapi.h> 24 - #include <crypto/des.h> 24 + #include <crypto/internal/des.h> 25 25 26 26 static char hifn_pll_ref[sizeof("extNNN")] = "ext"; 27 27 module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444); ··· 1939 1939 static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key, 1940 1940 unsigned int len) 1941 1941 { 1942 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 1943 - struct hifn_context *ctx = crypto_tfm_ctx(tfm); 1942 + struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher); 1944 1943 struct hifn_device *dev = ctx->dev; 1944 + int err; 1945 1945 1946 - if (len > HIFN_MAX_CRYPT_KEY_LENGTH) { 1947 - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); 1948 - return -1; 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 - } 1946 + err = verify_ablkcipher_des_key(cipher, key); 1947 + if (err) 1948 + return err; 1961 1949 1962 1950 dev->flags &= ~HIFN_FLAG_OLD_KEY; 1963 1951 ··· 1960 1972 { 1961 1973 struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher); 1962 1974 struct hifn_device *dev = ctx->dev; 1963 - u32 flags; 1964 1975 int err; 1965 1976 1966 - flags = crypto_ablkcipher_get_flags(cipher); 1967 - err = __des3_verify_key(&flags, key); 1968 - if (unlikely(err)) { 1969 - crypto_ablkcipher_set_flags(cipher, flags); 1977 + err = verify_ablkcipher_des3_key(cipher, key); 1978 + if (err) 1970 1979 return err; 1971 - } 1972 1980 1973 1981 dev->flags &= ~HIFN_FLAG_OLD_KEY; 1974 1982