diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-12 01:17:50 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-18 05:35:46 -0400 |
| commit | 3a01d0ee2b991c8c267620e63a4ab47cd8c30cc4 (patch) | |
| tree | 5c8d3aa7fb5fbaa3ae9d80883e9057c0395b7def /include/crypto | |
| parent | 6cf80a296575723aed6ce6c695581540202bfc6b (diff) | |
crypto: skcipher - Remove top-level givcipher interface
This patch removes the old crypto_grab_skcipher helper and replaces
it with crypto_grab_skcipher2.
As this is the final entry point into givcipher this patch also
removes all traces of the top-level givcipher interface, including
all implicit IV generators such as chainiv.
The bottom-level givcipher interface remains until the drivers
using it are converted.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/internal/skcipher.h | 63 | ||||
| -rw-r--r-- | include/crypto/skcipher.h | 76 |
2 files changed, 12 insertions, 127 deletions
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index ce6619c339fe..a21a95e1a375 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h | |||
| @@ -67,8 +67,12 @@ static inline void crypto_set_skcipher_spawn( | |||
| 67 | 67 | ||
| 68 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 68 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, |
| 69 | u32 type, u32 mask); | 69 | u32 type, u32 mask); |
| 70 | int crypto_grab_skcipher2(struct crypto_skcipher_spawn *spawn, | 70 | |
| 71 | const char *name, u32 type, u32 mask); | 71 | static inline int crypto_grab_skcipher2(struct crypto_skcipher_spawn *spawn, |
| 72 | const char *name, u32 type, u32 mask) | ||
| 73 | { | ||
| 74 | return crypto_grab_skcipher(spawn, name, type, mask); | ||
| 75 | } | ||
| 72 | 76 | ||
| 73 | struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask); | 77 | struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask); |
| 74 | 78 | ||
| @@ -77,30 +81,28 @@ static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn) | |||
| 77 | crypto_drop_spawn(&spawn->base); | 81 | crypto_drop_spawn(&spawn->base); |
| 78 | } | 82 | } |
| 79 | 83 | ||
| 80 | static inline struct crypto_alg *crypto_skcipher_spawn_alg( | 84 | static inline struct skcipher_alg *crypto_skcipher_spawn_alg( |
| 81 | struct crypto_skcipher_spawn *spawn) | 85 | struct crypto_skcipher_spawn *spawn) |
| 82 | { | 86 | { |
| 83 | return spawn->base.alg; | 87 | return container_of(spawn->base.alg, struct skcipher_alg, base); |
| 84 | } | 88 | } |
| 85 | 89 | ||
| 86 | static inline struct skcipher_alg *crypto_spawn_skcipher_alg( | 90 | static inline struct skcipher_alg *crypto_spawn_skcipher_alg( |
| 87 | struct crypto_skcipher_spawn *spawn) | 91 | struct crypto_skcipher_spawn *spawn) |
| 88 | { | 92 | { |
| 89 | return container_of(spawn->base.alg, struct skcipher_alg, base); | 93 | return crypto_skcipher_spawn_alg(spawn); |
| 90 | } | 94 | } |
| 91 | 95 | ||
| 92 | static inline struct crypto_ablkcipher *crypto_spawn_skcipher( | 96 | static inline struct crypto_skcipher *crypto_spawn_skcipher( |
| 93 | struct crypto_skcipher_spawn *spawn) | 97 | struct crypto_skcipher_spawn *spawn) |
| 94 | { | 98 | { |
| 95 | return __crypto_ablkcipher_cast( | 99 | return crypto_spawn_tfm2(&spawn->base); |
| 96 | crypto_spawn_tfm(&spawn->base, crypto_skcipher_type(0), | ||
| 97 | crypto_skcipher_mask(0))); | ||
| 98 | } | 100 | } |
| 99 | 101 | ||
| 100 | static inline struct crypto_skcipher *crypto_spawn_skcipher2( | 102 | static inline struct crypto_skcipher *crypto_spawn_skcipher2( |
| 101 | struct crypto_skcipher_spawn *spawn) | 103 | struct crypto_skcipher_spawn *spawn) |
| 102 | { | 104 | { |
| 103 | return crypto_spawn_tfm2(&spawn->base); | 105 | return crypto_spawn_skcipher(spawn); |
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | static inline void crypto_skcipher_set_reqsize( | 108 | static inline void crypto_skcipher_set_reqsize( |
| @@ -116,53 +118,12 @@ void crypto_unregister_skciphers(struct skcipher_alg *algs, int count); | |||
| 116 | int skcipher_register_instance(struct crypto_template *tmpl, | 118 | int skcipher_register_instance(struct crypto_template *tmpl, |
| 117 | struct skcipher_instance *inst); | 119 | struct skcipher_instance *inst); |
| 118 | 120 | ||
| 119 | int skcipher_null_givencrypt(struct skcipher_givcrypt_request *req); | ||
| 120 | int skcipher_null_givdecrypt(struct skcipher_givcrypt_request *req); | ||
| 121 | const char *crypto_default_geniv(const struct crypto_alg *alg); | ||
| 122 | |||
| 123 | struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl, | ||
| 124 | struct rtattr **tb, u32 type, | ||
| 125 | u32 mask); | ||
| 126 | void skcipher_geniv_free(struct crypto_instance *inst); | ||
| 127 | int skcipher_geniv_init(struct crypto_tfm *tfm); | ||
| 128 | void skcipher_geniv_exit(struct crypto_tfm *tfm); | ||
| 129 | |||
| 130 | static inline struct crypto_ablkcipher *skcipher_geniv_cipher( | ||
| 131 | struct crypto_ablkcipher *geniv) | ||
| 132 | { | ||
| 133 | return crypto_ablkcipher_crt(geniv)->base; | ||
| 134 | } | ||
| 135 | |||
| 136 | static inline int skcipher_enqueue_givcrypt( | ||
| 137 | struct crypto_queue *queue, struct skcipher_givcrypt_request *request) | ||
| 138 | { | ||
| 139 | return ablkcipher_enqueue_request(queue, &request->creq); | ||
| 140 | } | ||
| 141 | |||
| 142 | static inline struct skcipher_givcrypt_request *skcipher_dequeue_givcrypt( | ||
| 143 | struct crypto_queue *queue) | ||
| 144 | { | ||
| 145 | return skcipher_givcrypt_cast(crypto_dequeue_request(queue)); | ||
| 146 | } | ||
| 147 | |||
| 148 | static inline void *skcipher_givcrypt_reqctx( | ||
| 149 | struct skcipher_givcrypt_request *req) | ||
| 150 | { | ||
| 151 | return ablkcipher_request_ctx(&req->creq); | ||
| 152 | } | ||
| 153 | |||
| 154 | static inline void ablkcipher_request_complete(struct ablkcipher_request *req, | 121 | static inline void ablkcipher_request_complete(struct ablkcipher_request *req, |
| 155 | int err) | 122 | int err) |
| 156 | { | 123 | { |
| 157 | req->base.complete(&req->base, err); | 124 | req->base.complete(&req->base, err); |
| 158 | } | 125 | } |
| 159 | 126 | ||
| 160 | static inline void skcipher_givcrypt_complete( | ||
| 161 | struct skcipher_givcrypt_request *req, int err) | ||
| 162 | { | ||
| 163 | ablkcipher_request_complete(&req->creq, err); | ||
| 164 | } | ||
| 165 | |||
| 166 | static inline u32 ablkcipher_request_flags(struct ablkcipher_request *req) | 127 | static inline u32 ablkcipher_request_flags(struct ablkcipher_request *req) |
| 167 | { | 128 | { |
| 168 | return req->base.flags; | 129 | return req->base.flags; |
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index a381f57ea695..59c8f6c593e6 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h | |||
| @@ -139,82 +139,6 @@ struct skcipher_alg { | |||
| 139 | crypto_skcipher_reqsize(tfm)] CRYPTO_MINALIGN_ATTR; \ | 139 | crypto_skcipher_reqsize(tfm)] CRYPTO_MINALIGN_ATTR; \ |
| 140 | struct skcipher_request *name = (void *)__##name##_desc | 140 | struct skcipher_request *name = (void *)__##name##_desc |
| 141 | 141 | ||
| 142 | static inline struct crypto_ablkcipher *skcipher_givcrypt_reqtfm( | ||
| 143 | struct skcipher_givcrypt_request *req) | ||
| 144 | { | ||
| 145 | return crypto_ablkcipher_reqtfm(&req->creq); | ||
| 146 | } | ||
| 147 | |||
| 148 | static inline int crypto_skcipher_givencrypt( | ||
| 149 | struct skcipher_givcrypt_request *req) | ||
| 150 | { | ||
| 151 | struct ablkcipher_tfm *crt = | ||
| 152 | crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req)); | ||
| 153 | return crt->givencrypt(req); | ||
| 154 | }; | ||
| 155 | |||
| 156 | static inline int crypto_skcipher_givdecrypt( | ||
| 157 | struct skcipher_givcrypt_request *req) | ||
| 158 | { | ||
| 159 | struct ablkcipher_tfm *crt = | ||
| 160 | crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req)); | ||
| 161 | return crt->givdecrypt(req); | ||
| 162 | }; | ||
| 163 | |||
| 164 | static inline void skcipher_givcrypt_set_tfm( | ||
| 165 | struct skcipher_givcrypt_request *req, struct crypto_ablkcipher *tfm) | ||
| 166 | { | ||
| 167 | req->creq.base.tfm = crypto_ablkcipher_tfm(tfm); | ||
| 168 | } | ||
| 169 | |||
| 170 | static inline struct skcipher_givcrypt_request *skcipher_givcrypt_cast( | ||
| 171 | struct crypto_async_request *req) | ||
| 172 | { | ||
| 173 | return container_of(ablkcipher_request_cast(req), | ||
| 174 | struct skcipher_givcrypt_request, creq); | ||
| 175 | } | ||
| 176 | |||
| 177 | static inline struct skcipher_givcrypt_request *skcipher_givcrypt_alloc( | ||
| 178 | struct crypto_ablkcipher *tfm, gfp_t gfp) | ||
| 179 | { | ||
| 180 | struct skcipher_givcrypt_request *req; | ||
| 181 | |||
| 182 | req = kmalloc(sizeof(struct skcipher_givcrypt_request) + | ||
| 183 | crypto_ablkcipher_reqsize(tfm), gfp); | ||
| 184 | |||
| 185 | if (likely(req)) | ||
| 186 | skcipher_givcrypt_set_tfm(req, tfm); | ||
| 187 | |||
| 188 | return req; | ||
| 189 | } | ||
| 190 | |||
| 191 | static inline void skcipher_givcrypt_free(struct skcipher_givcrypt_request *req) | ||
| 192 | { | ||
| 193 | kfree(req); | ||
| 194 | } | ||
| 195 | |||
| 196 | static inline void skcipher_givcrypt_set_callback( | ||
| 197 | struct skcipher_givcrypt_request *req, u32 flags, | ||
| 198 | crypto_completion_t compl, void *data) | ||
| 199 | { | ||
| 200 | ablkcipher_request_set_callback(&req->creq, flags, compl, data); | ||
| 201 | } | ||
| 202 | |||
| 203 | static inline void skcipher_givcrypt_set_crypt( | ||
| 204 | struct skcipher_givcrypt_request *req, | ||
| 205 | struct scatterlist *src, struct scatterlist *dst, | ||
| 206 | unsigned int nbytes, void *iv) | ||
| 207 | { | ||
| 208 | ablkcipher_request_set_crypt(&req->creq, src, dst, nbytes, iv); | ||
| 209 | } | ||
| 210 | |||
| 211 | static inline void skcipher_givcrypt_set_giv( | ||
| 212 | struct skcipher_givcrypt_request *req, u8 *giv, u64 seq) | ||
| 213 | { | ||
| 214 | req->giv = giv; | ||
| 215 | req->seq = seq; | ||
| 216 | } | ||
| 217 | |||
| 218 | /** | 142 | /** |
| 219 | * DOC: Symmetric Key Cipher API | 143 | * DOC: Symmetric Key Cipher API |
| 220 | * | 144 | * |
