aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/aead.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/aead.c')
-rw-r--r--crypto/aead.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/crypto/aead.c b/crypto/aead.c
index 84a3501fb478..f23c2b0ee009 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -53,6 +53,24 @@ static int setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen)
53 return aead->setkey(tfm, key, keylen); 53 return aead->setkey(tfm, key, keylen);
54} 54}
55 55
56int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
57{
58 int err;
59
60 if (authsize > crypto_aead_alg(tfm)->maxauthsize)
61 return -EINVAL;
62
63 if (crypto_aead_alg(tfm)->setauthsize) {
64 err = crypto_aead_alg(tfm)->setauthsize(tfm, authsize);
65 if (err)
66 return err;
67 }
68
69 crypto_aead_crt(tfm)->authsize = authsize;
70 return 0;
71}
72EXPORT_SYMBOL_GPL(crypto_aead_setauthsize);
73
56static unsigned int crypto_aead_ctxsize(struct crypto_alg *alg, u32 type, 74static unsigned int crypto_aead_ctxsize(struct crypto_alg *alg, u32 type,
57 u32 mask) 75 u32 mask)
58{ 76{
@@ -64,14 +82,14 @@ static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
64 struct aead_alg *alg = &tfm->__crt_alg->cra_aead; 82 struct aead_alg *alg = &tfm->__crt_alg->cra_aead;
65 struct aead_tfm *crt = &tfm->crt_aead; 83 struct aead_tfm *crt = &tfm->crt_aead;
66 84
67 if (max(alg->authsize, alg->ivsize) > PAGE_SIZE / 8) 85 if (max(alg->maxauthsize, alg->ivsize) > PAGE_SIZE / 8)
68 return -EINVAL; 86 return -EINVAL;
69 87
70 crt->setkey = setkey; 88 crt->setkey = setkey;
71 crt->encrypt = alg->encrypt; 89 crt->encrypt = alg->encrypt;
72 crt->decrypt = alg->decrypt; 90 crt->decrypt = alg->decrypt;
73 crt->ivsize = alg->ivsize; 91 crt->ivsize = alg->ivsize;
74 crt->authsize = alg->authsize; 92 crt->authsize = alg->maxauthsize;
75 93
76 return 0; 94 return 0;
77} 95}
@@ -85,7 +103,7 @@ static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
85 seq_printf(m, "type : aead\n"); 103 seq_printf(m, "type : aead\n");
86 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); 104 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
87 seq_printf(m, "ivsize : %u\n", aead->ivsize); 105 seq_printf(m, "ivsize : %u\n", aead->ivsize);
88 seq_printf(m, "authsize : %u\n", aead->authsize); 106 seq_printf(m, "maxauthsize : %u\n", aead->maxauthsize);
89} 107}
90 108
91const struct crypto_type crypto_aead_type = { 109const struct crypto_type crypto_aead_type = {