aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-08-30 04:24:15 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:43 -0400
commit3c09f17c3d11f3e98928f55b600e6de22f58017a (patch)
tree1c707e78054804fba65719a6dc87bc555fe9566b /include
parentb16c3a2e2c0307f5370b2b5e18bcbe1437b5f3d8 (diff)
[CRYPTO] aead: Add authenc
This patch adds the authenc algorithm which constructs an AEAD algorithm from an asynchronous block cipher and a hash. The construction is done by concatenating the encrypted result from the cipher with the output from the hash, as is used by the IPsec ESP protocol. The authenc algorithm exists as a template with four parameters: authenc(auth, authsize, enc, enckeylen). The authentication algorithm, the authentication size (i.e., truncating the output of the authentication algorithm), the encryption algorithm, and the encryption key length. Both the size field and the key length field are in bytes. For example, AES-128 with SHA1-HMAC would be represented by authenc(hmac(sha1), 12, cbc(aes), 16) The key for the authenc algorithm is the concatenation of the keys for the authentication algorithm with the encryption algorithm. For the above example, if a key of length 36 bytes is given, then hmac(sha1) would receive the first 20 bytes while the last 16 would be given to cbc(aes). Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include')
-rw-r--r--include/crypto/algapi.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index cd721a7ce78f..4af72dc21202 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -112,7 +112,8 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
112 112
113struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); 113struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
114int crypto_check_attr_type(struct rtattr **tb, u32 type); 114int crypto_check_attr_type(struct rtattr **tb, u32 type);
115struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask); 115struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask);
116int crypto_attr_u32(struct rtattr *rta, u32 *num);
116struct crypto_instance *crypto_alloc_instance(const char *name, 117struct crypto_instance *crypto_alloc_instance(const char *name,
117 struct crypto_alg *alg); 118 struct crypto_alg *alg);
118 119
@@ -171,6 +172,26 @@ static inline struct aead_alg *crypto_aead_alg(struct crypto_aead *tfm)
171 return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead; 172 return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead;
172} 173}
173 174
175static inline void *crypto_aead_ctx(struct crypto_aead *tfm)
176{
177 return crypto_tfm_ctx(&tfm->base);
178}
179
180static inline struct crypto_instance *crypto_aead_alg_instance(
181 struct crypto_aead *aead)
182{
183 return crypto_tfm_alg_instance(&aead->base);
184}
185
186static inline struct crypto_ablkcipher *crypto_spawn_ablkcipher(
187 struct crypto_spawn *spawn)
188{
189 u32 type = CRYPTO_ALG_TYPE_BLKCIPHER;
190 u32 mask = CRYPTO_ALG_TYPE_MASK;
191
192 return __crypto_ablkcipher_cast(crypto_spawn_tfm(spawn, type, mask));
193}
194
174static inline struct crypto_blkcipher *crypto_spawn_blkcipher( 195static inline struct crypto_blkcipher *crypto_spawn_blkcipher(
175 struct crypto_spawn *spawn) 196 struct crypto_spawn *spawn)
176{ 197{
@@ -257,5 +278,26 @@ static inline int ablkcipher_tfm_in_queue(struct crypto_queue *queue,
257 return crypto_tfm_in_queue(queue, crypto_ablkcipher_tfm(tfm)); 278 return crypto_tfm_in_queue(queue, crypto_ablkcipher_tfm(tfm));
258} 279}
259 280
281static inline void *aead_request_ctx(struct aead_request *req)
282{
283 return req->__ctx;
284}
285
286static inline void aead_request_complete(struct aead_request *req, int err)
287{
288 req->base.complete(&req->base, err);
289}
290
291static inline u32 aead_request_flags(struct aead_request *req)
292{
293 return req->base.flags;
294}
295
296static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb,
297 u32 type, u32 mask)
298{
299 return crypto_attr_alg(tb[1], type, mask);
300}
301
260#endif /* _CRYPTO_ALGAPI_H */ 302#endif /* _CRYPTO_ALGAPI_H */
261 303