lkml.org 
[lkml]   [2019]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 02/11] crypto: akcipher - check the presence of callback before the call
On Fri, Mar 01, 2019 at 08:59:09PM +0300, Vitaly Chikunov wrote:
> Because with 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 before calling them to increase
> robustness.
>
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
> include/crypto/akcipher.h | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
> index 2d690494568c..f537fad1989f 100644
> --- a/include/crypto/akcipher.h
> +++ b/include/crypto/akcipher.h
> @@ -268,7 +268,10 @@ static inline unsigned int crypto_akcipher_maxsize(struct crypto_akcipher *tfm)
> {
> struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
>
> - return alg->max_size(tfm);
> + if (alg->max_size)
> + return alg->max_size(tfm);
> + else
> + return 0;
> }

Please do these checks at registration time instead and provide
default implementations as needed.

Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2019-03-21 12:21    [W:2.365 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site