diff options
author | Vitaly Chikunov <vt@altlinux.org> | 2019-04-11 11:51:13 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-04-18 10:15:01 -0400 |
commit | 78a0324f4a5328088fea9426cfe1d1851276c475 (patch) | |
tree | de5222d19c10023d866d9e59fec731267df9ae2d /crypto | |
parent | 3c2bc636219fc0c2ea82c8f0d3fb0c9936cf5146 (diff) |
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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/akcipher.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/akcipher.c b/crypto/akcipher.c index 0cbeae137e0a..780daa436dac 100644 --- a/crypto/akcipher.c +++ b/crypto/akcipher.c | |||
@@ -119,10 +119,24 @@ static void akcipher_prepare_alg(struct akcipher_alg *alg) | |||
119 | base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER; | 119 | base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER; |
120 | } | 120 | } |
121 | 121 | ||
122 | static int akcipher_default_op(struct akcipher_request *req) | ||
123 | { | ||
124 | return -ENOSYS; | ||
125 | } | ||
126 | |||
122 | int crypto_register_akcipher(struct akcipher_alg *alg) | 127 | int crypto_register_akcipher(struct akcipher_alg *alg) |
123 | { | 128 | { |
124 | struct crypto_alg *base = &alg->base; | 129 | struct crypto_alg *base = &alg->base; |
125 | 130 | ||
131 | if (!alg->sign) | ||
132 | alg->sign = akcipher_default_op; | ||
133 | if (!alg->verify) | ||
134 | alg->verify = akcipher_default_op; | ||
135 | if (!alg->encrypt) | ||
136 | alg->encrypt = akcipher_default_op; | ||
137 | if (!alg->decrypt) | ||
138 | alg->decrypt = akcipher_default_op; | ||
139 | |||
126 | akcipher_prepare_alg(alg); | 140 | akcipher_prepare_alg(alg); |
127 | return crypto_register_alg(base); | 141 | return crypto_register_alg(base); |
128 | } | 142 | } |