diff options
-rw-r--r-- | crypto/aead.c | 7 | ||||
-rw-r--r-- | include/crypto/aead.h | 38 | ||||
-rw-r--r-- | include/linux/crypto.h | 5 |
3 files changed, 50 insertions, 0 deletions
diff --git a/crypto/aead.c b/crypto/aead.c index f23c2b0ee009..0402b606fcfd 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
@@ -77,6 +77,11 @@ static unsigned int crypto_aead_ctxsize(struct crypto_alg *alg, u32 type, | |||
77 | return alg->cra_ctxsize; | 77 | return alg->cra_ctxsize; |
78 | } | 78 | } |
79 | 79 | ||
80 | static int no_givdecrypt(struct aead_givcrypt_request *req) | ||
81 | { | ||
82 | return -ENOSYS; | ||
83 | } | ||
84 | |||
80 | static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | 85 | static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask) |
81 | { | 86 | { |
82 | struct aead_alg *alg = &tfm->__crt_alg->cra_aead; | 87 | struct aead_alg *alg = &tfm->__crt_alg->cra_aead; |
@@ -88,6 +93,8 @@ static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | |||
88 | crt->setkey = setkey; | 93 | crt->setkey = setkey; |
89 | crt->encrypt = alg->encrypt; | 94 | crt->encrypt = alg->encrypt; |
90 | crt->decrypt = alg->decrypt; | 95 | crt->decrypt = alg->decrypt; |
96 | crt->givencrypt = alg->givencrypt; | ||
97 | crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; | ||
91 | crt->ivsize = alg->ivsize; | 98 | crt->ivsize = alg->ivsize; |
92 | crt->authsize = alg->maxauthsize; | 99 | crt->authsize = alg->maxauthsize; |
93 | 100 | ||
diff --git a/include/crypto/aead.h b/include/crypto/aead.h new file mode 100644 index 000000000000..083920312da0 --- /dev/null +++ b/include/crypto/aead.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * AEAD: Authenticated Encryption with Associated Data | ||
3 | * | ||
4 | * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _CRYPTO_AEAD_H | ||
14 | #define _CRYPTO_AEAD_H | ||
15 | |||
16 | #include <linux/crypto.h> | ||
17 | #include <linux/kernel.h> | ||
18 | |||
19 | /** | ||
20 | * struct aead_givcrypt_request - AEAD request with IV generation | ||
21 | * @seq: Sequence number for IV generation | ||
22 | * @giv: Space for generated IV | ||
23 | * @areq: The AEAD request itself | ||
24 | */ | ||
25 | struct aead_givcrypt_request { | ||
26 | u64 seq; | ||
27 | u8 *giv; | ||
28 | |||
29 | struct aead_request areq; | ||
30 | }; | ||
31 | |||
32 | static inline struct crypto_aead *aead_givcrypt_reqtfm( | ||
33 | struct aead_givcrypt_request *req) | ||
34 | { | ||
35 | return crypto_aead_reqtfm(&req->areq); | ||
36 | } | ||
37 | |||
38 | #endif /* _CRYPTO_AEAD_H */ | ||
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 835dcaf3fe4e..7524928bff93 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -106,6 +106,7 @@ struct crypto_blkcipher; | |||
106 | struct crypto_hash; | 106 | struct crypto_hash; |
107 | struct crypto_tfm; | 107 | struct crypto_tfm; |
108 | struct crypto_type; | 108 | struct crypto_type; |
109 | struct aead_givcrypt_request; | ||
109 | struct skcipher_givcrypt_request; | 110 | struct skcipher_givcrypt_request; |
110 | 111 | ||
111 | typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); | 112 | typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); |
@@ -202,6 +203,8 @@ struct aead_alg { | |||
202 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); | 203 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); |
203 | int (*encrypt)(struct aead_request *req); | 204 | int (*encrypt)(struct aead_request *req); |
204 | int (*decrypt)(struct aead_request *req); | 205 | int (*decrypt)(struct aead_request *req); |
206 | int (*givencrypt)(struct aead_givcrypt_request *req); | ||
207 | int (*givdecrypt)(struct aead_givcrypt_request *req); | ||
205 | 208 | ||
206 | unsigned int ivsize; | 209 | unsigned int ivsize; |
207 | unsigned int maxauthsize; | 210 | unsigned int maxauthsize; |
@@ -348,6 +351,8 @@ struct aead_tfm { | |||
348 | unsigned int keylen); | 351 | unsigned int keylen); |
349 | int (*encrypt)(struct aead_request *req); | 352 | int (*encrypt)(struct aead_request *req); |
350 | int (*decrypt)(struct aead_request *req); | 353 | int (*decrypt)(struct aead_request *req); |
354 | int (*givencrypt)(struct aead_givcrypt_request *req); | ||
355 | int (*givdecrypt)(struct aead_givcrypt_request *req); | ||
351 | unsigned int ivsize; | 356 | unsigned int ivsize; |
352 | unsigned int authsize; | 357 | unsigned int authsize; |
353 | unsigned int reqsize; | 358 | unsigned int reqsize; |