diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/crypto/algapi.h | 37 | ||||
| -rw-r--r-- | include/crypto/cryptd.h | 17 | ||||
| -rw-r--r-- | include/crypto/hash.h | 147 | ||||
| -rw-r--r-- | include/crypto/internal/hash.h | 147 | ||||
| -rw-r--r-- | include/crypto/sha.h | 20 | ||||
| -rw-r--r-- | include/crypto/vmac.h | 61 | ||||
| -rw-r--r-- | include/linux/crypto.h | 43 | ||||
| -rw-r--r-- | include/linux/fips.h | 10 |
8 files changed, 378 insertions, 104 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 5a2bd1cc9656..1ffb53f74d37 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h | |||
| @@ -22,11 +22,9 @@ 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, | 25 | unsigned int (*extsize)(struct crypto_alg *alg); |
| 26 | const struct crypto_type *frontend); | ||
| 27 | int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); | 26 | int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); |
| 28 | int (*init_tfm)(struct crypto_tfm *tfm, | 27 | int (*init_tfm)(struct crypto_tfm *tfm); |
| 29 | const struct crypto_type *frontend); | ||
| 30 | void (*show)(struct seq_file *m, struct crypto_alg *alg); | 28 | void (*show)(struct seq_file *m, struct crypto_alg *alg); |
| 31 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); | 29 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); |
| 32 | 30 | ||
| @@ -52,6 +50,7 @@ struct crypto_template { | |||
| 52 | 50 | ||
| 53 | struct crypto_instance *(*alloc)(struct rtattr **tb); | 51 | struct crypto_instance *(*alloc)(struct rtattr **tb); |
| 54 | void (*free)(struct crypto_instance *inst); | 52 | void (*free)(struct crypto_instance *inst); |
| 53 | int (*create)(struct crypto_template *tmpl, struct rtattr **tb); | ||
| 55 | 54 | ||
| 56 | char name[CRYPTO_MAX_ALG_NAME]; | 55 | char name[CRYPTO_MAX_ALG_NAME]; |
| 57 | }; | 56 | }; |
| @@ -60,6 +59,7 @@ struct crypto_spawn { | |||
| 60 | struct list_head list; | 59 | struct list_head list; |
| 61 | struct crypto_alg *alg; | 60 | struct crypto_alg *alg; |
| 62 | struct crypto_instance *inst; | 61 | struct crypto_instance *inst; |
| 62 | const struct crypto_type *frontend; | ||
| 63 | u32 mask; | 63 | u32 mask; |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| @@ -114,11 +114,19 @@ int crypto_register_template(struct crypto_template *tmpl); | |||
| 114 | void crypto_unregister_template(struct crypto_template *tmpl); | 114 | void crypto_unregister_template(struct crypto_template *tmpl); |
| 115 | struct crypto_template *crypto_lookup_template(const char *name); | 115 | struct crypto_template *crypto_lookup_template(const char *name); |
| 116 | 116 | ||
| 117 | int crypto_register_instance(struct crypto_template *tmpl, | ||
| 118 | struct crypto_instance *inst); | ||
| 119 | |||
| 117 | int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, | 120 | int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, |
| 118 | struct crypto_instance *inst, u32 mask); | 121 | struct crypto_instance *inst, u32 mask); |
| 122 | int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg, | ||
| 123 | struct crypto_instance *inst, | ||
| 124 | const struct crypto_type *frontend); | ||
| 125 | |||
| 119 | void crypto_drop_spawn(struct crypto_spawn *spawn); | 126 | void crypto_drop_spawn(struct crypto_spawn *spawn); |
| 120 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, | 127 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, |
| 121 | u32 mask); | 128 | u32 mask); |
| 129 | void *crypto_spawn_tfm2(struct crypto_spawn *spawn); | ||
| 122 | 130 | ||
| 123 | static inline void crypto_set_spawn(struct crypto_spawn *spawn, | 131 | static inline void crypto_set_spawn(struct crypto_spawn *spawn, |
| 124 | struct crypto_instance *inst) | 132 | struct crypto_instance *inst) |
| @@ -129,8 +137,19 @@ static inline void crypto_set_spawn(struct crypto_spawn *spawn, | |||
| 129 | struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); | 137 | struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); |
| 130 | int crypto_check_attr_type(struct rtattr **tb, u32 type); | 138 | int crypto_check_attr_type(struct rtattr **tb, u32 type); |
| 131 | const char *crypto_attr_alg_name(struct rtattr *rta); | 139 | const char *crypto_attr_alg_name(struct rtattr *rta); |
| 132 | struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask); | 140 | struct crypto_alg *crypto_attr_alg2(struct rtattr *rta, |
| 141 | const struct crypto_type *frontend, | ||
| 142 | u32 type, u32 mask); | ||
| 143 | |||
| 144 | static inline struct crypto_alg *crypto_attr_alg(struct rtattr *rta, | ||
| 145 | u32 type, u32 mask) | ||
| 146 | { | ||
| 147 | return crypto_attr_alg2(rta, NULL, type, mask); | ||
| 148 | } | ||
| 149 | |||
| 133 | int crypto_attr_u32(struct rtattr *rta, u32 *num); | 150 | int crypto_attr_u32(struct rtattr *rta, u32 *num); |
| 151 | void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg, | ||
| 152 | unsigned int head); | ||
| 134 | struct crypto_instance *crypto_alloc_instance(const char *name, | 153 | struct crypto_instance *crypto_alloc_instance(const char *name, |
| 135 | struct crypto_alg *alg); | 154 | struct crypto_alg *alg); |
| 136 | 155 | ||
| @@ -157,12 +176,8 @@ int blkcipher_walk_virt_block(struct blkcipher_desc *desc, | |||
| 157 | 176 | ||
| 158 | static inline void *crypto_tfm_ctx_aligned(struct crypto_tfm *tfm) | 177 | static inline void *crypto_tfm_ctx_aligned(struct crypto_tfm *tfm) |
| 159 | { | 178 | { |
| 160 | unsigned long addr = (unsigned long)crypto_tfm_ctx(tfm); | 179 | return PTR_ALIGN(crypto_tfm_ctx(tfm), |
| 161 | unsigned long align = crypto_tfm_alg_alignmask(tfm); | 180 | crypto_tfm_alg_alignmask(tfm) + 1); |
| 162 | |||
| 163 | if (align <= crypto_tfm_ctx_alignment()) | ||
| 164 | align = 1; | ||
| 165 | return (void *)ALIGN(addr, align); | ||
| 166 | } | 181 | } |
| 167 | 182 | ||
| 168 | static inline struct crypto_instance *crypto_tfm_alg_instance( | 183 | static inline struct crypto_instance *crypto_tfm_alg_instance( |
diff --git a/include/crypto/cryptd.h b/include/crypto/cryptd.h index 55fa7bbdbc71..2f65a6e8ea4d 100644 --- a/include/crypto/cryptd.h +++ b/include/crypto/cryptd.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include <linux/crypto.h> | 8 | #include <linux/crypto.h> |
| 9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
| 10 | #include <crypto/hash.h> | ||
| 10 | 11 | ||
| 11 | struct cryptd_ablkcipher { | 12 | struct cryptd_ablkcipher { |
| 12 | struct crypto_ablkcipher base; | 13 | struct crypto_ablkcipher base; |
| @@ -24,4 +25,20 @@ struct cryptd_ablkcipher *cryptd_alloc_ablkcipher(const char *alg_name, | |||
| 24 | struct crypto_blkcipher *cryptd_ablkcipher_child(struct cryptd_ablkcipher *tfm); | 25 | struct crypto_blkcipher *cryptd_ablkcipher_child(struct cryptd_ablkcipher *tfm); |
| 25 | void cryptd_free_ablkcipher(struct cryptd_ablkcipher *tfm); | 26 | void cryptd_free_ablkcipher(struct cryptd_ablkcipher *tfm); |
| 26 | 27 | ||
| 28 | struct cryptd_ahash { | ||
| 29 | struct crypto_ahash base; | ||
| 30 | }; | ||
| 31 | |||
| 32 | static inline struct cryptd_ahash *__cryptd_ahash_cast( | ||
| 33 | struct crypto_ahash *tfm) | ||
| 34 | { | ||
| 35 | return (struct cryptd_ahash *)tfm; | ||
| 36 | } | ||
| 37 | |||
| 38 | /* alg_name should be algorithm to be cryptd-ed */ | ||
| 39 | struct cryptd_ahash *cryptd_alloc_ahash(const char *alg_name, | ||
| 40 | u32 type, u32 mask); | ||
| 41 | struct crypto_shash *cryptd_ahash_child(struct cryptd_ahash *tfm); | ||
| 42 | void cryptd_free_ahash(struct cryptd_ahash *tfm); | ||
| 43 | |||
| 27 | #endif | 44 | #endif |
diff --git a/include/crypto/hash.h b/include/crypto/hash.h index d56bb71617c3..26cb1eb16f4c 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h | |||
| @@ -15,6 +15,42 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/crypto.h> | 16 | #include <linux/crypto.h> |
| 17 | 17 | ||
| 18 | struct crypto_ahash; | ||
| 19 | |||
| 20 | struct hash_alg_common { | ||
| 21 | unsigned int digestsize; | ||
| 22 | unsigned int statesize; | ||
| 23 | |||
| 24 | struct crypto_alg base; | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct ahash_request { | ||
| 28 | struct crypto_async_request base; | ||
| 29 | |||
| 30 | unsigned int nbytes; | ||
| 31 | struct scatterlist *src; | ||
| 32 | u8 *result; | ||
| 33 | |||
| 34 | /* This field may only be used by the ahash API code. */ | ||
| 35 | void *priv; | ||
| 36 | |||
| 37 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | ||
| 38 | }; | ||
| 39 | |||
| 40 | struct ahash_alg { | ||
| 41 | int (*init)(struct ahash_request *req); | ||
| 42 | int (*update)(struct ahash_request *req); | ||
| 43 | int (*final)(struct ahash_request *req); | ||
| 44 | int (*finup)(struct ahash_request *req); | ||
| 45 | int (*digest)(struct ahash_request *req); | ||
| 46 | int (*export)(struct ahash_request *req, void *out); | ||
| 47 | int (*import)(struct ahash_request *req, const void *in); | ||
| 48 | int (*setkey)(struct crypto_ahash *tfm, const u8 *key, | ||
| 49 | unsigned int keylen); | ||
| 50 | |||
| 51 | struct hash_alg_common halg; | ||
| 52 | }; | ||
| 53 | |||
| 18 | struct shash_desc { | 54 | struct shash_desc { |
| 19 | struct crypto_shash *tfm; | 55 | struct crypto_shash *tfm; |
| 20 | u32 flags; | 56 | u32 flags; |
| @@ -24,7 +60,6 @@ struct shash_desc { | |||
| 24 | 60 | ||
| 25 | struct shash_alg { | 61 | struct shash_alg { |
| 26 | int (*init)(struct shash_desc *desc); | 62 | int (*init)(struct shash_desc *desc); |
| 27 | int (*reinit)(struct shash_desc *desc); | ||
| 28 | int (*update)(struct shash_desc *desc, const u8 *data, | 63 | int (*update)(struct shash_desc *desc, const u8 *data, |
| 29 | unsigned int len); | 64 | unsigned int len); |
| 30 | int (*final)(struct shash_desc *desc, u8 *out); | 65 | int (*final)(struct shash_desc *desc, u8 *out); |
| @@ -32,38 +67,48 @@ struct shash_alg { | |||
| 32 | unsigned int len, u8 *out); | 67 | unsigned int len, u8 *out); |
| 33 | int (*digest)(struct shash_desc *desc, const u8 *data, | 68 | int (*digest)(struct shash_desc *desc, const u8 *data, |
| 34 | unsigned int len, u8 *out); | 69 | unsigned int len, u8 *out); |
| 70 | int (*export)(struct shash_desc *desc, void *out); | ||
| 71 | int (*import)(struct shash_desc *desc, const void *in); | ||
| 35 | int (*setkey)(struct crypto_shash *tfm, const u8 *key, | 72 | int (*setkey)(struct crypto_shash *tfm, const u8 *key, |
| 36 | unsigned int keylen); | 73 | unsigned int keylen); |
| 37 | 74 | ||
| 38 | unsigned int descsize; | 75 | unsigned int descsize; |
| 39 | unsigned int digestsize; | 76 | |
| 77 | /* These fields must match hash_alg_common. */ | ||
| 78 | unsigned int digestsize | ||
| 79 | __attribute__ ((aligned(__alignof__(struct hash_alg_common)))); | ||
| 80 | unsigned int statesize; | ||
| 40 | 81 | ||
| 41 | struct crypto_alg base; | 82 | struct crypto_alg base; |
| 42 | }; | 83 | }; |
| 43 | 84 | ||
| 44 | struct crypto_ahash { | 85 | struct crypto_ahash { |
| 86 | int (*init)(struct ahash_request *req); | ||
| 87 | int (*update)(struct ahash_request *req); | ||
| 88 | int (*final)(struct ahash_request *req); | ||
| 89 | int (*finup)(struct ahash_request *req); | ||
| 90 | int (*digest)(struct ahash_request *req); | ||
| 91 | int (*export)(struct ahash_request *req, void *out); | ||
| 92 | int (*import)(struct ahash_request *req, const void *in); | ||
| 93 | int (*setkey)(struct crypto_ahash *tfm, const u8 *key, | ||
| 94 | unsigned int keylen); | ||
| 95 | |||
| 96 | unsigned int reqsize; | ||
| 45 | struct crypto_tfm base; | 97 | struct crypto_tfm base; |
| 46 | }; | 98 | }; |
| 47 | 99 | ||
| 48 | struct crypto_shash { | 100 | struct crypto_shash { |
| 101 | unsigned int descsize; | ||
| 49 | struct crypto_tfm base; | 102 | struct crypto_tfm base; |
| 50 | }; | 103 | }; |
| 51 | 104 | ||
| 52 | static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm) | 105 | static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm) |
| 53 | { | 106 | { |
| 54 | return (struct crypto_ahash *)tfm; | 107 | return container_of(tfm, struct crypto_ahash, base); |
| 55 | } | 108 | } |
| 56 | 109 | ||
| 57 | static inline struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, | 110 | struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, u32 type, |
| 58 | u32 type, u32 mask) | 111 | u32 mask); |
| 59 | { | ||
| 60 | type &= ~CRYPTO_ALG_TYPE_MASK; | ||
| 61 | mask &= ~CRYPTO_ALG_TYPE_MASK; | ||
| 62 | type |= CRYPTO_ALG_TYPE_AHASH; | ||
| 63 | mask |= CRYPTO_ALG_TYPE_AHASH_MASK; | ||
| 64 | |||
| 65 | return __crypto_ahash_cast(crypto_alloc_base(alg_name, type, mask)); | ||
| 66 | } | ||
| 67 | 112 | ||
| 68 | static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm) | 113 | static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm) |
| 69 | { | 114 | { |
| @@ -72,7 +117,7 @@ static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm) | |||
| 72 | 117 | ||
| 73 | static inline void crypto_free_ahash(struct crypto_ahash *tfm) | 118 | static inline void crypto_free_ahash(struct crypto_ahash *tfm) |
| 74 | { | 119 | { |
| 75 | crypto_free_tfm(crypto_ahash_tfm(tfm)); | 120 | crypto_destroy_tfm(tfm, crypto_ahash_tfm(tfm)); |
| 76 | } | 121 | } |
| 77 | 122 | ||
| 78 | static inline unsigned int crypto_ahash_alignmask( | 123 | static inline unsigned int crypto_ahash_alignmask( |
| @@ -81,14 +126,26 @@ static inline unsigned int crypto_ahash_alignmask( | |||
| 81 | return crypto_tfm_alg_alignmask(crypto_ahash_tfm(tfm)); | 126 | return crypto_tfm_alg_alignmask(crypto_ahash_tfm(tfm)); |
| 82 | } | 127 | } |
| 83 | 128 | ||
| 84 | static inline struct ahash_tfm *crypto_ahash_crt(struct crypto_ahash *tfm) | 129 | static inline struct hash_alg_common *__crypto_hash_alg_common( |
| 130 | struct crypto_alg *alg) | ||
| 131 | { | ||
| 132 | return container_of(alg, struct hash_alg_common, base); | ||
| 133 | } | ||
| 134 | |||
| 135 | static inline struct hash_alg_common *crypto_hash_alg_common( | ||
| 136 | struct crypto_ahash *tfm) | ||
| 85 | { | 137 | { |
| 86 | return &crypto_ahash_tfm(tfm)->crt_ahash; | 138 | return __crypto_hash_alg_common(crypto_ahash_tfm(tfm)->__crt_alg); |
| 87 | } | 139 | } |
| 88 | 140 | ||
| 89 | static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm) | 141 | static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm) |
| 90 | { | 142 | { |
| 91 | return crypto_ahash_crt(tfm)->digestsize; | 143 | return crypto_hash_alg_common(tfm)->digestsize; |
| 144 | } | ||
| 145 | |||
| 146 | static inline unsigned int crypto_ahash_statesize(struct crypto_ahash *tfm) | ||
| 147 | { | ||
| 148 | return crypto_hash_alg_common(tfm)->statesize; | ||
| 92 | } | 149 | } |
| 93 | 150 | ||
| 94 | static inline u32 crypto_ahash_get_flags(struct crypto_ahash *tfm) | 151 | static inline u32 crypto_ahash_get_flags(struct crypto_ahash *tfm) |
| @@ -114,7 +171,7 @@ static inline struct crypto_ahash *crypto_ahash_reqtfm( | |||
| 114 | 171 | ||
| 115 | static inline unsigned int crypto_ahash_reqsize(struct crypto_ahash *tfm) | 172 | static inline unsigned int crypto_ahash_reqsize(struct crypto_ahash *tfm) |
| 116 | { | 173 | { |
| 117 | return crypto_ahash_crt(tfm)->reqsize; | 174 | return tfm->reqsize; |
| 118 | } | 175 | } |
| 119 | 176 | ||
| 120 | static inline void *ahash_request_ctx(struct ahash_request *req) | 177 | static inline void *ahash_request_ctx(struct ahash_request *req) |
| @@ -122,44 +179,30 @@ static inline void *ahash_request_ctx(struct ahash_request *req) | |||
| 122 | return req->__ctx; | 179 | return req->__ctx; |
| 123 | } | 180 | } |
| 124 | 181 | ||
| 125 | static inline int crypto_ahash_setkey(struct crypto_ahash *tfm, | 182 | int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key, |
| 126 | const u8 *key, unsigned int keylen) | 183 | unsigned int keylen); |
| 127 | { | 184 | int crypto_ahash_finup(struct ahash_request *req); |
| 128 | struct ahash_tfm *crt = crypto_ahash_crt(tfm); | 185 | int crypto_ahash_final(struct ahash_request *req); |
| 129 | 186 | int crypto_ahash_digest(struct ahash_request *req); | |
| 130 | return crt->setkey(tfm, key, keylen); | ||
| 131 | } | ||
| 132 | 187 | ||
| 133 | static inline int crypto_ahash_digest(struct ahash_request *req) | 188 | static inline int crypto_ahash_export(struct ahash_request *req, void *out) |
| 134 | { | 189 | { |
| 135 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); | 190 | return crypto_ahash_reqtfm(req)->export(req, out); |
| 136 | return crt->digest(req); | ||
| 137 | } | 191 | } |
| 138 | 192 | ||
| 139 | static inline void crypto_ahash_export(struct ahash_request *req, u8 *out) | 193 | static inline int crypto_ahash_import(struct ahash_request *req, const void *in) |
| 140 | { | 194 | { |
| 141 | memcpy(out, ahash_request_ctx(req), | 195 | return crypto_ahash_reqtfm(req)->import(req, in); |
| 142 | crypto_ahash_reqsize(crypto_ahash_reqtfm(req))); | ||
| 143 | } | 196 | } |
| 144 | 197 | ||
| 145 | int crypto_ahash_import(struct ahash_request *req, const u8 *in); | ||
| 146 | |||
| 147 | static inline int crypto_ahash_init(struct ahash_request *req) | 198 | static inline int crypto_ahash_init(struct ahash_request *req) |
| 148 | { | 199 | { |
| 149 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); | 200 | return crypto_ahash_reqtfm(req)->init(req); |
| 150 | return crt->init(req); | ||
| 151 | } | 201 | } |
| 152 | 202 | ||
| 153 | static inline int crypto_ahash_update(struct ahash_request *req) | 203 | static inline int crypto_ahash_update(struct ahash_request *req) |
| 154 | { | 204 | { |
| 155 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); | 205 | return crypto_ahash_reqtfm(req)->update(req); |
| 156 | return crt->update(req); | ||
| 157 | } | ||
| 158 | |||
| 159 | static inline int crypto_ahash_final(struct ahash_request *req) | ||
| 160 | { | ||
| 161 | struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req)); | ||
| 162 | return crt->final(req); | ||
| 163 | } | 206 | } |
| 164 | 207 | ||
| 165 | static inline void ahash_request_set_tfm(struct ahash_request *req, | 208 | static inline void ahash_request_set_tfm(struct ahash_request *req, |
| @@ -184,7 +227,7 @@ static inline struct ahash_request *ahash_request_alloc( | |||
| 184 | 227 | ||
| 185 | static inline void ahash_request_free(struct ahash_request *req) | 228 | static inline void ahash_request_free(struct ahash_request *req) |
| 186 | { | 229 | { |
| 187 | kfree(req); | 230 | kzfree(req); |
| 188 | } | 231 | } |
| 189 | 232 | ||
| 190 | static inline struct ahash_request *ahash_request_cast( | 233 | static inline struct ahash_request *ahash_request_cast( |
| @@ -251,6 +294,11 @@ static inline unsigned int crypto_shash_digestsize(struct crypto_shash *tfm) | |||
| 251 | return crypto_shash_alg(tfm)->digestsize; | 294 | return crypto_shash_alg(tfm)->digestsize; |
| 252 | } | 295 | } |
| 253 | 296 | ||
| 297 | static inline unsigned int crypto_shash_statesize(struct crypto_shash *tfm) | ||
| 298 | { | ||
| 299 | return crypto_shash_alg(tfm)->statesize; | ||
| 300 | } | ||
| 301 | |||
| 254 | static inline u32 crypto_shash_get_flags(struct crypto_shash *tfm) | 302 | static inline u32 crypto_shash_get_flags(struct crypto_shash *tfm) |
| 255 | { | 303 | { |
| 256 | return crypto_tfm_get_flags(crypto_shash_tfm(tfm)); | 304 | return crypto_tfm_get_flags(crypto_shash_tfm(tfm)); |
| @@ -268,7 +316,7 @@ static inline void crypto_shash_clear_flags(struct crypto_shash *tfm, u32 flags) | |||
| 268 | 316 | ||
| 269 | static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm) | 317 | static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm) |
| 270 | { | 318 | { |
| 271 | return crypto_shash_alg(tfm)->descsize; | 319 | return tfm->descsize; |
| 272 | } | 320 | } |
| 273 | 321 | ||
| 274 | static inline void *shash_desc_ctx(struct shash_desc *desc) | 322 | static inline void *shash_desc_ctx(struct shash_desc *desc) |
| @@ -281,12 +329,15 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, | |||
| 281 | int crypto_shash_digest(struct shash_desc *desc, const u8 *data, | 329 | int crypto_shash_digest(struct shash_desc *desc, const u8 *data, |
| 282 | unsigned int len, u8 *out); | 330 | unsigned int len, u8 *out); |
| 283 | 331 | ||
| 284 | static inline void crypto_shash_export(struct shash_desc *desc, u8 *out) | 332 | static inline int crypto_shash_export(struct shash_desc *desc, void *out) |
| 285 | { | 333 | { |
| 286 | memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm)); | 334 | return crypto_shash_alg(desc->tfm)->export(desc, out); |
| 287 | } | 335 | } |
| 288 | 336 | ||
| 289 | int crypto_shash_import(struct shash_desc *desc, const u8 *in); | 337 | static inline int crypto_shash_import(struct shash_desc *desc, const void *in) |
| 338 | { | ||
| 339 | return crypto_shash_alg(desc->tfm)->import(desc, in); | ||
| 340 | } | ||
| 290 | 341 | ||
| 291 | static inline int crypto_shash_init(struct shash_desc *desc) | 342 | static inline int crypto_shash_init(struct shash_desc *desc) |
| 292 | { | 343 | { |
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 82b70564bcab..5bfad8c80595 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
| @@ -34,6 +34,22 @@ struct crypto_hash_walk { | |||
| 34 | unsigned int flags; | 34 | unsigned int flags; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | struct ahash_instance { | ||
| 38 | struct ahash_alg alg; | ||
| 39 | }; | ||
| 40 | |||
| 41 | struct shash_instance { | ||
| 42 | struct shash_alg alg; | ||
| 43 | }; | ||
| 44 | |||
| 45 | struct crypto_ahash_spawn { | ||
| 46 | struct crypto_spawn base; | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct crypto_shash_spawn { | ||
| 50 | struct crypto_spawn base; | ||
| 51 | }; | ||
| 52 | |||
| 37 | extern const struct crypto_type crypto_ahash_type; | 53 | extern const struct crypto_type crypto_ahash_type; |
| 38 | 54 | ||
| 39 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); | 55 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); |
| @@ -43,18 +59,100 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc, | |||
| 43 | struct crypto_hash_walk *walk, | 59 | struct crypto_hash_walk *walk, |
| 44 | struct scatterlist *sg, unsigned int len); | 60 | struct scatterlist *sg, unsigned int len); |
| 45 | 61 | ||
| 62 | static inline int crypto_hash_walk_last(struct crypto_hash_walk *walk) | ||
| 63 | { | ||
| 64 | return !(walk->entrylen | walk->total); | ||
| 65 | } | ||
| 66 | |||
| 67 | int crypto_register_ahash(struct ahash_alg *alg); | ||
| 68 | int crypto_unregister_ahash(struct ahash_alg *alg); | ||
| 69 | int ahash_register_instance(struct crypto_template *tmpl, | ||
| 70 | struct ahash_instance *inst); | ||
| 71 | void ahash_free_instance(struct crypto_instance *inst); | ||
| 72 | |||
| 73 | int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn, | ||
| 74 | struct hash_alg_common *alg, | ||
| 75 | struct crypto_instance *inst); | ||
| 76 | |||
| 77 | static inline void crypto_drop_ahash(struct crypto_ahash_spawn *spawn) | ||
| 78 | { | ||
| 79 | crypto_drop_spawn(&spawn->base); | ||
| 80 | } | ||
| 81 | |||
| 82 | struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask); | ||
| 83 | |||
| 46 | int crypto_register_shash(struct shash_alg *alg); | 84 | int crypto_register_shash(struct shash_alg *alg); |
| 47 | int crypto_unregister_shash(struct shash_alg *alg); | 85 | int crypto_unregister_shash(struct shash_alg *alg); |
| 86 | int shash_register_instance(struct crypto_template *tmpl, | ||
| 87 | struct shash_instance *inst); | ||
| 88 | void shash_free_instance(struct crypto_instance *inst); | ||
| 89 | |||
| 90 | int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn, | ||
| 91 | struct shash_alg *alg, | ||
| 92 | struct crypto_instance *inst); | ||
| 93 | |||
| 94 | static inline void crypto_drop_shash(struct crypto_shash_spawn *spawn) | ||
| 95 | { | ||
| 96 | crypto_drop_spawn(&spawn->base); | ||
| 97 | } | ||
| 98 | |||
| 99 | struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask); | ||
| 100 | |||
| 101 | int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc); | ||
| 102 | int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc); | ||
| 103 | int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc); | ||
| 104 | |||
| 105 | int crypto_init_shash_ops_async(struct crypto_tfm *tfm); | ||
| 48 | 106 | ||
| 49 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) | 107 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) |
| 50 | { | 108 | { |
| 51 | return crypto_tfm_ctx(&tfm->base); | 109 | return crypto_tfm_ctx(crypto_ahash_tfm(tfm)); |
| 110 | } | ||
| 111 | |||
| 112 | static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg) | ||
| 113 | { | ||
| 114 | return container_of(__crypto_hash_alg_common(alg), struct ahash_alg, | ||
| 115 | halg); | ||
| 116 | } | ||
| 117 | |||
| 118 | static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm, | ||
| 119 | unsigned int reqsize) | ||
| 120 | { | ||
| 121 | tfm->reqsize = reqsize; | ||
| 122 | } | ||
| 123 | |||
| 124 | static inline struct crypto_instance *ahash_crypto_instance( | ||
| 125 | struct ahash_instance *inst) | ||
| 126 | { | ||
| 127 | return container_of(&inst->alg.halg.base, struct crypto_instance, alg); | ||
| 52 | } | 128 | } |
| 53 | 129 | ||
| 54 | static inline struct ahash_alg *crypto_ahash_alg( | 130 | static inline struct ahash_instance *ahash_instance( |
| 55 | struct crypto_ahash *tfm) | 131 | struct crypto_instance *inst) |
| 56 | { | 132 | { |
| 57 | return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash; | 133 | return container_of(&inst->alg, struct ahash_instance, alg.halg.base); |
| 134 | } | ||
| 135 | |||
| 136 | static inline void *ahash_instance_ctx(struct ahash_instance *inst) | ||
| 137 | { | ||
| 138 | return crypto_instance_ctx(ahash_crypto_instance(inst)); | ||
| 139 | } | ||
| 140 | |||
| 141 | static inline unsigned int ahash_instance_headroom(void) | ||
| 142 | { | ||
| 143 | return sizeof(struct ahash_alg) - sizeof(struct crypto_alg); | ||
| 144 | } | ||
| 145 | |||
| 146 | static inline struct ahash_instance *ahash_alloc_instance( | ||
| 147 | const char *name, struct crypto_alg *alg) | ||
| 148 | { | ||
| 149 | return crypto_alloc_instance2(name, alg, ahash_instance_headroom()); | ||
| 150 | } | ||
| 151 | |||
| 152 | static inline struct crypto_ahash *crypto_spawn_ahash( | ||
| 153 | struct crypto_ahash_spawn *spawn) | ||
| 154 | { | ||
| 155 | return crypto_spawn_tfm2(&spawn->base); | ||
| 58 | } | 156 | } |
| 59 | 157 | ||
| 60 | static inline int ahash_enqueue_request(struct crypto_queue *queue, | 158 | static inline int ahash_enqueue_request(struct crypto_queue *queue, |
| @@ -80,5 +178,46 @@ static inline void *crypto_shash_ctx(struct crypto_shash *tfm) | |||
| 80 | return crypto_tfm_ctx(&tfm->base); | 178 | return crypto_tfm_ctx(&tfm->base); |
| 81 | } | 179 | } |
| 82 | 180 | ||
| 181 | static inline struct crypto_instance *shash_crypto_instance( | ||
| 182 | struct shash_instance *inst) | ||
| 183 | { | ||
| 184 | return container_of(&inst->alg.base, struct crypto_instance, alg); | ||
| 185 | } | ||
| 186 | |||
| 187 | static inline struct shash_instance *shash_instance( | ||
| 188 | struct crypto_instance *inst) | ||
| 189 | { | ||
| 190 | return container_of(__crypto_shash_alg(&inst->alg), | ||
| 191 | struct shash_instance, alg); | ||
| 192 | } | ||
| 193 | |||
| 194 | static inline void *shash_instance_ctx(struct shash_instance *inst) | ||
| 195 | { | ||
| 196 | return crypto_instance_ctx(shash_crypto_instance(inst)); | ||
| 197 | } | ||
| 198 | |||
| 199 | static inline struct shash_instance *shash_alloc_instance( | ||
| 200 | const char *name, struct crypto_alg *alg) | ||
| 201 | { | ||
| 202 | return crypto_alloc_instance2(name, alg, | ||
| 203 | sizeof(struct shash_alg) - sizeof(*alg)); | ||
| 204 | } | ||
| 205 | |||
| 206 | static inline struct crypto_shash *crypto_spawn_shash( | ||
| 207 | struct crypto_shash_spawn *spawn) | ||
| 208 | { | ||
| 209 | return crypto_spawn_tfm2(&spawn->base); | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline void *crypto_shash_ctx_aligned(struct crypto_shash *tfm) | ||
| 213 | { | ||
| 214 | return crypto_tfm_ctx_aligned(&tfm->base); | ||
| 215 | } | ||
| 216 | |||
| 217 | static inline struct crypto_shash *__crypto_shash_cast(struct crypto_tfm *tfm) | ||
| 218 | { | ||
| 219 | return container_of(tfm, struct crypto_shash, base); | ||
| 220 | } | ||
| 221 | |||
| 83 | #endif /* _CRYPTO_INTERNAL_HASH_H */ | 222 | #endif /* _CRYPTO_INTERNAL_HASH_H */ |
| 84 | 223 | ||
diff --git a/include/crypto/sha.h b/include/crypto/sha.h index c0ccc2b1a2d8..069e85ba97e1 100644 --- a/include/crypto/sha.h +++ b/include/crypto/sha.h | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #ifndef _CRYPTO_SHA_H | 5 | #ifndef _CRYPTO_SHA_H |
| 6 | #define _CRYPTO_SHA_H | 6 | #define _CRYPTO_SHA_H |
| 7 | 7 | ||
| 8 | #include <linux/types.h> | ||
| 9 | |||
| 8 | #define SHA1_DIGEST_SIZE 20 | 10 | #define SHA1_DIGEST_SIZE 20 |
| 9 | #define SHA1_BLOCK_SIZE 64 | 11 | #define SHA1_BLOCK_SIZE 64 |
| 10 | 12 | ||
| @@ -62,4 +64,22 @@ | |||
| 62 | #define SHA512_H6 0x1f83d9abfb41bd6bULL | 64 | #define SHA512_H6 0x1f83d9abfb41bd6bULL |
| 63 | #define SHA512_H7 0x5be0cd19137e2179ULL | 65 | #define SHA512_H7 0x5be0cd19137e2179ULL |
| 64 | 66 | ||
| 67 | struct sha1_state { | ||
| 68 | u64 count; | ||
| 69 | u32 state[SHA1_DIGEST_SIZE / 4]; | ||
| 70 | u8 buffer[SHA1_BLOCK_SIZE]; | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct sha256_state { | ||
| 74 | u64 count; | ||
| 75 | u32 state[SHA256_DIGEST_SIZE / 4]; | ||
| 76 | u8 buf[SHA256_BLOCK_SIZE]; | ||
| 77 | }; | ||
| 78 | |||
| 79 | struct sha512_state { | ||
| 80 | u64 count[2]; | ||
| 81 | u64 state[SHA512_DIGEST_SIZE / 8]; | ||
| 82 | u8 buf[SHA512_BLOCK_SIZE]; | ||
| 83 | }; | ||
| 84 | |||
| 65 | #endif | 85 | #endif |
diff --git a/include/crypto/vmac.h b/include/crypto/vmac.h new file mode 100644 index 000000000000..c4467c55df1e --- /dev/null +++ b/include/crypto/vmac.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * Modified to interface to the Linux kernel | ||
| 3 | * Copyright (c) 2009, Intel Corporation. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms and conditions of the GNU General Public License, | ||
| 7 | * version 2, as published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along with | ||
| 15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 16 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __CRYPTO_VMAC_H | ||
| 20 | #define __CRYPTO_VMAC_H | ||
| 21 | |||
| 22 | /* -------------------------------------------------------------------------- | ||
| 23 | * VMAC and VHASH Implementation by Ted Krovetz (tdk@acm.org) and Wei Dai. | ||
| 24 | * This implementation is herby placed in the public domain. | ||
| 25 | * The authors offers no warranty. Use at your own risk. | ||
| 26 | * Please send bug reports to the authors. | ||
| 27 | * Last modified: 17 APR 08, 1700 PDT | ||
| 28 | * ----------------------------------------------------------------------- */ | ||
| 29 | |||
| 30 | /* | ||
| 31 | * User definable settings. | ||
| 32 | */ | ||
| 33 | #define VMAC_TAG_LEN 64 | ||
| 34 | #define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */ | ||
| 35 | #define VMAC_KEY_LEN (VMAC_KEY_SIZE/8) | ||
| 36 | #define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/ | ||
| 37 | |||
| 38 | /* | ||
| 39 | * This implementation uses u32 and u64 as names for unsigned 32- | ||
| 40 | * and 64-bit integer types. These are defined in C99 stdint.h. The | ||
| 41 | * following may need adaptation if you are not running a C99 or | ||
| 42 | * Microsoft C environment. | ||
| 43 | */ | ||
| 44 | struct vmac_ctx { | ||
| 45 | u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)]; | ||
| 46 | u64 polykey[2*VMAC_TAG_LEN/64]; | ||
| 47 | u64 l3key[2*VMAC_TAG_LEN/64]; | ||
| 48 | u64 polytmp[2*VMAC_TAG_LEN/64]; | ||
| 49 | u64 cached_nonce[2]; | ||
| 50 | u64 cached_aes[2]; | ||
| 51 | int first_block_processed; | ||
| 52 | }; | ||
| 53 | |||
| 54 | typedef u64 vmac_t; | ||
| 55 | |||
| 56 | struct vmac_ctx_t { | ||
| 57 | struct crypto_cipher *child; | ||
| 58 | struct vmac_ctx __vmac_ctx; | ||
| 59 | }; | ||
| 60 | |||
| 61 | #endif /* __CRYPTO_VMAC_H */ | ||
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index ec29fa268b94..fd929889e8dc 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
| @@ -115,7 +115,6 @@ struct crypto_async_request; | |||
| 115 | struct crypto_aead; | 115 | struct crypto_aead; |
| 116 | struct crypto_blkcipher; | 116 | struct crypto_blkcipher; |
| 117 | struct crypto_hash; | 117 | struct crypto_hash; |
| 118 | struct crypto_ahash; | ||
| 119 | struct crypto_rng; | 118 | struct crypto_rng; |
| 120 | struct crypto_tfm; | 119 | struct crypto_tfm; |
| 121 | struct crypto_type; | 120 | struct crypto_type; |
| @@ -146,16 +145,6 @@ struct ablkcipher_request { | |||
| 146 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | 145 | void *__ctx[] CRYPTO_MINALIGN_ATTR; |
| 147 | }; | 146 | }; |
| 148 | 147 | ||
| 149 | struct ahash_request { | ||
| 150 | struct crypto_async_request base; | ||
| 151 | |||
| 152 | unsigned int nbytes; | ||
| 153 | struct scatterlist *src; | ||
| 154 | u8 *result; | ||
| 155 | |||
| 156 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | ||
| 157 | }; | ||
| 158 | |||
| 159 | /** | 148 | /** |
| 160 | * struct aead_request - AEAD request | 149 | * struct aead_request - AEAD request |
| 161 | * @base: Common attributes for async crypto requests | 150 | * @base: Common attributes for async crypto requests |
| @@ -220,18 +209,6 @@ struct ablkcipher_alg { | |||
| 220 | unsigned int ivsize; | 209 | unsigned int ivsize; |
| 221 | }; | 210 | }; |
| 222 | 211 | ||
| 223 | struct ahash_alg { | ||
| 224 | int (*init)(struct ahash_request *req); | ||
| 225 | int (*reinit)(struct ahash_request *req); | ||
| 226 | int (*update)(struct ahash_request *req); | ||
| 227 | int (*final)(struct ahash_request *req); | ||
| 228 | int (*digest)(struct ahash_request *req); | ||
| 229 | int (*setkey)(struct crypto_ahash *tfm, const u8 *key, | ||
| 230 | unsigned int keylen); | ||
| 231 | |||
| 232 | unsigned int digestsize; | ||
| 233 | }; | ||
| 234 | |||
| 235 | struct aead_alg { | 212 | struct aead_alg { |
| 236 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | 213 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, |
| 237 | unsigned int keylen); | 214 | unsigned int keylen); |
| @@ -318,7 +295,6 @@ struct rng_alg { | |||
| 318 | #define cra_cipher cra_u.cipher | 295 | #define cra_cipher cra_u.cipher |
| 319 | #define cra_digest cra_u.digest | 296 | #define cra_digest cra_u.digest |
| 320 | #define cra_hash cra_u.hash | 297 | #define cra_hash cra_u.hash |
| 321 | #define cra_ahash cra_u.ahash | ||
| 322 | #define cra_compress cra_u.compress | 298 | #define cra_compress cra_u.compress |
| 323 | #define cra_rng cra_u.rng | 299 | #define cra_rng cra_u.rng |
| 324 | 300 | ||
| @@ -346,7 +322,6 @@ struct crypto_alg { | |||
| 346 | struct cipher_alg cipher; | 322 | struct cipher_alg cipher; |
| 347 | struct digest_alg digest; | 323 | struct digest_alg digest; |
| 348 | struct hash_alg hash; | 324 | struct hash_alg hash; |
| 349 | struct ahash_alg ahash; | ||
| 350 | struct compress_alg compress; | 325 | struct compress_alg compress; |
| 351 | struct rng_alg rng; | 326 | struct rng_alg rng; |
| 352 | } cra_u; | 327 | } cra_u; |
| @@ -433,18 +408,6 @@ struct hash_tfm { | |||
| 433 | unsigned int digestsize; | 408 | unsigned int digestsize; |
| 434 | }; | 409 | }; |
| 435 | 410 | ||
| 436 | struct ahash_tfm { | ||
| 437 | int (*init)(struct ahash_request *req); | ||
| 438 | int (*update)(struct ahash_request *req); | ||
| 439 | int (*final)(struct ahash_request *req); | ||
| 440 | int (*digest)(struct ahash_request *req); | ||
| 441 | int (*setkey)(struct crypto_ahash *tfm, const u8 *key, | ||
| 442 | unsigned int keylen); | ||
| 443 | |||
| 444 | unsigned int digestsize; | ||
| 445 | unsigned int reqsize; | ||
| 446 | }; | ||
| 447 | |||
| 448 | struct compress_tfm { | 411 | struct compress_tfm { |
| 449 | int (*cot_compress)(struct crypto_tfm *tfm, | 412 | int (*cot_compress)(struct crypto_tfm *tfm, |
| 450 | const u8 *src, unsigned int slen, | 413 | const u8 *src, unsigned int slen, |
| @@ -465,7 +428,6 @@ struct rng_tfm { | |||
| 465 | #define crt_blkcipher crt_u.blkcipher | 428 | #define crt_blkcipher crt_u.blkcipher |
| 466 | #define crt_cipher crt_u.cipher | 429 | #define crt_cipher crt_u.cipher |
| 467 | #define crt_hash crt_u.hash | 430 | #define crt_hash crt_u.hash |
| 468 | #define crt_ahash crt_u.ahash | ||
| 469 | #define crt_compress crt_u.compress | 431 | #define crt_compress crt_u.compress |
| 470 | #define crt_rng crt_u.rng | 432 | #define crt_rng crt_u.rng |
| 471 | 433 | ||
| @@ -479,7 +441,6 @@ struct crypto_tfm { | |||
| 479 | struct blkcipher_tfm blkcipher; | 441 | struct blkcipher_tfm blkcipher; |
| 480 | struct cipher_tfm cipher; | 442 | struct cipher_tfm cipher; |
| 481 | struct hash_tfm hash; | 443 | struct hash_tfm hash; |
| 482 | struct ahash_tfm ahash; | ||
| 483 | struct compress_tfm compress; | 444 | struct compress_tfm compress; |
| 484 | struct rng_tfm rng; | 445 | struct rng_tfm rng; |
| 485 | } crt_u; | 446 | } crt_u; |
| @@ -770,7 +731,7 @@ static inline struct ablkcipher_request *ablkcipher_request_alloc( | |||
| 770 | 731 | ||
| 771 | static inline void ablkcipher_request_free(struct ablkcipher_request *req) | 732 | static inline void ablkcipher_request_free(struct ablkcipher_request *req) |
| 772 | { | 733 | { |
| 773 | kfree(req); | 734 | kzfree(req); |
| 774 | } | 735 | } |
| 775 | 736 | ||
| 776 | static inline void ablkcipher_request_set_callback( | 737 | static inline void ablkcipher_request_set_callback( |
| @@ -901,7 +862,7 @@ static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, | |||
| 901 | 862 | ||
| 902 | static inline void aead_request_free(struct aead_request *req) | 863 | static inline void aead_request_free(struct aead_request *req) |
| 903 | { | 864 | { |
| 904 | kfree(req); | 865 | kzfree(req); |
| 905 | } | 866 | } |
| 906 | 867 | ||
| 907 | static inline void aead_request_set_callback(struct aead_request *req, | 868 | static inline void aead_request_set_callback(struct aead_request *req, |
diff --git a/include/linux/fips.h b/include/linux/fips.h new file mode 100644 index 000000000000..f8fb07b0b6b8 --- /dev/null +++ b/include/linux/fips.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #ifndef _FIPS_H | ||
| 2 | #define _FIPS_H | ||
| 3 | |||
| 4 | #ifdef CONFIG_CRYPTO_FIPS | ||
| 5 | extern int fips_enabled; | ||
| 6 | #else | ||
| 7 | #define fips_enabled 0 | ||
| 8 | #endif | ||
| 9 | |||
| 10 | #endif | ||
