diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 14:43:22 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 14:43:22 -0500 |
| commit | e14e61e967f2b3bdf23f05e4ae5b9aa830151a44 (patch) | |
| tree | 9412c94cbe37bf6f0d0bd9ad2d8b907ce23eb1db /include/crypto | |
| parent | cb10ea549fdc0ab2dd8988adab5bf40b4fa642f3 (diff) | |
| parent | 0ee4a96902dd7858e65f378c86f428a0355bd841 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (57 commits)
crypto: aes - Precompute tables
crypto: talitos - Ack done interrupt in isr instead of tasklet
crypto: testmgr - Correct comment about deflate parameters
crypto: salsa20 - Remove private wrappers around various operations
crypto: des3_ede - permit weak keys unless REQ_WEAK_KEY set
crypto: sha512 - Switch to shash
crypto: sha512 - Move message schedule W[80] to static percpu area
crypto: michael_mic - Switch to shash
crypto: wp512 - Switch to shash
crypto: tgr192 - Switch to shash
crypto: sha256 - Switch to shash
crypto: md5 - Switch to shash
crypto: md4 - Switch to shash
crypto: sha1 - Switch to shash
crypto: rmd320 - Switch to shash
crypto: rmd256 - Switch to shash
crypto: rmd160 - Switch to shash
crypto: rmd128 - Switch to shash
crypto: null - Switch to shash
crypto: hash - Make setkey optional
...
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/aes.h | 8 | ||||
| -rw-r--r-- | include/crypto/algapi.h | 16 | ||||
| -rw-r--r-- | include/crypto/hash.h | 125 | ||||
| -rw-r--r-- | include/crypto/internal/hash.h | 16 |
4 files changed, 155 insertions, 10 deletions
diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 40008d67ee3d..656a4c66a568 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h | |||
| @@ -23,10 +23,10 @@ struct crypto_aes_ctx { | |||
| 23 | u32 key_dec[AES_MAX_KEYLENGTH_U32]; | 23 | u32 key_dec[AES_MAX_KEYLENGTH_U32]; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | extern u32 crypto_ft_tab[4][256]; | 26 | extern const u32 crypto_ft_tab[4][256]; |
| 27 | extern u32 crypto_fl_tab[4][256]; | 27 | extern const u32 crypto_fl_tab[4][256]; |
| 28 | extern u32 crypto_it_tab[4][256]; | 28 | extern const u32 crypto_it_tab[4][256]; |
| 29 | extern u32 crypto_il_tab[4][256]; | 29 | extern const u32 crypto_il_tab[4][256]; |
| 30 | 30 | ||
| 31 | int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, | 31 | int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
| 32 | unsigned int key_len); | 32 | unsigned int key_len); |
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 60d06e784be3..010545436efa 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h | |||
| @@ -22,9 +22,18 @@ struct seq_file; | |||
| 22 | 22 | ||
| 23 | struct crypto_type { | 23 | struct crypto_type { |
| 24 | unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask); | 24 | unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask); |
| 25 | unsigned int (*extsize)(struct crypto_alg *alg, | ||
| 26 | const struct crypto_type *frontend); | ||
| 25 | int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); | 27 | int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); |
| 26 | void (*exit)(struct crypto_tfm *tfm); | 28 | int (*init_tfm)(struct crypto_tfm *tfm, |
| 29 | const struct crypto_type *frontend); | ||
| 27 | void (*show)(struct seq_file *m, struct crypto_alg *alg); | 30 | void (*show)(struct seq_file *m, struct crypto_alg *alg); |
| 31 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); | ||
| 32 | |||
| 33 | unsigned int type; | ||
| 34 | unsigned int maskclear; | ||
| 35 | unsigned int maskset; | ||
| 36 | unsigned int tfmsize; | ||
| 28 | }; | 37 | }; |
| 29 | 38 | ||
| 30 | struct crypto_instance { | 39 | struct crypto_instance { |
| @@ -239,6 +248,11 @@ static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn) | |||
| 239 | return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask)); | 248 | return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask)); |
| 240 | } | 249 | } |
| 241 | 250 | ||
| 251 | static inline void *crypto_hash_ctx(struct crypto_hash *tfm) | ||
| 252 | { | ||
| 253 | return crypto_tfm_ctx(&tfm->base); | ||
| 254 | } | ||
| 255 | |||
| 242 | static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm) | 256 | static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm) |
| 243 | { | 257 | { |
| 244 | return crypto_tfm_ctx_aligned(&tfm->base); | 258 | return crypto_tfm_ctx_aligned(&tfm->base); |
diff --git a/include/crypto/hash.h b/include/crypto/hash.h index ee48ef8fb2ea..cd16d6e668ce 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h | |||
| @@ -15,10 +15,40 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/crypto.h> | 16 | #include <linux/crypto.h> |
| 17 | 17 | ||
| 18 | struct shash_desc { | ||
| 19 | struct crypto_shash *tfm; | ||
| 20 | u32 flags; | ||
| 21 | |||
| 22 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct shash_alg { | ||
| 26 | int (*init)(struct shash_desc *desc); | ||
| 27 | int (*reinit)(struct shash_desc *desc); | ||
| 28 | int (*update)(struct shash_desc *desc, const u8 *data, | ||
| 29 | unsigned int len); | ||
| 30 | int (*final)(struct shash_desc *desc, u8 *out); | ||
| 31 | int (*finup)(struct shash_desc *desc, const u8 *data, | ||
| 32 | unsigned int len, u8 *out); | ||
| 33 | int (*digest)(struct shash_desc *desc, const u8 *data, | ||
| 34 | unsigned int len, u8 *out); | ||
| 35 | int (*setkey)(struct crypto_shash *tfm, const u8 *key, | ||
| 36 | unsigned int keylen); | ||
| 37 | |||
| 38 | unsigned int descsize; | ||
| 39 | unsigned int digestsize; | ||
| 40 | |||
| 41 | struct crypto_alg base; | ||
| 42 | }; | ||
| 43 | |||
| 18 | struct crypto_ahash { | 44 | struct crypto_ahash { |
| 19 | struct crypto_tfm base; | 45 | struct crypto_tfm base; |
| 20 | }; | 46 | }; |
| 21 | 47 | ||
| 48 | struct crypto_shash { | ||
| 49 | struct crypto_tfm base; | ||
| 50 | }; | ||
| 51 | |||
| 22 | static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm) | 52 | static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm) |
| 23 | { | 53 | { |
| 24 | return (struct crypto_ahash *)tfm; | 54 | return (struct crypto_ahash *)tfm; |
| @@ -87,6 +117,11 @@ static inline unsigned int crypto_ahash_reqsize(struct crypto_ahash *tfm) | |||
| 87 | return crypto_ahash_crt(tfm)->reqsize; | 117 | return crypto_ahash_crt(tfm)->reqsize; |
| 88 | } | 118 | } |
| 89 | 119 | ||
| 120 | static inline void *ahash_request_ctx(struct ahash_request *req) | ||
| 121 | { | ||
| 122 | return req->__ctx; | ||
| 123 | } | ||
| 124 | |||
| 90 | static inline int crypto_ahash_setkey(struct crypto_ahash *tfm, | 125 | static inline int crypto_ahash_setkey(struct crypto_ahash *tfm, |
| 91 | const u8 *key, unsigned int keylen) | 126 | const u8 *key, unsigned int keylen) |
| 92 | { | 127 | { |
| @@ -101,6 +136,14 @@ static inline int crypto_ahash_digest(struct ahash_request *req) | |||
| 101 | return crt->digest(req); | 136 | return crt->digest(req); |
| 102 | } | 137 | } |
| 103 | 138 | ||
| 139 | static inline void crypto_ahash_export(struct ahash_request *req, u8 *out) | ||
| 140 | { | ||
| 141 | memcpy(out, ahash_request_ctx(req), | ||
| 142 | crypto_ahash_reqsize(crypto_ahash_reqtfm(req))); | ||
| 143 | } | ||
| 144 | |||
| 145 | int crypto_ahash_import(struct ahash_request *req, const u8 *in); | ||
| 146 | |||
| 104 | static inline int crypto_ahash_init(struct ahash_request *req) | 147 | static inline int crypto_ahash_init(struct ahash_request *req) |
| 105 | { | 148 | { |
| 106 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); | 149 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); |
| @@ -169,4 +212,86 @@ static inline void ahash_request_set_crypt(struct ahash_request *req, | |||
| 169 | req->result = result; | 212 | req->result = result; |
| 170 | } | 213 | } |
| 171 | 214 | ||
| 215 | struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type, | ||
| 216 | u32 mask); | ||
| 217 | |||
| 218 | static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm) | ||
| 219 | { | ||
| 220 | return &tfm->base; | ||
| 221 | } | ||
| 222 | |||
| 223 | static inline void crypto_free_shash(struct crypto_shash *tfm) | ||
| 224 | { | ||
| 225 | crypto_free_tfm(crypto_shash_tfm(tfm)); | ||
| 226 | } | ||
| 227 | |||
| 228 | static inline unsigned int crypto_shash_alignmask( | ||
| 229 | struct crypto_shash *tfm) | ||
| 230 | { | ||
| 231 | return crypto_tfm_alg_alignmask(crypto_shash_tfm(tfm)); | ||
| 232 | } | ||
| 233 | |||
| 234 | static inline struct shash_alg *__crypto_shash_alg(struct crypto_alg *alg) | ||
| 235 | { | ||
| 236 | return container_of(alg, struct shash_alg, base); | ||
| 237 | } | ||
| 238 | |||
| 239 | static inline struct shash_alg *crypto_shash_alg(struct crypto_shash *tfm) | ||
| 240 | { | ||
| 241 | return __crypto_shash_alg(crypto_shash_tfm(tfm)->__crt_alg); | ||
| 242 | } | ||
| 243 | |||
| 244 | static inline unsigned int crypto_shash_digestsize(struct crypto_shash *tfm) | ||
| 245 | { | ||
| 246 | return crypto_shash_alg(tfm)->digestsize; | ||
| 247 | } | ||
| 248 | |||
| 249 | static inline u32 crypto_shash_get_flags(struct crypto_shash *tfm) | ||
| 250 | { | ||
| 251 | return crypto_tfm_get_flags(crypto_shash_tfm(tfm)); | ||
| 252 | } | ||
| 253 | |||
| 254 | static inline void crypto_shash_set_flags(struct crypto_shash *tfm, u32 flags) | ||
| 255 | { | ||
| 256 | crypto_tfm_set_flags(crypto_shash_tfm(tfm), flags); | ||
| 257 | } | ||
| 258 | |||
| 259 | static inline void crypto_shash_clear_flags(struct crypto_shash *tfm, u32 flags) | ||
| 260 | { | ||
| 261 | crypto_tfm_clear_flags(crypto_shash_tfm(tfm), flags); | ||
| 262 | } | ||
| 263 | |||
| 264 | static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm) | ||
| 265 | { | ||
| 266 | return crypto_shash_alg(tfm)->descsize; | ||
| 267 | } | ||
| 268 | |||
| 269 | static inline void *shash_desc_ctx(struct shash_desc *desc) | ||
| 270 | { | ||
| 271 | return desc->__ctx; | ||
| 272 | } | ||
| 273 | |||
| 274 | int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, | ||
| 275 | unsigned int keylen); | ||
| 276 | int crypto_shash_digest(struct shash_desc *desc, const u8 *data, | ||
| 277 | unsigned int len, u8 *out); | ||
| 278 | |||
| 279 | static inline void crypto_shash_export(struct shash_desc *desc, u8 *out) | ||
| 280 | { | ||
| 281 | memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm)); | ||
| 282 | } | ||
| 283 | |||
| 284 | int crypto_shash_import(struct shash_desc *desc, const u8 *in); | ||
| 285 | |||
| 286 | static inline int crypto_shash_init(struct shash_desc *desc) | ||
| 287 | { | ||
| 288 | return crypto_shash_alg(desc->tfm)->init(desc); | ||
| 289 | } | ||
| 290 | |||
| 291 | int crypto_shash_update(struct shash_desc *desc, const u8 *data, | ||
| 292 | unsigned int len); | ||
| 293 | int crypto_shash_final(struct shash_desc *desc, u8 *out); | ||
| 294 | int crypto_shash_finup(struct shash_desc *desc, const u8 *data, | ||
| 295 | unsigned int len, u8 *out); | ||
| 296 | |||
| 172 | #endif /* _CRYPTO_HASH_H */ | 297 | #endif /* _CRYPTO_HASH_H */ |
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 917ae57bad4a..82b70564bcab 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
| @@ -39,6 +39,12 @@ extern const struct crypto_type crypto_ahash_type; | |||
| 39 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); | 39 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); |
| 40 | int crypto_hash_walk_first(struct ahash_request *req, | 40 | int crypto_hash_walk_first(struct ahash_request *req, |
| 41 | struct crypto_hash_walk *walk); | 41 | struct crypto_hash_walk *walk); |
| 42 | int crypto_hash_walk_first_compat(struct hash_desc *hdesc, | ||
| 43 | struct crypto_hash_walk *walk, | ||
| 44 | struct scatterlist *sg, unsigned int len); | ||
| 45 | |||
| 46 | int crypto_register_shash(struct shash_alg *alg); | ||
| 47 | int crypto_unregister_shash(struct shash_alg *alg); | ||
| 42 | 48 | ||
| 43 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) | 49 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) |
| 44 | { | 50 | { |
| @@ -63,16 +69,16 @@ static inline struct ahash_request *ahash_dequeue_request( | |||
| 63 | return ahash_request_cast(crypto_dequeue_request(queue)); | 69 | return ahash_request_cast(crypto_dequeue_request(queue)); |
| 64 | } | 70 | } |
| 65 | 71 | ||
| 66 | static inline void *ahash_request_ctx(struct ahash_request *req) | ||
| 67 | { | ||
| 68 | return req->__ctx; | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline int ahash_tfm_in_queue(struct crypto_queue *queue, | 72 | static inline int ahash_tfm_in_queue(struct crypto_queue *queue, |
| 72 | struct crypto_ahash *tfm) | 73 | struct crypto_ahash *tfm) |
| 73 | { | 74 | { |
| 74 | return crypto_tfm_in_queue(queue, crypto_ahash_tfm(tfm)); | 75 | return crypto_tfm_in_queue(queue, crypto_ahash_tfm(tfm)); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 78 | static inline void *crypto_shash_ctx(struct crypto_shash *tfm) | ||
| 79 | { | ||
| 80 | return crypto_tfm_ctx(&tfm->base); | ||
| 81 | } | ||
| 82 | |||
| 77 | #endif /* _CRYPTO_INTERNAL_HASH_H */ | 83 | #endif /* _CRYPTO_INTERNAL_HASH_H */ |
| 78 | 84 | ||
