aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ablkcipher.c46
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};
108EXPORT_SYMBOL_GPL(crypto_ablkcipher_type); 108EXPORT_SYMBOL_GPL(crypto_ablkcipher_type);
109 109
110static int no_givdecrypt(struct skcipher_givcrypt_request *req)
111{
112 return -ENOSYS;
113}
114
115static 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
134static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
135 __attribute__ ((unused));
136static 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
147const 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};
154EXPORT_SYMBOL_GPL(crypto_givcipher_type);
155
110int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, 156int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,
111 u32 type, u32 mask) 157 u32 type, u32 mask)
112{ 158{