mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	crypto: akcipher - default implementations for request callbacks
Because with the introduction of EC-RDSA and change in workings of RSA in regard to sign/verify, akcipher could have not all callbacks defined, check the presence of callbacks in crypto_register_akcipher() and provide default implementation if the callback is not implemented. This is suggested by Herbert Xu instead of checking the presence of the callback on every request. Signed-off-by: Vitaly Chikunov <vt@altlinux.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
		
							parent
							
								
									3c2bc63621
								
							
						
					
					
						commit
						78a0324f4a
					
				
					 1 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -119,10 +119,24 @@ static void akcipher_prepare_alg(struct akcipher_alg *alg)
 | 
			
		|||
	base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int akcipher_default_op(struct akcipher_request *req)
 | 
			
		||||
{
 | 
			
		||||
	return -ENOSYS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int crypto_register_akcipher(struct akcipher_alg *alg)
 | 
			
		||||
{
 | 
			
		||||
	struct crypto_alg *base = &alg->base;
 | 
			
		||||
 | 
			
		||||
	if (!alg->sign)
 | 
			
		||||
		alg->sign = akcipher_default_op;
 | 
			
		||||
	if (!alg->verify)
 | 
			
		||||
		alg->verify = akcipher_default_op;
 | 
			
		||||
	if (!alg->encrypt)
 | 
			
		||||
		alg->encrypt = akcipher_default_op;
 | 
			
		||||
	if (!alg->decrypt)
 | 
			
		||||
		alg->decrypt = akcipher_default_op;
 | 
			
		||||
 | 
			
		||||
	akcipher_prepare_alg(alg);
 | 
			
		||||
	return crypto_register_alg(base);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue