diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ablkcipher.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index 0083140304d2..e403d8137ecd 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
@@ -107,6 +107,52 @@ const struct crypto_type crypto_ablkcipher_type = { | |||
107 | }; | 107 | }; |
108 | EXPORT_SYMBOL_GPL(crypto_ablkcipher_type); | 108 | EXPORT_SYMBOL_GPL(crypto_ablkcipher_type); |
109 | 109 | ||
110 | static int no_givdecrypt(struct skcipher_givcrypt_request *req) | ||
111 | { | ||
112 | return -ENOSYS; | ||
113 | } | ||
114 | |||
115 | static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type, | ||
116 | u32 mask) | ||
117 | { | ||
118 | struct ablkcipher_alg *alg = &tfm->__crt_alg->cra_ablkcipher; | ||
119 | struct ablkcipher_tfm *crt = &tfm->crt_ablkcipher; | ||
120 | |||
121 | if (alg->ivsize > PAGE_SIZE / 8) | ||
122 | return -EINVAL; | ||
123 | |||
124 | crt->setkey = setkey; | ||
125 | crt->encrypt = alg->encrypt; | ||
126 | crt->decrypt = alg->decrypt; | ||
127 | crt->givencrypt = alg->givencrypt; | ||
128 | crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; | ||
129 | crt->ivsize = alg->ivsize; | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) | ||
135 | __attribute__ ((unused)); | ||
136 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) | ||
137 | { | ||
138 | struct ablkcipher_alg *ablkcipher = &alg->cra_ablkcipher; | ||
139 | |||
140 | seq_printf(m, "type : givcipher\n"); | ||
141 | seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); | ||
142 | seq_printf(m, "min keysize : %u\n", ablkcipher->min_keysize); | ||
143 | seq_printf(m, "max keysize : %u\n", ablkcipher->max_keysize); | ||
144 | seq_printf(m, "ivsize : %u\n", ablkcipher->ivsize); | ||
145 | } | ||
146 | |||
147 | const struct crypto_type crypto_givcipher_type = { | ||
148 | .ctxsize = crypto_ablkcipher_ctxsize, | ||
149 | .init = crypto_init_givcipher_ops, | ||
150 | #ifdef CONFIG_PROC_FS | ||
151 | .show = crypto_givcipher_show, | ||
152 | #endif | ||
153 | }; | ||
154 | EXPORT_SYMBOL_GPL(crypto_givcipher_type); | ||
155 | |||
110 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 156 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, |
111 | u32 type, u32 mask) | 157 | u32 type, u32 mask) |
112 | { | 158 | { |