mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
crypto: geniv - use memcpy_sglist() instead of null skcipher
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
4e39d0712e
commit
d8aeec147a
5 changed files with 7 additions and 43 deletions
|
@ -815,7 +815,6 @@ config CRYPTO_GCM
|
|||
config CRYPTO_GENIV
|
||||
tristate
|
||||
select CRYPTO_AEAD
|
||||
select CRYPTO_NULL
|
||||
select CRYPTO_MANAGER
|
||||
select CRYPTO_RNG_DEFAULT
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ static int echainiv_encrypt(struct aead_request *req)
|
|||
u64 seqno;
|
||||
u8 *info;
|
||||
unsigned int ivsize = crypto_aead_ivsize(geniv);
|
||||
int err;
|
||||
|
||||
if (req->cryptlen < ivsize)
|
||||
return -EINVAL;
|
||||
|
@ -41,20 +40,9 @@ static int echainiv_encrypt(struct aead_request *req)
|
|||
|
||||
info = req->iv;
|
||||
|
||||
if (req->src != req->dst) {
|
||||
SYNC_SKCIPHER_REQUEST_ON_STACK(nreq, ctx->sknull);
|
||||
|
||||
skcipher_request_set_sync_tfm(nreq, ctx->sknull);
|
||||
skcipher_request_set_callback(nreq, req->base.flags,
|
||||
NULL, NULL);
|
||||
skcipher_request_set_crypt(nreq, req->src, req->dst,
|
||||
req->assoclen + req->cryptlen,
|
||||
NULL);
|
||||
|
||||
err = crypto_skcipher_encrypt(nreq);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
if (req->src != req->dst)
|
||||
memcpy_sglist(req->dst, req->src,
|
||||
req->assoclen + req->cryptlen);
|
||||
|
||||
aead_request_set_callback(subreq, req->base.flags,
|
||||
req->base.complete, req->base.data);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <crypto/internal/geniv.h>
|
||||
#include <crypto/internal/rng.h>
|
||||
#include <crypto/null.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
@ -125,15 +124,10 @@ int aead_init_geniv(struct crypto_aead *aead)
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
ctx->sknull = crypto_get_default_null_skcipher();
|
||||
err = PTR_ERR(ctx->sknull);
|
||||
if (IS_ERR(ctx->sknull))
|
||||
goto out;
|
||||
|
||||
child = crypto_spawn_aead(aead_instance_ctx(inst));
|
||||
err = PTR_ERR(child);
|
||||
if (IS_ERR(child))
|
||||
goto drop_null;
|
||||
goto out;
|
||||
|
||||
ctx->child = child;
|
||||
crypto_aead_set_reqsize(aead, crypto_aead_reqsize(child) +
|
||||
|
@ -143,10 +137,6 @@ int aead_init_geniv(struct crypto_aead *aead)
|
|||
|
||||
out:
|
||||
return err;
|
||||
|
||||
drop_null:
|
||||
crypto_put_default_null_skcipher();
|
||||
goto out;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(aead_init_geniv);
|
||||
|
||||
|
@ -155,7 +145,6 @@ void aead_exit_geniv(struct crypto_aead *tfm)
|
|||
struct aead_geniv_ctx *ctx = crypto_aead_ctx(tfm);
|
||||
|
||||
crypto_free_aead(ctx->child);
|
||||
crypto_put_default_null_skcipher();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(aead_exit_geniv);
|
||||
|
||||
|
|
|
@ -64,20 +64,9 @@ static int seqiv_aead_encrypt(struct aead_request *req)
|
|||
data = req->base.data;
|
||||
info = req->iv;
|
||||
|
||||
if (req->src != req->dst) {
|
||||
SYNC_SKCIPHER_REQUEST_ON_STACK(nreq, ctx->sknull);
|
||||
|
||||
skcipher_request_set_sync_tfm(nreq, ctx->sknull);
|
||||
skcipher_request_set_callback(nreq, req->base.flags,
|
||||
NULL, NULL);
|
||||
skcipher_request_set_crypt(nreq, req->src, req->dst,
|
||||
req->assoclen + req->cryptlen,
|
||||
NULL);
|
||||
|
||||
err = crypto_skcipher_encrypt(nreq);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
if (req->src != req->dst)
|
||||
memcpy_sglist(req->dst, req->src,
|
||||
req->assoclen + req->cryptlen);
|
||||
|
||||
if (unlikely(!IS_ALIGNED((unsigned long)info,
|
||||
crypto_aead_alignmask(geniv) + 1))) {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
struct aead_geniv_ctx {
|
||||
spinlock_t lock;
|
||||
struct crypto_aead *child;
|
||||
struct crypto_sync_skcipher *sknull;
|
||||
u8 salt[] __attribute__ ((aligned(__alignof__(u32))));
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue