diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-08-30 04:24:15 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:55:43 -0400 |
commit | 3c09f17c3d11f3e98928f55b600e6de22f58017a (patch) | |
tree | 1c707e78054804fba65719a6dc87bc555fe9566b /include/crypto/algapi.h | |
parent | b16c3a2e2c0307f5370b2b5e18bcbe1437b5f3d8 (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/crypto/algapi.h')
-rw-r--r-- | include/crypto/algapi.h | 44 |
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 | ||
113 | struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); | 113 | struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); |
114 | int crypto_check_attr_type(struct rtattr **tb, u32 type); | 114 | int crypto_check_attr_type(struct rtattr **tb, u32 type); |
115 | struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask); | 115 | struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask); |
116 | int crypto_attr_u32(struct rtattr *rta, u32 *num); | ||
116 | struct crypto_instance *crypto_alloc_instance(const char *name, | 117 | struct 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 | ||
175 | static inline void *crypto_aead_ctx(struct crypto_aead *tfm) | ||
176 | { | ||
177 | return crypto_tfm_ctx(&tfm->base); | ||
178 | } | ||
179 | |||
180 | static inline struct crypto_instance *crypto_aead_alg_instance( | ||
181 | struct crypto_aead *aead) | ||
182 | { | ||
183 | return crypto_tfm_alg_instance(&aead->base); | ||
184 | } | ||
185 | |||
186 | static 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 | |||
174 | static inline struct crypto_blkcipher *crypto_spawn_blkcipher( | 195 | static 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 | ||
281 | static inline void *aead_request_ctx(struct aead_request *req) | ||
282 | { | ||
283 | return req->__ctx; | ||
284 | } | ||
285 | |||
286 | static inline void aead_request_complete(struct aead_request *req, int err) | ||
287 | { | ||
288 | req->base.complete(&req->base, err); | ||
289 | } | ||
290 | |||
291 | static inline u32 aead_request_flags(struct aead_request *req) | ||
292 | { | ||
293 | return req->base.flags; | ||
294 | } | ||
295 | |||
296 | static 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 | ||