shash.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * Synchronous Cryptographic Hash operations.
  3. *
  4. * Copyright (c) 2008 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)
  9. * any later version.
  10. *
  11. */
  12. #include <crypto/scatterwalk.h>
  13. #include <crypto/internal/hash.h>
  14. #include <linux/err.h>
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. #include <linux/seq_file.h>
  19. #include "internal.h"
  20. static const struct crypto_type crypto_shash_type;
  21. static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
  22. unsigned int keylen)
  23. {
  24. return -ENOSYS;
  25. }
  26. static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
  27. unsigned int keylen)
  28. {
  29. struct shash_alg *shash = crypto_shash_alg(tfm);
  30. unsigned long alignmask = crypto_shash_alignmask(tfm);
  31. unsigned long absize;
  32. u8 *buffer, *alignbuffer;
  33. int err;
  34. absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
  35. buffer = kmalloc(absize, GFP_KERNEL);
  36. if (!buffer)
  37. return -ENOMEM;
  38. alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
  39. memcpy(alignbuffer, key, keylen);
  40. err = shash->setkey(tfm, alignbuffer, keylen);
  41. kzfree(buffer);
  42. return err;
  43. }
  44. int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
  45. unsigned int keylen)
  46. {
  47. struct shash_alg *shash = crypto_shash_alg(tfm);
  48. unsigned long alignmask = crypto_shash_alignmask(tfm);
  49. if ((unsigned long)key & alignmask)
  50. return shash_setkey_unaligned(tfm, key, keylen);
  51. return shash->setkey(tfm, key, keylen);
  52. }
  53. EXPORT_SYMBOL_GPL(crypto_shash_setkey);
  54. static inline unsigned int shash_align_buffer_size(unsigned len,
  55. unsigned long mask)
  56. {
  57. return len + (mask & ~(__alignof__(u8 __attribute__ ((aligned))) - 1));
  58. }
  59. static int shash_update_unaligned(struct shash_desc *desc, const u8 *data,
  60. unsigned int len)
  61. {
  62. struct crypto_shash *tfm = desc->tfm;
  63. struct shash_alg *shash = crypto_shash_alg(tfm);
  64. unsigned long alignmask = crypto_shash_alignmask(tfm);
  65. unsigned int unaligned_len = alignmask + 1 -
  66. ((unsigned long)data & alignmask);
  67. u8 ubuf[shash_align_buffer_size(unaligned_len, alignmask)]
  68. __attribute__ ((aligned));
  69. u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
  70. int err;
  71. if (unaligned_len > len)
  72. unaligned_len = len;
  73. memcpy(buf, data, unaligned_len);
  74. err = shash->update(desc, buf, unaligned_len);
  75. memset(buf, 0, unaligned_len);
  76. return err ?:
  77. shash->update(desc, data + unaligned_len, len - unaligned_len);
  78. }
  79. int crypto_shash_update(struct shash_desc *desc, const u8 *data,
  80. unsigned int len)
  81. {
  82. struct crypto_shash *tfm = desc->tfm;
  83. struct shash_alg *shash = crypto_shash_alg(tfm);
  84. unsigned long alignmask = crypto_shash_alignmask(tfm);
  85. if ((unsigned long)data & alignmask)
  86. return shash_update_unaligned(desc, data, len);
  87. return shash->update(desc, data, len);
  88. }
  89. EXPORT_SYMBOL_GPL(crypto_shash_update);
  90. static int shash_final_unaligned(struct shash_desc *desc, u8 *out)
  91. {
  92. struct crypto_shash *tfm = desc->tfm;
  93. unsigned long alignmask = crypto_shash_alignmask(tfm);
  94. struct shash_alg *shash = crypto_shash_alg(tfm);
  95. unsigned int ds = crypto_shash_digestsize(tfm);
  96. u8 ubuf[shash_align_buffer_size(ds, alignmask)]
  97. __attribute__ ((aligned));
  98. u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
  99. int err;
  100. err = shash->final(desc, buf);
  101. if (err)
  102. goto out;
  103. memcpy(out, buf, ds);
  104. out:
  105. memset(buf, 0, ds);
  106. return err;
  107. }
  108. int crypto_shash_final(struct shash_desc *desc, u8 *out)
  109. {
  110. struct crypto_shash *tfm = desc->tfm;
  111. struct shash_alg *shash = crypto_shash_alg(tfm);
  112. unsigned long alignmask = crypto_shash_alignmask(tfm);
  113. if ((unsigned long)out & alignmask)
  114. return shash_final_unaligned(desc, out);
  115. return shash->final(desc, out);
  116. }
  117. EXPORT_SYMBOL_GPL(crypto_shash_final);
  118. static int shash_finup_unaligned(struct shash_desc *desc, const u8 *data,
  119. unsigned int len, u8 *out)
  120. {
  121. return crypto_shash_update(desc, data, len) ?:
  122. crypto_shash_final(desc, out);
  123. }
  124. int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
  125. unsigned int len, u8 *out)
  126. {
  127. struct crypto_shash *tfm = desc->tfm;
  128. struct shash_alg *shash = crypto_shash_alg(tfm);
  129. unsigned long alignmask = crypto_shash_alignmask(tfm);
  130. if (((unsigned long)data | (unsigned long)out) & alignmask)
  131. return shash_finup_unaligned(desc, data, len, out);
  132. return shash->finup(desc, data, len, out);
  133. }
  134. EXPORT_SYMBOL_GPL(crypto_shash_finup);
  135. static int shash_digest_unaligned(struct shash_desc *desc, const u8 *data,
  136. unsigned int len, u8 *out)
  137. {
  138. return crypto_shash_init(desc) ?:
  139. crypto_shash_finup(desc, data, len, out);
  140. }
  141. int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
  142. unsigned int len, u8 *out)
  143. {
  144. struct crypto_shash *tfm = desc->tfm;
  145. struct shash_alg *shash = crypto_shash_alg(tfm);
  146. unsigned long alignmask = crypto_shash_alignmask(tfm);
  147. if (((unsigned long)data | (unsigned long)out) & alignmask)
  148. return shash_digest_unaligned(desc, data, len, out);
  149. return shash->digest(desc, data, len, out);
  150. }
  151. EXPORT_SYMBOL_GPL(crypto_shash_digest);
  152. static int shash_default_export(struct shash_desc *desc, void *out)
  153. {
  154. memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm));
  155. return 0;
  156. }
  157. static int shash_default_import(struct shash_desc *desc, const void *in)
  158. {
  159. memcpy(shash_desc_ctx(desc), in, crypto_shash_descsize(desc->tfm));
  160. return 0;
  161. }
  162. static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key,
  163. unsigned int keylen)
  164. {
  165. struct crypto_shash **ctx = crypto_ahash_ctx(tfm);
  166. return crypto_shash_setkey(*ctx, key, keylen);
  167. }
  168. static int shash_async_init(struct ahash_request *req)
  169. {
  170. struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
  171. struct shash_desc *desc = ahash_request_ctx(req);
  172. desc->tfm = *ctx;
  173. desc->flags = req->base.flags;
  174. return crypto_shash_init(desc);
  175. }
  176. int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc)
  177. {
  178. struct crypto_hash_walk walk;
  179. int nbytes;
  180. for (nbytes = crypto_hash_walk_first(req, &walk); nbytes > 0;
  181. nbytes = crypto_hash_walk_done(&walk, nbytes))
  182. nbytes = crypto_shash_update(desc, walk.data, nbytes);
  183. return nbytes;
  184. }
  185. EXPORT_SYMBOL_GPL(shash_ahash_update);
  186. static int shash_async_update(struct ahash_request *req)
  187. {
  188. return shash_ahash_update(req, ahash_request_ctx(req));
  189. }
  190. static int shash_async_final(struct ahash_request *req)
  191. {
  192. return crypto_shash_final(ahash_request_ctx(req), req->result);
  193. }
  194. int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc)
  195. {
  196. struct crypto_hash_walk walk;
  197. int nbytes;
  198. nbytes = crypto_hash_walk_first(req, &walk);
  199. if (!nbytes)
  200. return crypto_shash_final(desc, req->result);
  201. do {
  202. nbytes = crypto_hash_walk_last(&walk) ?
  203. crypto_shash_finup(desc, walk.data, nbytes,
  204. req->result) :
  205. crypto_shash_update(desc, walk.data, nbytes);
  206. nbytes = crypto_hash_walk_done(&walk, nbytes);
  207. } while (nbytes > 0);
  208. return nbytes;
  209. }
  210. EXPORT_SYMBOL_GPL(shash_ahash_finup);
  211. static int shash_async_finup(struct ahash_request *req)
  212. {
  213. struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
  214. struct shash_desc *desc = ahash_request_ctx(req);
  215. desc->tfm = *ctx;
  216. desc->flags = req->base.flags;
  217. return shash_ahash_finup(req, desc);
  218. }
  219. int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
  220. {
  221. struct scatterlist *sg = req->src;
  222. unsigned int offset = sg->offset;
  223. unsigned int nbytes = req->nbytes;
  224. int err;
  225. if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
  226. void *data;
  227. data = crypto_kmap(sg_page(sg), 0);
  228. err = crypto_shash_digest(desc, data + offset, nbytes,
  229. req->result);
  230. crypto_kunmap(data, 0);
  231. crypto_yield(desc->flags);
  232. } else
  233. err = crypto_shash_init(desc) ?:
  234. shash_ahash_finup(req, desc);
  235. return err;
  236. }
  237. EXPORT_SYMBOL_GPL(shash_ahash_digest);
  238. static int shash_async_digest(struct ahash_request *req)
  239. {
  240. struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
  241. struct shash_desc *desc = ahash_request_ctx(req);
  242. desc->tfm = *ctx;
  243. desc->flags = req->base.flags;
  244. return shash_ahash_digest(req, desc);
  245. }
  246. static int shash_async_export(struct ahash_request *req, void *out)
  247. {
  248. return crypto_shash_export(ahash_request_ctx(req), out);
  249. }
  250. static int shash_async_import(struct ahash_request *req, const void *in)
  251. {
  252. struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
  253. struct shash_desc *desc = ahash_request_ctx(req);
  254. desc->tfm = *ctx;
  255. desc->flags = req->base.flags;
  256. return crypto_shash_import(desc, in);
  257. }
  258. static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
  259. {
  260. struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
  261. crypto_free_shash(*ctx);
  262. }
  263. int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
  264. {
  265. struct crypto_alg *calg = tfm->__crt_alg;
  266. struct shash_alg *alg = __crypto_shash_alg(calg);
  267. struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
  268. struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
  269. struct crypto_shash *shash;
  270. if (!crypto_mod_get(calg))
  271. return -EAGAIN;
  272. shash = crypto_create_tfm(calg, &crypto_shash_type);
  273. if (IS_ERR(shash)) {
  274. crypto_mod_put(calg);
  275. return PTR_ERR(shash);
  276. }
  277. *ctx = shash;
  278. tfm->exit = crypto_exit_shash_ops_async;
  279. crt->init = shash_async_init;
  280. crt->update = shash_async_update;
  281. crt->final = shash_async_final;
  282. crt->finup = shash_async_finup;
  283. crt->digest = shash_async_digest;
  284. if (alg->setkey)
  285. crt->setkey = shash_async_setkey;
  286. if (alg->export)
  287. crt->export = shash_async_export;
  288. if (alg->import)
  289. crt->import = shash_async_import;
  290. crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
  291. return 0;
  292. }
  293. static int shash_compat_setkey(struct crypto_hash *tfm, const u8 *key,
  294. unsigned int keylen)
  295. {
  296. struct shash_desc **descp = crypto_hash_ctx(tfm);
  297. struct shash_desc *desc = *descp;
  298. return crypto_shash_setkey(desc->tfm, key, keylen);
  299. }
  300. static int shash_compat_init(struct hash_desc *hdesc)
  301. {
  302. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  303. struct shash_desc *desc = *descp;
  304. desc->flags = hdesc->flags;
  305. return crypto_shash_init(desc);
  306. }
  307. static int shash_compat_update(struct hash_desc *hdesc, struct scatterlist *sg,
  308. unsigned int len)
  309. {
  310. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  311. struct shash_desc *desc = *descp;
  312. struct crypto_hash_walk walk;
  313. int nbytes;
  314. for (nbytes = crypto_hash_walk_first_compat(hdesc, &walk, sg, len);
  315. nbytes > 0; nbytes = crypto_hash_walk_done(&walk, nbytes))
  316. nbytes = crypto_shash_update(desc, walk.data, nbytes);
  317. return nbytes;
  318. }
  319. static int shash_compat_final(struct hash_desc *hdesc, u8 *out)
  320. {
  321. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  322. return crypto_shash_final(*descp, out);
  323. }
  324. static int shash_compat_digest(struct hash_desc *hdesc, struct scatterlist *sg,
  325. unsigned int nbytes, u8 *out)
  326. {
  327. unsigned int offset = sg->offset;
  328. int err;
  329. if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
  330. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  331. struct shash_desc *desc = *descp;
  332. void *data;
  333. desc->flags = hdesc->flags;
  334. data = crypto_kmap(sg_page(sg), 0);
  335. err = crypto_shash_digest(desc, data + offset, nbytes, out);
  336. crypto_kunmap(data, 0);
  337. crypto_yield(desc->flags);
  338. goto out;
  339. }
  340. err = shash_compat_init(hdesc);
  341. if (err)
  342. goto out;
  343. err = shash_compat_update(hdesc, sg, nbytes);
  344. if (err)
  345. goto out;
  346. err = shash_compat_final(hdesc, out);
  347. out:
  348. return err;
  349. }
  350. static void crypto_exit_shash_ops_compat(struct crypto_tfm *tfm)
  351. {
  352. struct shash_desc **descp = crypto_tfm_ctx(tfm);
  353. struct shash_desc *desc = *descp;
  354. crypto_free_shash(desc->tfm);
  355. kzfree(desc);
  356. }
  357. static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
  358. {
  359. struct hash_tfm *crt = &tfm->crt_hash;
  360. struct crypto_alg *calg = tfm->__crt_alg;
  361. struct shash_alg *alg = __crypto_shash_alg(calg);
  362. struct shash_desc **descp = crypto_tfm_ctx(tfm);
  363. struct crypto_shash *shash;
  364. struct shash_desc *desc;
  365. if (!crypto_mod_get(calg))
  366. return -EAGAIN;
  367. shash = crypto_create_tfm(calg, &crypto_shash_type);
  368. if (IS_ERR(shash)) {
  369. crypto_mod_put(calg);
  370. return PTR_ERR(shash);
  371. }
  372. desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(shash),
  373. GFP_KERNEL);
  374. if (!desc) {
  375. crypto_free_shash(shash);
  376. return -ENOMEM;
  377. }
  378. *descp = desc;
  379. desc->tfm = shash;
  380. tfm->exit = crypto_exit_shash_ops_compat;
  381. crt->init = shash_compat_init;
  382. crt->update = shash_compat_update;
  383. crt->final = shash_compat_final;
  384. crt->digest = shash_compat_digest;
  385. crt->setkey = shash_compat_setkey;
  386. crt->digestsize = alg->digestsize;
  387. return 0;
  388. }
  389. static int crypto_init_shash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
  390. {
  391. switch (mask & CRYPTO_ALG_TYPE_MASK) {
  392. case CRYPTO_ALG_TYPE_HASH_MASK:
  393. return crypto_init_shash_ops_compat(tfm);
  394. }
  395. return -EINVAL;
  396. }
  397. static unsigned int crypto_shash_ctxsize(struct crypto_alg *alg, u32 type,
  398. u32 mask)
  399. {
  400. switch (mask & CRYPTO_ALG_TYPE_MASK) {
  401. case CRYPTO_ALG_TYPE_HASH_MASK:
  402. return sizeof(struct shash_desc *);
  403. }
  404. return 0;
  405. }
  406. static int crypto_shash_init_tfm(struct crypto_tfm *tfm)
  407. {
  408. struct crypto_shash *hash = __crypto_shash_cast(tfm);
  409. hash->descsize = crypto_shash_alg(hash)->descsize;
  410. return 0;
  411. }
  412. static unsigned int crypto_shash_extsize(struct crypto_alg *alg)
  413. {
  414. return alg->cra_ctxsize;
  415. }
  416. static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
  417. __attribute__ ((unused));
  418. static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
  419. {
  420. struct shash_alg *salg = __crypto_shash_alg(alg);
  421. seq_printf(m, "type : shash\n");
  422. seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
  423. seq_printf(m, "digestsize : %u\n", salg->digestsize);
  424. }
  425. static const struct crypto_type crypto_shash_type = {
  426. .ctxsize = crypto_shash_ctxsize,
  427. .extsize = crypto_shash_extsize,
  428. .init = crypto_init_shash_ops,
  429. .init_tfm = crypto_shash_init_tfm,
  430. #ifdef CONFIG_PROC_FS
  431. .show = crypto_shash_show,
  432. #endif
  433. .maskclear = ~CRYPTO_ALG_TYPE_MASK,
  434. .maskset = CRYPTO_ALG_TYPE_MASK,
  435. .type = CRYPTO_ALG_TYPE_SHASH,
  436. .tfmsize = offsetof(struct crypto_shash, base),
  437. };
  438. struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
  439. u32 mask)
  440. {
  441. return crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask);
  442. }
  443. EXPORT_SYMBOL_GPL(crypto_alloc_shash);
  444. static int shash_prepare_alg(struct shash_alg *alg)
  445. {
  446. struct crypto_alg *base = &alg->base;
  447. if (alg->digestsize > PAGE_SIZE / 8 ||
  448. alg->descsize > PAGE_SIZE / 8 ||
  449. alg->statesize > PAGE_SIZE / 8)
  450. return -EINVAL;
  451. base->cra_type = &crypto_shash_type;
  452. base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
  453. base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
  454. if (!alg->finup)
  455. alg->finup = shash_finup_unaligned;
  456. if (!alg->digest)
  457. alg->digest = shash_digest_unaligned;
  458. if (!alg->export) {
  459. alg->export = shash_default_export;
  460. alg->import = shash_default_import;
  461. alg->statesize = alg->descsize;
  462. }
  463. if (!alg->setkey)
  464. alg->setkey = shash_no_setkey;
  465. return 0;
  466. }
  467. int crypto_register_shash(struct shash_alg *alg)
  468. {
  469. struct crypto_alg *base = &alg->base;
  470. int err;
  471. err = shash_prepare_alg(alg);
  472. if (err)
  473. return err;
  474. return crypto_register_alg(base);
  475. }
  476. EXPORT_SYMBOL_GPL(crypto_register_shash);
  477. int crypto_unregister_shash(struct shash_alg *alg)
  478. {
  479. return crypto_unregister_alg(&alg->base);
  480. }
  481. EXPORT_SYMBOL_GPL(crypto_unregister_shash);
  482. int shash_register_instance(struct crypto_template *tmpl,
  483. struct shash_instance *inst)
  484. {
  485. int err;
  486. err = shash_prepare_alg(&inst->alg);
  487. if (err)
  488. return err;
  489. return crypto_register_instance(tmpl, shash_crypto_instance(inst));
  490. }
  491. EXPORT_SYMBOL_GPL(shash_register_instance);
  492. void shash_free_instance(struct crypto_instance *inst)
  493. {
  494. crypto_drop_spawn(crypto_instance_ctx(inst));
  495. kfree(shash_instance(inst));
  496. }
  497. EXPORT_SYMBOL_GPL(shash_free_instance);
  498. int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
  499. struct shash_alg *alg,
  500. struct crypto_instance *inst)
  501. {
  502. return crypto_init_spawn2(&spawn->base, &alg->base, inst,
  503. &crypto_shash_type);
  504. }
  505. EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
  506. struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
  507. {
  508. struct crypto_alg *alg;
  509. alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask);
  510. return IS_ERR(alg) ? ERR_CAST(alg) :
  511. container_of(alg, struct shash_alg, base);
  512. }
  513. EXPORT_SYMBOL_GPL(shash_attr_alg);
  514. MODULE_LICENSE("GPL");
  515. MODULE_DESCRIPTION("Synchronous cryptographic hash type");