ahash.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * Asynchronous Cryptographic Hash operations.
  3. *
  4. * This is the asynchronous version of hash.c with notification of
  5. * completion via a callback.
  6. *
  7. * Copyright (c) 2008 Loc Ho <[email protected]>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the Free
  11. * Software Foundation; either version 2 of the License, or (at your option)
  12. * any later version.
  13. *
  14. */
  15. #include <crypto/internal/hash.h>
  16. #include <crypto/scatterwalk.h>
  17. #include <linux/bug.h>
  18. #include <linux/err.h>
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/sched.h>
  22. #include <linux/slab.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/cryptouser.h>
  25. #include <net/netlink.h>
  26. #include "internal.h"
  27. struct ahash_request_priv {
  28. crypto_completion_t complete;
  29. void *data;
  30. u8 *result;
  31. u32 flags;
  32. void *ubuf[] CRYPTO_MINALIGN_ATTR;
  33. };
  34. static inline struct ahash_alg *crypto_ahash_alg(struct crypto_ahash *hash)
  35. {
  36. return container_of(crypto_hash_alg_common(hash), struct ahash_alg,
  37. halg);
  38. }
  39. static int hash_walk_next(struct crypto_hash_walk *walk)
  40. {
  41. unsigned int alignmask = walk->alignmask;
  42. unsigned int offset = walk->offset;
  43. unsigned int nbytes = min(walk->entrylen,
  44. ((unsigned int)(PAGE_SIZE)) - offset);
  45. if (walk->flags & CRYPTO_ALG_ASYNC)
  46. walk->data = kmap(walk->pg);
  47. else
  48. walk->data = kmap_atomic(walk->pg);
  49. walk->data += offset;
  50. if (offset & alignmask) {
  51. unsigned int unaligned = alignmask + 1 - (offset & alignmask);
  52. if (nbytes > unaligned)
  53. nbytes = unaligned;
  54. }
  55. walk->entrylen -= nbytes;
  56. return nbytes;
  57. }
  58. static int hash_walk_new_entry(struct crypto_hash_walk *walk)
  59. {
  60. struct scatterlist *sg;
  61. sg = walk->sg;
  62. walk->offset = sg->offset;
  63. walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
  64. walk->offset = offset_in_page(walk->offset);
  65. walk->entrylen = sg->length;
  66. if (walk->entrylen > walk->total)
  67. walk->entrylen = walk->total;
  68. walk->total -= walk->entrylen;
  69. return hash_walk_next(walk);
  70. }
  71. int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
  72. {
  73. unsigned int alignmask = walk->alignmask;
  74. walk->data -= walk->offset;
  75. if (walk->entrylen && (walk->offset & alignmask) && !err) {
  76. unsigned int nbytes;
  77. walk->offset = ALIGN(walk->offset, alignmask + 1);
  78. nbytes = min(walk->entrylen,
  79. (unsigned int)(PAGE_SIZE - walk->offset));
  80. if (nbytes) {
  81. walk->entrylen -= nbytes;
  82. walk->data += walk->offset;
  83. return nbytes;
  84. }
  85. }
  86. if (walk->flags & CRYPTO_ALG_ASYNC)
  87. kunmap(walk->pg);
  88. else {
  89. kunmap_atomic(walk->data);
  90. /*
  91. * The may sleep test only makes sense for sync users.
  92. * Async users don't need to sleep here anyway.
  93. */
  94. crypto_yield(walk->flags);
  95. }
  96. if (err)
  97. return err;
  98. if (walk->entrylen) {
  99. walk->offset = 0;
  100. walk->pg++;
  101. return hash_walk_next(walk);
  102. }
  103. if (!walk->total)
  104. return 0;
  105. walk->sg = sg_next(walk->sg);
  106. return hash_walk_new_entry(walk);
  107. }
  108. EXPORT_SYMBOL_GPL(crypto_hash_walk_done);
  109. int crypto_hash_walk_first(struct ahash_request *req,
  110. struct crypto_hash_walk *walk)
  111. {
  112. walk->total = req->nbytes;
  113. if (!walk->total) {
  114. walk->entrylen = 0;
  115. return 0;
  116. }
  117. walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
  118. walk->sg = req->src;
  119. walk->flags = req->base.flags & CRYPTO_TFM_REQ_MASK;
  120. return hash_walk_new_entry(walk);
  121. }
  122. EXPORT_SYMBOL_GPL(crypto_hash_walk_first);
  123. int crypto_ahash_walk_first(struct ahash_request *req,
  124. struct crypto_hash_walk *walk)
  125. {
  126. walk->total = req->nbytes;
  127. if (!walk->total) {
  128. walk->entrylen = 0;
  129. return 0;
  130. }
  131. walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
  132. walk->sg = req->src;
  133. walk->flags = req->base.flags & CRYPTO_TFM_REQ_MASK;
  134. walk->flags |= CRYPTO_ALG_ASYNC;
  135. BUILD_BUG_ON(CRYPTO_TFM_REQ_MASK & CRYPTO_ALG_ASYNC);
  136. return hash_walk_new_entry(walk);
  137. }
  138. EXPORT_SYMBOL_GPL(crypto_ahash_walk_first);
  139. static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key,
  140. unsigned int keylen)
  141. {
  142. unsigned long alignmask = crypto_ahash_alignmask(tfm);
  143. int ret;
  144. u8 *buffer, *alignbuffer;
  145. unsigned long absize;
  146. absize = keylen + alignmask;
  147. buffer = kmalloc(absize, GFP_KERNEL);
  148. if (!buffer)
  149. return -ENOMEM;
  150. alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
  151. memcpy(alignbuffer, key, keylen);
  152. ret = tfm->setkey(tfm, alignbuffer, keylen);
  153. kzfree(buffer);
  154. return ret;
  155. }
  156. static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
  157. unsigned int keylen)
  158. {
  159. return -ENOSYS;
  160. }
  161. static void ahash_set_needkey(struct crypto_ahash *tfm)
  162. {
  163. const struct hash_alg_common *alg = crypto_hash_alg_common(tfm);
  164. if (tfm->setkey != ahash_nosetkey &&
  165. !(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY))
  166. crypto_ahash_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
  167. }
  168. int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
  169. unsigned int keylen)
  170. {
  171. unsigned long alignmask = crypto_ahash_alignmask(tfm);
  172. int err;
  173. if ((unsigned long)key & alignmask)
  174. err = ahash_setkey_unaligned(tfm, key, keylen);
  175. else
  176. err = tfm->setkey(tfm, key, keylen);
  177. if (unlikely(err)) {
  178. ahash_set_needkey(tfm);
  179. return err;
  180. }
  181. crypto_ahash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
  182. return 0;
  183. }
  184. EXPORT_SYMBOL_GPL(crypto_ahash_setkey);
  185. static inline unsigned int ahash_align_buffer_size(unsigned len,
  186. unsigned long mask)
  187. {
  188. return len + (mask & ~(crypto_tfm_ctx_alignment() - 1));
  189. }
  190. static int ahash_save_req(struct ahash_request *req, crypto_completion_t cplt)
  191. {
  192. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  193. unsigned long alignmask = crypto_ahash_alignmask(tfm);
  194. unsigned int ds = crypto_ahash_digestsize(tfm);
  195. struct ahash_request_priv *priv;
  196. priv = kmalloc(sizeof(*priv) + ahash_align_buffer_size(ds, alignmask),
  197. (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
  198. GFP_KERNEL : GFP_ATOMIC);
  199. if (!priv)
  200. return -ENOMEM;
  201. /*
  202. * WARNING: Voodoo programming below!
  203. *
  204. * The code below is obscure and hard to understand, thus explanation
  205. * is necessary. See include/crypto/hash.h and include/linux/crypto.h
  206. * to understand the layout of structures used here!
  207. *
  208. * The code here will replace portions of the ORIGINAL request with
  209. * pointers to new code and buffers so the hashing operation can store
  210. * the result in aligned buffer. We will call the modified request
  211. * an ADJUSTED request.
  212. *
  213. * The newly mangled request will look as such:
  214. *
  215. * req {
  216. * .result = ADJUSTED[new aligned buffer]
  217. * .base.complete = ADJUSTED[pointer to completion function]
  218. * .base.data = ADJUSTED[*req (pointer to self)]
  219. * .priv = ADJUSTED[new priv] {
  220. * .result = ORIGINAL(result)
  221. * .complete = ORIGINAL(base.complete)
  222. * .data = ORIGINAL(base.data)
  223. * }
  224. */
  225. priv->result = req->result;
  226. priv->complete = req->base.complete;
  227. priv->data = req->base.data;
  228. priv->flags = req->base.flags;
  229. /*
  230. * WARNING: We do not backup req->priv here! The req->priv
  231. * is for internal use of the Crypto API and the
  232. * user must _NOT_ _EVER_ depend on it's content!
  233. */
  234. req->result = PTR_ALIGN((u8 *)priv->ubuf, alignmask + 1);
  235. req->base.complete = cplt;
  236. req->base.data = req;
  237. req->priv = priv;
  238. return 0;
  239. }
  240. static void ahash_restore_req(struct ahash_request *req, int err)
  241. {
  242. struct ahash_request_priv *priv = req->priv;
  243. if (!err)
  244. memcpy(priv->result, req->result,
  245. crypto_ahash_digestsize(crypto_ahash_reqtfm(req)));
  246. /* Restore the original crypto request. */
  247. req->result = priv->result;
  248. ahash_request_set_callback(req, priv->flags,
  249. priv->complete, priv->data);
  250. req->priv = NULL;
  251. /* Free the req->priv.priv from the ADJUSTED request. */
  252. kzfree(priv);
  253. }
  254. static void ahash_notify_einprogress(struct ahash_request *req)
  255. {
  256. struct ahash_request_priv *priv = req->priv;
  257. struct crypto_async_request oreq;
  258. oreq.data = priv->data;
  259. priv->complete(&oreq, -EINPROGRESS);
  260. }
  261. static void ahash_op_unaligned_done(struct crypto_async_request *req, int err)
  262. {
  263. struct ahash_request *areq = req->data;
  264. if (err == -EINPROGRESS) {
  265. ahash_notify_einprogress(areq);
  266. return;
  267. }
  268. /*
  269. * Restore the original request, see ahash_op_unaligned() for what
  270. * goes where.
  271. *
  272. * The "struct ahash_request *req" here is in fact the "req.base"
  273. * from the ADJUSTED request from ahash_op_unaligned(), thus as it
  274. * is a pointer to self, it is also the ADJUSTED "req" .
  275. */
  276. /* First copy req->result into req->priv.result */
  277. ahash_restore_req(areq, err);
  278. /* Complete the ORIGINAL request. */
  279. areq->base.complete(&areq->base, err);
  280. }
  281. static int ahash_op_unaligned(struct ahash_request *req,
  282. int (*op)(struct ahash_request *))
  283. {
  284. int err;
  285. err = ahash_save_req(req, ahash_op_unaligned_done);
  286. if (err)
  287. return err;
  288. err = op(req);
  289. if (err == -EINPROGRESS ||
  290. (err == -EBUSY && (ahash_request_flags(req) &
  291. CRYPTO_TFM_REQ_MAY_BACKLOG)))
  292. return err;
  293. ahash_restore_req(req, err);
  294. return err;
  295. }
  296. static int crypto_ahash_op(struct ahash_request *req,
  297. int (*op)(struct ahash_request *))
  298. {
  299. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  300. unsigned long alignmask = crypto_ahash_alignmask(tfm);
  301. if ((unsigned long)req->result & alignmask)
  302. return ahash_op_unaligned(req, op);
  303. return op(req);
  304. }
  305. int crypto_ahash_final(struct ahash_request *req)
  306. {
  307. return crypto_ahash_op(req, crypto_ahash_reqtfm(req)->final);
  308. }
  309. EXPORT_SYMBOL_GPL(crypto_ahash_final);
  310. int crypto_ahash_finup(struct ahash_request *req)
  311. {
  312. return crypto_ahash_op(req, crypto_ahash_reqtfm(req)->finup);
  313. }
  314. EXPORT_SYMBOL_GPL(crypto_ahash_finup);
  315. int crypto_ahash_digest(struct ahash_request *req)
  316. {
  317. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  318. if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
  319. return -ENOKEY;
  320. return crypto_ahash_op(req, tfm->digest);
  321. }
  322. EXPORT_SYMBOL_GPL(crypto_ahash_digest);
  323. static void ahash_def_finup_done2(struct crypto_async_request *req, int err)
  324. {
  325. struct ahash_request *areq = req->data;
  326. if (err == -EINPROGRESS)
  327. return;
  328. ahash_restore_req(areq, err);
  329. areq->base.complete(&areq->base, err);
  330. }
  331. static int ahash_def_finup_finish1(struct ahash_request *req, int err)
  332. {
  333. if (err)
  334. goto out;
  335. req->base.complete = ahash_def_finup_done2;
  336. err = crypto_ahash_reqtfm(req)->final(req);
  337. if (err == -EINPROGRESS ||
  338. (err == -EBUSY && (ahash_request_flags(req) &
  339. CRYPTO_TFM_REQ_MAY_BACKLOG)))
  340. return err;
  341. out:
  342. ahash_restore_req(req, err);
  343. return err;
  344. }
  345. static void ahash_def_finup_done1(struct crypto_async_request *req, int err)
  346. {
  347. struct ahash_request *areq = req->data;
  348. if (err == -EINPROGRESS) {
  349. ahash_notify_einprogress(areq);
  350. return;
  351. }
  352. areq->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
  353. err = ahash_def_finup_finish1(areq, err);
  354. if (areq->priv)
  355. return;
  356. areq->base.complete(&areq->base, err);
  357. }
  358. static int ahash_def_finup(struct ahash_request *req)
  359. {
  360. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  361. int err;
  362. err = ahash_save_req(req, ahash_def_finup_done1);
  363. if (err)
  364. return err;
  365. err = tfm->update(req);
  366. if (err == -EINPROGRESS ||
  367. (err == -EBUSY && (ahash_request_flags(req) &
  368. CRYPTO_TFM_REQ_MAY_BACKLOG)))
  369. return err;
  370. return ahash_def_finup_finish1(req, err);
  371. }
  372. static int ahash_no_export(struct ahash_request *req, void *out)
  373. {
  374. return -ENOSYS;
  375. }
  376. static int ahash_no_import(struct ahash_request *req, const void *in)
  377. {
  378. return -ENOSYS;
  379. }
  380. static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
  381. {
  382. struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
  383. struct ahash_alg *alg = crypto_ahash_alg(hash);
  384. hash->setkey = ahash_nosetkey;
  385. hash->export = ahash_no_export;
  386. hash->import = ahash_no_import;
  387. if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
  388. return crypto_init_shash_ops_async(tfm);
  389. hash->init = alg->init;
  390. hash->update = alg->update;
  391. hash->final = alg->final;
  392. hash->finup = alg->finup ?: ahash_def_finup;
  393. hash->digest = alg->digest;
  394. if (alg->setkey) {
  395. hash->setkey = alg->setkey;
  396. ahash_set_needkey(hash);
  397. }
  398. if (alg->export)
  399. hash->export = alg->export;
  400. if (alg->import)
  401. hash->import = alg->import;
  402. return 0;
  403. }
  404. static unsigned int crypto_ahash_extsize(struct crypto_alg *alg)
  405. {
  406. if (alg->cra_type != &crypto_ahash_type)
  407. return sizeof(struct crypto_shash *);
  408. return crypto_alg_extsize(alg);
  409. }
  410. #ifdef CONFIG_NET
  411. static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg)
  412. {
  413. struct crypto_report_hash rhash;
  414. strncpy(rhash.type, "ahash", sizeof(rhash.type));
  415. rhash.blocksize = alg->cra_blocksize;
  416. rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize;
  417. if (nla_put(skb, CRYPTOCFGA_REPORT_HASH,
  418. sizeof(struct crypto_report_hash), &rhash))
  419. goto nla_put_failure;
  420. return 0;
  421. nla_put_failure:
  422. return -EMSGSIZE;
  423. }
  424. #else
  425. static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg)
  426. {
  427. return -ENOSYS;
  428. }
  429. #endif
  430. static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
  431. __attribute__ ((unused));
  432. static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
  433. {
  434. seq_printf(m, "type : ahash\n");
  435. seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ?
  436. "yes" : "no");
  437. seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
  438. seq_printf(m, "digestsize : %u\n",
  439. __crypto_hash_alg_common(alg)->digestsize);
  440. }
  441. const struct crypto_type crypto_ahash_type = {
  442. .extsize = crypto_ahash_extsize,
  443. .init_tfm = crypto_ahash_init_tfm,
  444. #ifdef CONFIG_PROC_FS
  445. .show = crypto_ahash_show,
  446. #endif
  447. .report = crypto_ahash_report,
  448. .maskclear = ~CRYPTO_ALG_TYPE_MASK,
  449. .maskset = CRYPTO_ALG_TYPE_AHASH_MASK,
  450. .type = CRYPTO_ALG_TYPE_AHASH,
  451. .tfmsize = offsetof(struct crypto_ahash, base),
  452. };
  453. EXPORT_SYMBOL_GPL(crypto_ahash_type);
  454. struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, u32 type,
  455. u32 mask)
  456. {
  457. return crypto_alloc_tfm(alg_name, &crypto_ahash_type, type, mask);
  458. }
  459. EXPORT_SYMBOL_GPL(crypto_alloc_ahash);
  460. int crypto_has_ahash(const char *alg_name, u32 type, u32 mask)
  461. {
  462. return crypto_type_has_alg(alg_name, &crypto_ahash_type, type, mask);
  463. }
  464. EXPORT_SYMBOL_GPL(crypto_has_ahash);
  465. static int ahash_prepare_alg(struct ahash_alg *alg)
  466. {
  467. struct crypto_alg *base = &alg->halg.base;
  468. if (alg->halg.digestsize > PAGE_SIZE / 8 ||
  469. alg->halg.statesize > PAGE_SIZE / 8 ||
  470. alg->halg.statesize == 0)
  471. return -EINVAL;
  472. base->cra_type = &crypto_ahash_type;
  473. base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
  474. base->cra_flags |= CRYPTO_ALG_TYPE_AHASH;
  475. return 0;
  476. }
  477. int crypto_register_ahash(struct ahash_alg *alg)
  478. {
  479. struct crypto_alg *base = &alg->halg.base;
  480. int err;
  481. err = ahash_prepare_alg(alg);
  482. if (err)
  483. return err;
  484. return crypto_register_alg(base);
  485. }
  486. EXPORT_SYMBOL_GPL(crypto_register_ahash);
  487. int crypto_unregister_ahash(struct ahash_alg *alg)
  488. {
  489. return crypto_unregister_alg(&alg->halg.base);
  490. }
  491. EXPORT_SYMBOL_GPL(crypto_unregister_ahash);
  492. int ahash_register_instance(struct crypto_template *tmpl,
  493. struct ahash_instance *inst)
  494. {
  495. int err;
  496. err = ahash_prepare_alg(&inst->alg);
  497. if (err)
  498. return err;
  499. return crypto_register_instance(tmpl, ahash_crypto_instance(inst));
  500. }
  501. EXPORT_SYMBOL_GPL(ahash_register_instance);
  502. void ahash_free_instance(struct crypto_instance *inst)
  503. {
  504. crypto_drop_spawn(crypto_instance_ctx(inst));
  505. kfree(ahash_instance(inst));
  506. }
  507. EXPORT_SYMBOL_GPL(ahash_free_instance);
  508. int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
  509. struct hash_alg_common *alg,
  510. struct crypto_instance *inst)
  511. {
  512. return crypto_init_spawn2(&spawn->base, &alg->base, inst,
  513. &crypto_ahash_type);
  514. }
  515. EXPORT_SYMBOL_GPL(crypto_init_ahash_spawn);
  516. struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
  517. {
  518. struct crypto_alg *alg;
  519. alg = crypto_attr_alg2(rta, &crypto_ahash_type, type, mask);
  520. return IS_ERR(alg) ? ERR_CAST(alg) : __crypto_hash_alg_common(alg);
  521. }
  522. EXPORT_SYMBOL_GPL(ahash_attr_alg);
  523. bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg)
  524. {
  525. struct crypto_alg *alg = &halg->base;
  526. if (alg->cra_type != &crypto_ahash_type)
  527. return crypto_shash_alg_has_setkey(__crypto_shash_alg(alg));
  528. return __crypto_ahash_alg(alg)->setkey != NULL;
  529. }
  530. EXPORT_SYMBOL_GPL(crypto_hash_alg_has_setkey);
  531. MODULE_LICENSE("GPL");
  532. MODULE_DESCRIPTION("Asynchronous cryptographic hash type");