shash.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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. return crypto_shash_import(ahash_request_ctx(req), in);
  253. }
  254. static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
  255. {
  256. struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
  257. crypto_free_shash(*ctx);
  258. }
  259. int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
  260. {
  261. struct crypto_alg *calg = tfm->__crt_alg;
  262. struct shash_alg *alg = __crypto_shash_alg(calg);
  263. struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
  264. struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
  265. struct crypto_shash *shash;
  266. if (!crypto_mod_get(calg))
  267. return -EAGAIN;
  268. shash = crypto_create_tfm(calg, &crypto_shash_type);
  269. if (IS_ERR(shash)) {
  270. crypto_mod_put(calg);
  271. return PTR_ERR(shash);
  272. }
  273. *ctx = shash;
  274. tfm->exit = crypto_exit_shash_ops_async;
  275. crt->init = shash_async_init;
  276. crt->update = shash_async_update;
  277. crt->final = shash_async_final;
  278. crt->finup = shash_async_finup;
  279. crt->digest = shash_async_digest;
  280. if (alg->setkey)
  281. crt->setkey = shash_async_setkey;
  282. if (alg->export)
  283. crt->export = shash_async_export;
  284. if (alg->import)
  285. crt->import = shash_async_import;
  286. crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
  287. return 0;
  288. }
  289. static int shash_compat_setkey(struct crypto_hash *tfm, const u8 *key,
  290. unsigned int keylen)
  291. {
  292. struct shash_desc **descp = crypto_hash_ctx(tfm);
  293. struct shash_desc *desc = *descp;
  294. return crypto_shash_setkey(desc->tfm, key, keylen);
  295. }
  296. static int shash_compat_init(struct hash_desc *hdesc)
  297. {
  298. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  299. struct shash_desc *desc = *descp;
  300. desc->flags = hdesc->flags;
  301. return crypto_shash_init(desc);
  302. }
  303. static int shash_compat_update(struct hash_desc *hdesc, struct scatterlist *sg,
  304. unsigned int len)
  305. {
  306. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  307. struct shash_desc *desc = *descp;
  308. struct crypto_hash_walk walk;
  309. int nbytes;
  310. for (nbytes = crypto_hash_walk_first_compat(hdesc, &walk, sg, len);
  311. nbytes > 0; nbytes = crypto_hash_walk_done(&walk, nbytes))
  312. nbytes = crypto_shash_update(desc, walk.data, nbytes);
  313. return nbytes;
  314. }
  315. static int shash_compat_final(struct hash_desc *hdesc, u8 *out)
  316. {
  317. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  318. return crypto_shash_final(*descp, out);
  319. }
  320. static int shash_compat_digest(struct hash_desc *hdesc, struct scatterlist *sg,
  321. unsigned int nbytes, u8 *out)
  322. {
  323. unsigned int offset = sg->offset;
  324. int err;
  325. if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
  326. struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);
  327. struct shash_desc *desc = *descp;
  328. void *data;
  329. desc->flags = hdesc->flags;
  330. data = crypto_kmap(sg_page(sg), 0);
  331. err = crypto_shash_digest(desc, data + offset, nbytes, out);
  332. crypto_kunmap(data, 0);
  333. crypto_yield(desc->flags);
  334. goto out;
  335. }
  336. err = shash_compat_init(hdesc);
  337. if (err)
  338. goto out;
  339. err = shash_compat_update(hdesc, sg, nbytes);
  340. if (err)
  341. goto out;
  342. err = shash_compat_final(hdesc, out);
  343. out:
  344. return err;
  345. }
  346. static void crypto_exit_shash_ops_compat(struct crypto_tfm *tfm)
  347. {
  348. struct shash_desc **descp = crypto_tfm_ctx(tfm);
  349. struct shash_desc *desc = *descp;
  350. crypto_free_shash(desc->tfm);
  351. kzfree(desc);
  352. }
  353. static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
  354. {
  355. struct hash_tfm *crt = &tfm->crt_hash;
  356. struct crypto_alg *calg = tfm->__crt_alg;
  357. struct shash_alg *alg = __crypto_shash_alg(calg);
  358. struct shash_desc **descp = crypto_tfm_ctx(tfm);
  359. struct crypto_shash *shash;
  360. struct shash_desc *desc;
  361. if (!crypto_mod_get(calg))
  362. return -EAGAIN;
  363. shash = crypto_create_tfm(calg, &crypto_shash_type);
  364. if (IS_ERR(shash)) {
  365. crypto_mod_put(calg);
  366. return PTR_ERR(shash);
  367. }
  368. desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(shash),
  369. GFP_KERNEL);
  370. if (!desc) {
  371. crypto_free_shash(shash);
  372. return -ENOMEM;
  373. }
  374. *descp = desc;
  375. desc->tfm = shash;
  376. tfm->exit = crypto_exit_shash_ops_compat;
  377. crt->init = shash_compat_init;
  378. crt->update = shash_compat_update;
  379. crt->final = shash_compat_final;
  380. crt->digest = shash_compat_digest;
  381. crt->setkey = shash_compat_setkey;
  382. crt->digestsize = alg->digestsize;
  383. return 0;
  384. }
  385. static int crypto_init_shash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
  386. {
  387. switch (mask & CRYPTO_ALG_TYPE_MASK) {
  388. case CRYPTO_ALG_TYPE_HASH_MASK:
  389. return crypto_init_shash_ops_compat(tfm);
  390. }
  391. return -EINVAL;
  392. }
  393. static unsigned int crypto_shash_ctxsize(struct crypto_alg *alg, u32 type,
  394. u32 mask)
  395. {
  396. switch (mask & CRYPTO_ALG_TYPE_MASK) {
  397. case CRYPTO_ALG_TYPE_HASH_MASK:
  398. return sizeof(struct shash_desc *);
  399. }
  400. return 0;
  401. }
  402. static int crypto_shash_init_tfm(struct crypto_tfm *tfm)
  403. {
  404. struct crypto_shash *hash = __crypto_shash_cast(tfm);
  405. hash->descsize = crypto_shash_alg(hash)->descsize;
  406. return 0;
  407. }
  408. static unsigned int crypto_shash_extsize(struct crypto_alg *alg)
  409. {
  410. return alg->cra_ctxsize;
  411. }
  412. static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
  413. __attribute__ ((unused));
  414. static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
  415. {
  416. struct shash_alg *salg = __crypto_shash_alg(alg);
  417. seq_printf(m, "type : shash\n");
  418. seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
  419. seq_printf(m, "digestsize : %u\n", salg->digestsize);
  420. }
  421. static const struct crypto_type crypto_shash_type = {
  422. .ctxsize = crypto_shash_ctxsize,
  423. .extsize = crypto_shash_extsize,
  424. .init = crypto_init_shash_ops,
  425. .init_tfm = crypto_shash_init_tfm,
  426. #ifdef CONFIG_PROC_FS
  427. .show = crypto_shash_show,
  428. #endif
  429. .maskclear = ~CRYPTO_ALG_TYPE_MASK,
  430. .maskset = CRYPTO_ALG_TYPE_MASK,
  431. .type = CRYPTO_ALG_TYPE_SHASH,
  432. .tfmsize = offsetof(struct crypto_shash, base),
  433. };
  434. struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
  435. u32 mask)
  436. {
  437. return crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask);
  438. }
  439. EXPORT_SYMBOL_GPL(crypto_alloc_shash);
  440. static int shash_prepare_alg(struct shash_alg *alg)
  441. {
  442. struct crypto_alg *base = &alg->base;
  443. if (alg->digestsize > PAGE_SIZE / 8 ||
  444. alg->descsize > PAGE_SIZE / 8 ||
  445. alg->statesize > PAGE_SIZE / 8)
  446. return -EINVAL;
  447. base->cra_type = &crypto_shash_type;
  448. base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
  449. base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
  450. if (!alg->finup)
  451. alg->finup = shash_finup_unaligned;
  452. if (!alg->digest)
  453. alg->digest = shash_digest_unaligned;
  454. if (!alg->export) {
  455. alg->export = shash_default_export;
  456. alg->import = shash_default_import;
  457. alg->statesize = alg->descsize;
  458. }
  459. if (!alg->setkey)
  460. alg->setkey = shash_no_setkey;
  461. return 0;
  462. }
  463. int crypto_register_shash(struct shash_alg *alg)
  464. {
  465. struct crypto_alg *base = &alg->base;
  466. int err;
  467. err = shash_prepare_alg(alg);
  468. if (err)
  469. return err;
  470. return crypto_register_alg(base);
  471. }
  472. EXPORT_SYMBOL_GPL(crypto_register_shash);
  473. int crypto_unregister_shash(struct shash_alg *alg)
  474. {
  475. return crypto_unregister_alg(&alg->base);
  476. }
  477. EXPORT_SYMBOL_GPL(crypto_unregister_shash);
  478. int shash_register_instance(struct crypto_template *tmpl,
  479. struct shash_instance *inst)
  480. {
  481. int err;
  482. err = shash_prepare_alg(&inst->alg);
  483. if (err)
  484. return err;
  485. return crypto_register_instance(tmpl, shash_crypto_instance(inst));
  486. }
  487. EXPORT_SYMBOL_GPL(shash_register_instance);
  488. void shash_free_instance(struct crypto_instance *inst)
  489. {
  490. crypto_drop_spawn(crypto_instance_ctx(inst));
  491. kfree(shash_instance(inst));
  492. }
  493. EXPORT_SYMBOL_GPL(shash_free_instance);
  494. int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
  495. struct shash_alg *alg,
  496. struct crypto_instance *inst)
  497. {
  498. return crypto_init_spawn2(&spawn->base, &alg->base, inst,
  499. &crypto_shash_type);
  500. }
  501. EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
  502. struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
  503. {
  504. struct crypto_alg *alg;
  505. alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask);
  506. return IS_ERR(alg) ? ERR_CAST(alg) :
  507. container_of(alg, struct shash_alg, base);
  508. }
  509. EXPORT_SYMBOL_GPL(shash_attr_alg);
  510. MODULE_LICENSE("GPL");
  511. MODULE_DESCRIPTION("Synchronous cryptographic hash type");