algboss.c (da7f033ddc9fdebb3223b0bf88a2a2ab5b797608) | algboss.c (73d3864a4823abda19ebc4387b6ddcbf416e3a77) |
---|---|
1/* 2 * Create default crypto algorithm instances. 3 * 4 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the Free 8 * Software Foundation; either version 2 of the License, or (at your option) --- 31 unchanged lines hidden (view full) --- 40 struct { 41 struct rtattr attr; 42 struct crypto_attr_u32 data; 43 } nu32; 44 } attrs[CRYPTO_MAX_ATTRS]; 45 46 char larval[CRYPTO_MAX_ALG_NAME]; 47 char template[CRYPTO_MAX_ALG_NAME]; | 1/* 2 * Create default crypto algorithm instances. 3 * 4 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the Free 8 * Software Foundation; either version 2 of the License, or (at your option) --- 31 unchanged lines hidden (view full) --- 40 struct { 41 struct rtattr attr; 42 struct crypto_attr_u32 data; 43 } nu32; 44 } attrs[CRYPTO_MAX_ATTRS]; 45 46 char larval[CRYPTO_MAX_ALG_NAME]; 47 char template[CRYPTO_MAX_ALG_NAME]; |
48 49 u32 otype; 50 u32 omask; |
|
48}; 49 | 51}; 52 |
53struct crypto_test_param { 54 char driver[CRYPTO_MAX_ALG_NAME]; 55 char alg[CRYPTO_MAX_ALG_NAME]; 56 u32 type; 57}; 58 |
|
50static int cryptomgr_probe(void *data) 51{ 52 struct cryptomgr_param *param = data; 53 struct crypto_template *tmpl; 54 struct crypto_instance *inst; 55 int err; 56 57 tmpl = crypto_lookup_template(param->template); --- 13 unchanged lines hidden (view full) --- 71 if (err) 72 goto err; 73 74out: 75 kfree(param); 76 module_put_and_exit(0); 77 78err: | 59static int cryptomgr_probe(void *data) 60{ 61 struct cryptomgr_param *param = data; 62 struct crypto_template *tmpl; 63 struct crypto_instance *inst; 64 int err; 65 66 tmpl = crypto_lookup_template(param->template); --- 13 unchanged lines hidden (view full) --- 80 if (err) 81 goto err; 82 83out: 84 kfree(param); 85 module_put_and_exit(0); 86 87err: |
79 crypto_larval_error(param->larval, param->type.data.type, 80 param->type.data.mask); | 88 crypto_larval_error(param->larval, param->otype, param->omask); |
81 goto out; 82} 83 84static int cryptomgr_schedule_probe(struct crypto_larval *larval) 85{ 86 struct task_struct *thread; 87 struct cryptomgr_param *param; 88 const char *name = larval->alg.cra_name; --- 75 unchanged lines hidden (view full) --- 164 165 if (!i) 166 goto err_free_param; 167 168 param->tb[i + 1] = NULL; 169 170 param->type.attr.rta_len = sizeof(param->type); 171 param->type.attr.rta_type = CRYPTOA_TYPE; | 89 goto out; 90} 91 92static int cryptomgr_schedule_probe(struct crypto_larval *larval) 93{ 94 struct task_struct *thread; 95 struct cryptomgr_param *param; 96 const char *name = larval->alg.cra_name; --- 75 unchanged lines hidden (view full) --- 172 173 if (!i) 174 goto err_free_param; 175 176 param->tb[i + 1] = NULL; 177 178 param->type.attr.rta_len = sizeof(param->type); 179 param->type.attr.rta_type = CRYPTOA_TYPE; |
172 param->type.data.type = larval->alg.cra_flags; 173 param->type.data.mask = larval->mask; | 180 param->type.data.type = larval->alg.cra_flags & ~CRYPTO_ALG_TESTED; 181 param->type.data.mask = larval->mask & ~CRYPTO_ALG_TESTED; |
174 param->tb[0] = ¶m->type.attr; 175 | 182 param->tb[0] = ¶m->type.attr; 183 |
184 param->otype = larval->alg.cra_flags; 185 param->omask = larval->mask; 186 |
|
176 memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); 177 | 187 memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); 188 |
178 thread = kthread_run(cryptomgr_probe, param, "cryptomgr"); | 189 thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe"); |
179 if (IS_ERR(thread)) 180 goto err_free_param; 181 182 return NOTIFY_STOP; 183 184err_free_param: 185 kfree(param); 186err_put_module: 187 module_put(THIS_MODULE); 188err: 189 return NOTIFY_OK; 190} 191 | 190 if (IS_ERR(thread)) 191 goto err_free_param; 192 193 return NOTIFY_STOP; 194 195err_free_param: 196 kfree(param); 197err_put_module: 198 module_put(THIS_MODULE); 199err: 200 return NOTIFY_OK; 201} 202 |
203static int cryptomgr_test(void *data) 204{ 205 struct crypto_test_param *param = data; 206 u32 type = param->type; 207 int err = 0; 208 209 if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) & 210 CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV)) 211 goto skiptest; 212 213 if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) 214 goto skiptest; 215 216 err = alg_test(param->driver, param->alg, 0, CRYPTO_ALG_TESTED); 217 218skiptest: 219 crypto_alg_tested(param->driver, err); 220 221 kfree(param); 222 module_put_and_exit(0); 223} 224 225static int cryptomgr_schedule_test(struct crypto_alg *alg) 226{ 227 struct task_struct *thread; 228 struct crypto_test_param *param; 229 230 if (!try_module_get(THIS_MODULE)) 231 goto err; 232 233 param = kzalloc(sizeof(*param), GFP_KERNEL); 234 if (!param) 235 goto err_put_module; 236 237 memcpy(param->driver, alg->cra_driver_name, sizeof(param->driver)); 238 memcpy(param->alg, alg->cra_name, sizeof(param->alg)); 239 param->type = alg->cra_flags; 240 241 thread = kthread_run(cryptomgr_test, param, "cryptomgr_test"); 242 if (IS_ERR(thread)) 243 goto err_free_param; 244 245 return NOTIFY_STOP; 246 247err_free_param: 248 kfree(param); 249err_put_module: 250 module_put(THIS_MODULE); 251err: 252 return NOTIFY_OK; 253} 254 |
|
192static int cryptomgr_notify(struct notifier_block *this, unsigned long msg, 193 void *data) 194{ 195 switch (msg) { 196 case CRYPTO_MSG_ALG_REQUEST: 197 return cryptomgr_schedule_probe(data); | 255static int cryptomgr_notify(struct notifier_block *this, unsigned long msg, 256 void *data) 257{ 258 switch (msg) { 259 case CRYPTO_MSG_ALG_REQUEST: 260 return cryptomgr_schedule_probe(data); |
261 case CRYPTO_MSG_ALG_REGISTER: 262 return cryptomgr_schedule_test(data); |
|
198 } 199 200 return NOTIFY_DONE; 201} 202 203static struct notifier_block cryptomgr_notifier = { 204 .notifier_call = cryptomgr_notify, 205}; --- 33 unchanged lines hidden --- | 263 } 264 265 return NOTIFY_DONE; 266} 267 268static struct notifier_block cryptomgr_notifier = { 269 .notifier_call = cryptomgr_notify, 270}; --- 33 unchanged lines hidden --- |