| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Symmetric key ciphers. | 
|  | 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_INTERNAL_SKCIPHER_H | 
|  | 14 | #define _CRYPTO_INTERNAL_SKCIPHER_H | 
|  | 15 |  | 
|  | 16 | #include <crypto/algapi.h> | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 17 | #include <crypto/skcipher.h> | 
| Herbert Xu | 76fc60a | 2008-02-23 11:12:06 +0800 | [diff] [blame] | 18 | #include <linux/init.h> | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 19 | #include <linux/types.h> | 
|  | 20 |  | 
|  | 21 | struct rtattr; | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 22 |  | 
|  | 23 | struct crypto_skcipher_spawn { | 
|  | 24 | struct crypto_spawn base; | 
|  | 25 | }; | 
|  | 26 |  | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 27 | extern const struct crypto_type crypto_givcipher_type; | 
|  | 28 |  | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 29 | static inline void crypto_set_skcipher_spawn( | 
|  | 30 | struct crypto_skcipher_spawn *spawn, struct crypto_instance *inst) | 
|  | 31 | { | 
|  | 32 | crypto_set_spawn(&spawn->base, inst); | 
|  | 33 | } | 
|  | 34 |  | 
|  | 35 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 
|  | 36 | u32 type, u32 mask); | 
|  | 37 |  | 
|  | 38 | static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn) | 
|  | 39 | { | 
|  | 40 | crypto_drop_spawn(&spawn->base); | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | static inline struct crypto_alg *crypto_skcipher_spawn_alg( | 
|  | 44 | struct crypto_skcipher_spawn *spawn) | 
|  | 45 | { | 
|  | 46 | return spawn->base.alg; | 
|  | 47 | } | 
|  | 48 |  | 
|  | 49 | static inline struct crypto_ablkcipher *crypto_spawn_skcipher( | 
|  | 50 | struct crypto_skcipher_spawn *spawn) | 
|  | 51 | { | 
|  | 52 | return __crypto_ablkcipher_cast( | 
|  | 53 | crypto_spawn_tfm(&spawn->base, crypto_skcipher_type(0), | 
|  | 54 | crypto_skcipher_mask(0))); | 
|  | 55 | } | 
|  | 56 |  | 
| Herbert Xu | b9c55aa | 2007-12-04 12:46:48 +1100 | [diff] [blame] | 57 | int skcipher_null_givencrypt(struct skcipher_givcrypt_request *req); | 
|  | 58 | int skcipher_null_givdecrypt(struct skcipher_givcrypt_request *req); | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 59 | const char *crypto_default_geniv(const struct crypto_alg *alg); | 
|  | 60 |  | 
|  | 61 | struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl, | 
|  | 62 | struct rtattr **tb, u32 type, | 
|  | 63 | u32 mask); | 
|  | 64 | void skcipher_geniv_free(struct crypto_instance *inst); | 
|  | 65 | int skcipher_geniv_init(struct crypto_tfm *tfm); | 
|  | 66 | void skcipher_geniv_exit(struct crypto_tfm *tfm); | 
|  | 67 |  | 
| Herbert Xu | 76fc60a | 2008-02-23 11:12:06 +0800 | [diff] [blame] | 68 | int __init eseqiv_module_init(void); | 
|  | 69 | void __exit eseqiv_module_exit(void); | 
|  | 70 | int __init chainiv_module_init(void); | 
| Herbert Xu | f13ba2f | 2008-03-08 20:29:43 +0800 | [diff] [blame] | 71 | void chainiv_module_exit(void); | 
| Herbert Xu | 76fc60a | 2008-02-23 11:12:06 +0800 | [diff] [blame] | 72 |  | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 73 | static inline struct crypto_ablkcipher *skcipher_geniv_cipher( | 
|  | 74 | struct crypto_ablkcipher *geniv) | 
|  | 75 | { | 
|  | 76 | return crypto_ablkcipher_crt(geniv)->base; | 
|  | 77 | } | 
|  | 78 |  | 
| Herbert Xu | e7cd251 | 2007-12-14 22:28:14 +0800 | [diff] [blame] | 79 | static inline int skcipher_enqueue_givcrypt( | 
|  | 80 | struct crypto_queue *queue, struct skcipher_givcrypt_request *request) | 
|  | 81 | { | 
|  | 82 | return ablkcipher_enqueue_request(queue, &request->creq); | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | static inline struct skcipher_givcrypt_request *skcipher_dequeue_givcrypt( | 
|  | 86 | struct crypto_queue *queue) | 
|  | 87 | { | 
|  | 88 | return container_of(ablkcipher_dequeue_request(queue), | 
|  | 89 | struct skcipher_givcrypt_request, creq); | 
|  | 90 | } | 
|  | 91 |  | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 92 | static inline void *skcipher_givcrypt_reqctx( | 
|  | 93 | struct skcipher_givcrypt_request *req) | 
|  | 94 | { | 
|  | 95 | return ablkcipher_request_ctx(&req->creq); | 
|  | 96 | } | 
|  | 97 |  | 
| Herbert Xu | 15c6728 | 2007-11-30 20:17:28 +1100 | [diff] [blame] | 98 | static inline void ablkcipher_request_complete(struct ablkcipher_request *req, | 
|  | 99 | int err) | 
|  | 100 | { | 
|  | 101 | req->base.complete(&req->base, err); | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | static inline void skcipher_givcrypt_complete( | 
|  | 105 | struct skcipher_givcrypt_request *req, int err) | 
|  | 106 | { | 
|  | 107 | ablkcipher_request_complete(&req->creq, err); | 
|  | 108 | } | 
|  | 109 |  | 
| Herbert Xu | 3631c65 | 2007-12-13 22:28:59 +0800 | [diff] [blame] | 110 | static inline u32 ablkcipher_request_flags(struct ablkcipher_request *req) | 
|  | 111 | { | 
|  | 112 | return req->base.flags; | 
|  | 113 | } | 
|  | 114 |  | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 115 | #endif	/* _CRYPTO_INTERNAL_SKCIPHER_H */ | 
|  | 116 |  |