crypto: n2/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>
This commit is contained in:
		
							parent
							
								
									9bfa85ebd5
								
							
						
					
					
						commit
						d4b90dbc85
					
				| @ -17,7 +17,7 @@ | |||||||
| #include <crypto/md5.h> | #include <crypto/md5.h> | ||||||
| #include <crypto/sha.h> | #include <crypto/sha.h> | ||||||
| #include <crypto/aes.h> | #include <crypto/aes.h> | ||||||
| #include <crypto/des.h> | #include <crypto/internal/des.h> | ||||||
| #include <linux/mutex.h> | #include <linux/mutex.h> | ||||||
| #include <linux/delay.h> | #include <linux/delay.h> | ||||||
| #include <linux/sched.h> | #include <linux/sched.h> | ||||||
| @ -757,25 +757,16 @@ static int n2_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | |||||||
| static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | ||||||
| 			 unsigned int keylen) | 			 unsigned int keylen) | ||||||
| { | { | ||||||
| 	struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); | 	struct n2_cipher_context *ctx = crypto_ablkcipher_ctx(cipher); | ||||||
| 	struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); |  | ||||||
| 	struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); | 	struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); | ||||||
| 	u32 tmp[DES_EXPKEY_WORDS]; |  | ||||||
| 	int err; | 	int err; | ||||||
| 
 | 
 | ||||||
|  | 	err = verify_ablkcipher_des_key(cipher, key); | ||||||
|  | 	if (err) | ||||||
|  | 		return err; | ||||||
|  | 
 | ||||||
| 	ctx->enc_type = n2alg->enc_type; | 	ctx->enc_type = n2alg->enc_type; | ||||||
| 
 | 
 | ||||||
| 	if (keylen != DES_KEY_SIZE) { |  | ||||||
| 		crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |  | ||||||
| 		return -EINVAL; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	err = des_ekey(tmp, key); |  | ||||||
| 	if (err == 0 && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { |  | ||||||
| 		tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; |  | ||||||
| 		return -EINVAL; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	ctx->key_len = keylen; | 	ctx->key_len = keylen; | ||||||
| 	memcpy(ctx->key.des, key, keylen); | 	memcpy(ctx->key.des, key, keylen); | ||||||
| 	return 0; | 	return 0; | ||||||
| @ -784,18 +775,13 @@ static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | |||||||
| static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, | ||||||
| 			  unsigned int keylen) | 			  unsigned int keylen) | ||||||
| { | { | ||||||
| 	struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); | 	struct n2_cipher_context *ctx = crypto_ablkcipher_ctx(cipher); | ||||||
| 	struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); |  | ||||||
| 	struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); | 	struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); | ||||||
| 	u32 flags; |  | ||||||
| 	int err; | 	int err; | ||||||
| 
 | 
 | ||||||
| 	flags = crypto_ablkcipher_get_flags(cipher); | 	err = verify_ablkcipher_des3_key(cipher, key); | ||||||
| 	err = __des3_verify_key(&flags, key); | 	if (err) | ||||||
| 	if (unlikely(err)) { |  | ||||||
| 		crypto_ablkcipher_set_flags(cipher, flags); |  | ||||||
| 		return err; | 		return err; | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	ctx->enc_type = n2alg->enc_type; | 	ctx->enc_type = n2alg->enc_type; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user