[CRYPTO] hifn_795x: Detect weak keys
HIFN driver update to use DES weak key checks (exported in this patch). Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
16d004a2ed
commit
c3041f9c93
@ -29,6 +29,7 @@
|
||||
#include <linux/crypto.h>
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/des.h>
|
||||
|
||||
#include <asm/kmap_types.h>
|
||||
|
||||
@ -1924,6 +1925,16 @@ static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len == HIFN_DES_KEY_LENGTH) {
|
||||
u32 tmp[DES_EXPKEY_WORDS];
|
||||
int ret = des_ekey(tmp, key);
|
||||
|
||||
if (unlikely(ret == 0) && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
dev->flags &= ~HIFN_FLAG_OLD_KEY;
|
||||
|
||||
memcpy(ctx->key, key, len);
|
||||
|
Reference in New Issue
Block a user