pkcs7_parser.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /* PKCS#7 parser
  2. *
  3. * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #define pr_fmt(fmt) "PKCS7: "fmt
  12. #include <linux/kernel.h>
  13. #include <linux/export.h>
  14. #include <linux/slab.h>
  15. #include <linux/err.h>
  16. #include <linux/oid_registry.h>
  17. #include <crypto/public_key.h>
  18. #include "pkcs7_parser.h"
  19. #include "pkcs7-asn1.h"
  20. struct pkcs7_parse_context {
  21. struct pkcs7_message *msg; /* Message being constructed */
  22. struct pkcs7_signed_info *sinfo; /* SignedInfo being constructed */
  23. struct pkcs7_signed_info **ppsinfo;
  24. struct x509_certificate *certs; /* Certificate cache */
  25. struct x509_certificate **ppcerts;
  26. unsigned long data; /* Start of data */
  27. enum OID last_oid; /* Last OID encountered */
  28. unsigned x509_index;
  29. unsigned sinfo_index;
  30. const void *raw_serial;
  31. unsigned raw_serial_size;
  32. unsigned raw_issuer_size;
  33. const void *raw_issuer;
  34. const void *raw_skid;
  35. unsigned raw_skid_size;
  36. bool expect_skid;
  37. };
  38. /*
  39. * Free a signed information block.
  40. */
  41. static void pkcs7_free_signed_info(struct pkcs7_signed_info *sinfo)
  42. {
  43. if (sinfo) {
  44. public_key_signature_free(sinfo->sig);
  45. kfree(sinfo);
  46. }
  47. }
  48. /**
  49. * pkcs7_free_message - Free a PKCS#7 message
  50. * @pkcs7: The PKCS#7 message to free
  51. */
  52. void pkcs7_free_message(struct pkcs7_message *pkcs7)
  53. {
  54. struct x509_certificate *cert;
  55. struct pkcs7_signed_info *sinfo;
  56. if (pkcs7) {
  57. while (pkcs7->certs) {
  58. cert = pkcs7->certs;
  59. pkcs7->certs = cert->next;
  60. x509_free_certificate(cert);
  61. }
  62. while (pkcs7->crl) {
  63. cert = pkcs7->crl;
  64. pkcs7->crl = cert->next;
  65. x509_free_certificate(cert);
  66. }
  67. while (pkcs7->signed_infos) {
  68. sinfo = pkcs7->signed_infos;
  69. pkcs7->signed_infos = sinfo->next;
  70. pkcs7_free_signed_info(sinfo);
  71. }
  72. kfree(pkcs7);
  73. }
  74. }
  75. EXPORT_SYMBOL_GPL(pkcs7_free_message);
  76. /*
  77. * Check authenticatedAttributes are provided or not provided consistently.
  78. */
  79. static int pkcs7_check_authattrs(struct pkcs7_message *msg)
  80. {
  81. struct pkcs7_signed_info *sinfo;
  82. bool want = false;
  83. sinfo = msg->signed_infos;
  84. if (!sinfo)
  85. goto inconsistent;
  86. if (sinfo->authattrs) {
  87. want = true;
  88. msg->have_authattrs = true;
  89. }
  90. for (sinfo = sinfo->next; sinfo; sinfo = sinfo->next)
  91. if (!!sinfo->authattrs != want)
  92. goto inconsistent;
  93. return 0;
  94. inconsistent:
  95. pr_warn("Inconsistently supplied authAttrs\n");
  96. return -EINVAL;
  97. }
  98. /**
  99. * pkcs7_parse_message - Parse a PKCS#7 message
  100. * @data: The raw binary ASN.1 encoded message to be parsed
  101. * @datalen: The size of the encoded message
  102. */
  103. struct pkcs7_message *pkcs7_parse_message(const void *data, size_t datalen)
  104. {
  105. struct pkcs7_parse_context *ctx;
  106. struct pkcs7_message *msg = ERR_PTR(-ENOMEM);
  107. int ret;
  108. ctx = kzalloc(sizeof(struct pkcs7_parse_context), GFP_KERNEL);
  109. if (!ctx)
  110. goto out_no_ctx;
  111. ctx->msg = kzalloc(sizeof(struct pkcs7_message), GFP_KERNEL);
  112. if (!ctx->msg)
  113. goto out_no_msg;
  114. ctx->sinfo = kzalloc(sizeof(struct pkcs7_signed_info), GFP_KERNEL);
  115. if (!ctx->sinfo)
  116. goto out_no_sinfo;
  117. ctx->sinfo->sig = kzalloc(sizeof(struct public_key_signature),
  118. GFP_KERNEL);
  119. if (!ctx->sinfo->sig)
  120. goto out_no_sig;
  121. ctx->data = (unsigned long)data;
  122. ctx->ppcerts = &ctx->certs;
  123. ctx->ppsinfo = &ctx->msg->signed_infos;
  124. /* Attempt to decode the signature */
  125. ret = asn1_ber_decoder(&pkcs7_decoder, ctx, data, datalen);
  126. if (ret < 0) {
  127. msg = ERR_PTR(ret);
  128. goto out;
  129. }
  130. ret = pkcs7_check_authattrs(ctx->msg);
  131. if (ret < 0)
  132. goto out;
  133. msg = ctx->msg;
  134. ctx->msg = NULL;
  135. out:
  136. while (ctx->certs) {
  137. struct x509_certificate *cert = ctx->certs;
  138. ctx->certs = cert->next;
  139. x509_free_certificate(cert);
  140. }
  141. out_no_sig:
  142. pkcs7_free_signed_info(ctx->sinfo);
  143. out_no_sinfo:
  144. pkcs7_free_message(ctx->msg);
  145. out_no_msg:
  146. kfree(ctx);
  147. out_no_ctx:
  148. return msg;
  149. }
  150. EXPORT_SYMBOL_GPL(pkcs7_parse_message);
  151. /**
  152. * pkcs7_get_content_data - Get access to the PKCS#7 content
  153. * @pkcs7: The preparsed PKCS#7 message to access
  154. * @_data: Place to return a pointer to the data
  155. * @_data_len: Place to return the data length
  156. * @_headerlen: Size of ASN.1 header not included in _data
  157. *
  158. * Get access to the data content of the PKCS#7 message. The size of the
  159. * header of the ASN.1 object that contains it is also provided and can be used
  160. * to adjust *_data and *_data_len to get the entire object.
  161. *
  162. * Returns -ENODATA if the data object was missing from the message.
  163. */
  164. int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
  165. const void **_data, size_t *_data_len,
  166. size_t *_headerlen)
  167. {
  168. if (!pkcs7->data)
  169. return -ENODATA;
  170. *_data = pkcs7->data;
  171. *_data_len = pkcs7->data_len;
  172. if (_headerlen)
  173. *_headerlen = pkcs7->data_hdrlen;
  174. return 0;
  175. }
  176. EXPORT_SYMBOL_GPL(pkcs7_get_content_data);
  177. /*
  178. * Note an OID when we find one for later processing when we know how
  179. * to interpret it.
  180. */
  181. int pkcs7_note_OID(void *context, size_t hdrlen,
  182. unsigned char tag,
  183. const void *value, size_t vlen)
  184. {
  185. struct pkcs7_parse_context *ctx = context;
  186. ctx->last_oid = look_up_OID(value, vlen);
  187. if (ctx->last_oid == OID__NR) {
  188. char buffer[50];
  189. sprint_oid(value, vlen, buffer, sizeof(buffer));
  190. printk("PKCS7: Unknown OID: [%lu] %s\n",
  191. (unsigned long)value - ctx->data, buffer);
  192. }
  193. return 0;
  194. }
  195. /*
  196. * Note the digest algorithm for the signature.
  197. */
  198. int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
  199. unsigned char tag,
  200. const void *value, size_t vlen)
  201. {
  202. struct pkcs7_parse_context *ctx = context;
  203. switch (ctx->last_oid) {
  204. case OID_md4:
  205. ctx->sinfo->sig->hash_algo = "md4";
  206. break;
  207. case OID_md5:
  208. ctx->sinfo->sig->hash_algo = "md5";
  209. break;
  210. case OID_sha1:
  211. ctx->sinfo->sig->hash_algo = "sha1";
  212. break;
  213. case OID_sha256:
  214. ctx->sinfo->sig->hash_algo = "sha256";
  215. break;
  216. case OID_sha384:
  217. ctx->sinfo->sig->hash_algo = "sha384";
  218. break;
  219. case OID_sha512:
  220. ctx->sinfo->sig->hash_algo = "sha512";
  221. break;
  222. case OID_sha224:
  223. ctx->sinfo->sig->hash_algo = "sha224";
  224. break;
  225. default:
  226. printk("Unsupported digest algo: %u\n", ctx->last_oid);
  227. return -ENOPKG;
  228. }
  229. return 0;
  230. }
  231. /*
  232. * Note the public key algorithm for the signature.
  233. */
  234. int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
  235. unsigned char tag,
  236. const void *value, size_t vlen)
  237. {
  238. struct pkcs7_parse_context *ctx = context;
  239. switch (ctx->last_oid) {
  240. case OID_rsaEncryption:
  241. ctx->sinfo->sig->pkey_algo = "rsa";
  242. break;
  243. default:
  244. printk("Unsupported pkey algo: %u\n", ctx->last_oid);
  245. return -ENOPKG;
  246. }
  247. return 0;
  248. }
  249. /*
  250. * We only support signed data [RFC2315 sec 9].
  251. */
  252. int pkcs7_check_content_type(void *context, size_t hdrlen,
  253. unsigned char tag,
  254. const void *value, size_t vlen)
  255. {
  256. struct pkcs7_parse_context *ctx = context;
  257. if (ctx->last_oid != OID_signed_data) {
  258. pr_warn("Only support pkcs7_signedData type\n");
  259. return -EINVAL;
  260. }
  261. return 0;
  262. }
  263. /*
  264. * Note the SignedData version
  265. */
  266. int pkcs7_note_signeddata_version(void *context, size_t hdrlen,
  267. unsigned char tag,
  268. const void *value, size_t vlen)
  269. {
  270. struct pkcs7_parse_context *ctx = context;
  271. unsigned version;
  272. if (vlen != 1)
  273. goto unsupported;
  274. ctx->msg->version = version = *(const u8 *)value;
  275. switch (version) {
  276. case 1:
  277. /* PKCS#7 SignedData [RFC2315 sec 9.1]
  278. * CMS ver 1 SignedData [RFC5652 sec 5.1]
  279. */
  280. break;
  281. case 3:
  282. /* CMS ver 3 SignedData [RFC2315 sec 5.1] */
  283. break;
  284. default:
  285. goto unsupported;
  286. }
  287. return 0;
  288. unsupported:
  289. pr_warn("Unsupported SignedData version\n");
  290. return -EINVAL;
  291. }
  292. /*
  293. * Note the SignerInfo version
  294. */
  295. int pkcs7_note_signerinfo_version(void *context, size_t hdrlen,
  296. unsigned char tag,
  297. const void *value, size_t vlen)
  298. {
  299. struct pkcs7_parse_context *ctx = context;
  300. unsigned version;
  301. if (vlen != 1)
  302. goto unsupported;
  303. version = *(const u8 *)value;
  304. switch (version) {
  305. case 1:
  306. /* PKCS#7 SignerInfo [RFC2315 sec 9.2]
  307. * CMS ver 1 SignerInfo [RFC5652 sec 5.3]
  308. */
  309. if (ctx->msg->version != 1)
  310. goto version_mismatch;
  311. ctx->expect_skid = false;
  312. break;
  313. case 3:
  314. /* CMS ver 3 SignerInfo [RFC2315 sec 5.3] */
  315. if (ctx->msg->version == 1)
  316. goto version_mismatch;
  317. ctx->expect_skid = true;
  318. break;
  319. default:
  320. goto unsupported;
  321. }
  322. return 0;
  323. unsupported:
  324. pr_warn("Unsupported SignerInfo version\n");
  325. return -EINVAL;
  326. version_mismatch:
  327. pr_warn("SignedData-SignerInfo version mismatch\n");
  328. return -EBADMSG;
  329. }
  330. /*
  331. * Extract a certificate and store it in the context.
  332. */
  333. int pkcs7_extract_cert(void *context, size_t hdrlen,
  334. unsigned char tag,
  335. const void *value, size_t vlen)
  336. {
  337. struct pkcs7_parse_context *ctx = context;
  338. struct x509_certificate *x509;
  339. if (tag != ((ASN1_UNIV << 6) | ASN1_CONS_BIT | ASN1_SEQ)) {
  340. pr_debug("Cert began with tag %02x at %lu\n",
  341. tag, (unsigned long)ctx - ctx->data);
  342. return -EBADMSG;
  343. }
  344. /* We have to correct for the header so that the X.509 parser can start
  345. * from the beginning. Note that since X.509 stipulates DER, there
  346. * probably shouldn't be an EOC trailer - but it is in PKCS#7 (which
  347. * stipulates BER).
  348. */
  349. value -= hdrlen;
  350. vlen += hdrlen;
  351. if (((u8*)value)[1] == 0x80)
  352. vlen += 2; /* Indefinite length - there should be an EOC */
  353. x509 = x509_cert_parse(value, vlen);
  354. if (IS_ERR(x509))
  355. return PTR_ERR(x509);
  356. x509->index = ++ctx->x509_index;
  357. pr_debug("Got cert %u for %s\n", x509->index, x509->subject);
  358. pr_debug("- fingerprint %*phN\n", x509->id->len, x509->id->data);
  359. *ctx->ppcerts = x509;
  360. ctx->ppcerts = &x509->next;
  361. return 0;
  362. }
  363. /*
  364. * Save the certificate list
  365. */
  366. int pkcs7_note_certificate_list(void *context, size_t hdrlen,
  367. unsigned char tag,
  368. const void *value, size_t vlen)
  369. {
  370. struct pkcs7_parse_context *ctx = context;
  371. pr_devel("Got cert list (%02x)\n", tag);
  372. *ctx->ppcerts = ctx->msg->certs;
  373. ctx->msg->certs = ctx->certs;
  374. ctx->certs = NULL;
  375. ctx->ppcerts = &ctx->certs;
  376. return 0;
  377. }
  378. /*
  379. * Note the content type.
  380. */
  381. int pkcs7_note_content(void *context, size_t hdrlen,
  382. unsigned char tag,
  383. const void *value, size_t vlen)
  384. {
  385. struct pkcs7_parse_context *ctx = context;
  386. if (ctx->last_oid != OID_data &&
  387. ctx->last_oid != OID_msIndirectData) {
  388. pr_warn("Unsupported data type %d\n", ctx->last_oid);
  389. return -EINVAL;
  390. }
  391. ctx->msg->data_type = ctx->last_oid;
  392. return 0;
  393. }
  394. /*
  395. * Extract the data from the message and store that and its content type OID in
  396. * the context.
  397. */
  398. int pkcs7_note_data(void *context, size_t hdrlen,
  399. unsigned char tag,
  400. const void *value, size_t vlen)
  401. {
  402. struct pkcs7_parse_context *ctx = context;
  403. pr_debug("Got data\n");
  404. ctx->msg->data = value;
  405. ctx->msg->data_len = vlen;
  406. ctx->msg->data_hdrlen = hdrlen;
  407. return 0;
  408. }
  409. /*
  410. * Parse authenticated attributes.
  411. */
  412. int pkcs7_sig_note_authenticated_attr(void *context, size_t hdrlen,
  413. unsigned char tag,
  414. const void *value, size_t vlen)
  415. {
  416. struct pkcs7_parse_context *ctx = context;
  417. struct pkcs7_signed_info *sinfo = ctx->sinfo;
  418. enum OID content_type;
  419. pr_devel("AuthAttr: %02x %zu [%*ph]\n", tag, vlen, (unsigned)vlen, value);
  420. switch (ctx->last_oid) {
  421. case OID_contentType:
  422. if (__test_and_set_bit(sinfo_has_content_type, &sinfo->aa_set))
  423. goto repeated;
  424. content_type = look_up_OID(value, vlen);
  425. if (content_type != ctx->msg->data_type) {
  426. pr_warn("Mismatch between global data type (%d) and sinfo %u (%d)\n",
  427. ctx->msg->data_type, sinfo->index,
  428. content_type);
  429. return -EBADMSG;
  430. }
  431. return 0;
  432. case OID_signingTime:
  433. if (__test_and_set_bit(sinfo_has_signing_time, &sinfo->aa_set))
  434. goto repeated;
  435. /* Should we check that the signing time is consistent
  436. * with the signer's X.509 cert?
  437. */
  438. return x509_decode_time(&sinfo->signing_time,
  439. hdrlen, tag, value, vlen);
  440. case OID_messageDigest:
  441. if (__test_and_set_bit(sinfo_has_message_digest, &sinfo->aa_set))
  442. goto repeated;
  443. if (tag != ASN1_OTS)
  444. return -EBADMSG;
  445. sinfo->msgdigest = value;
  446. sinfo->msgdigest_len = vlen;
  447. return 0;
  448. case OID_smimeCapabilites:
  449. if (__test_and_set_bit(sinfo_has_smime_caps, &sinfo->aa_set))
  450. goto repeated;
  451. if (ctx->msg->data_type != OID_msIndirectData) {
  452. pr_warn("S/MIME Caps only allowed with Authenticode\n");
  453. return -EKEYREJECTED;
  454. }
  455. return 0;
  456. /* Microsoft SpOpusInfo seems to be contain cont[0] 16-bit BE
  457. * char URLs and cont[1] 8-bit char URLs.
  458. *
  459. * Microsoft StatementType seems to contain a list of OIDs that
  460. * are also used as extendedKeyUsage types in X.509 certs.
  461. */
  462. case OID_msSpOpusInfo:
  463. if (__test_and_set_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))
  464. goto repeated;
  465. goto authenticode_check;
  466. case OID_msStatementType:
  467. if (__test_and_set_bit(sinfo_has_ms_statement_type, &sinfo->aa_set))
  468. goto repeated;
  469. authenticode_check:
  470. if (ctx->msg->data_type != OID_msIndirectData) {
  471. pr_warn("Authenticode AuthAttrs only allowed with Authenticode\n");
  472. return -EKEYREJECTED;
  473. }
  474. /* I'm not sure how to validate these */
  475. return 0;
  476. default:
  477. return 0;
  478. }
  479. repeated:
  480. /* We permit max one item per AuthenticatedAttribute and no repeats */
  481. pr_warn("Repeated/multivalue AuthAttrs not permitted\n");
  482. return -EKEYREJECTED;
  483. }
  484. /*
  485. * Note the set of auth attributes for digestion purposes [RFC2315 sec 9.3]
  486. */
  487. int pkcs7_sig_note_set_of_authattrs(void *context, size_t hdrlen,
  488. unsigned char tag,
  489. const void *value, size_t vlen)
  490. {
  491. struct pkcs7_parse_context *ctx = context;
  492. struct pkcs7_signed_info *sinfo = ctx->sinfo;
  493. if (!test_bit(sinfo_has_content_type, &sinfo->aa_set) ||
  494. !test_bit(sinfo_has_message_digest, &sinfo->aa_set)) {
  495. pr_warn("Missing required AuthAttr\n");
  496. return -EBADMSG;
  497. }
  498. if (ctx->msg->data_type != OID_msIndirectData &&
  499. test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set)) {
  500. pr_warn("Unexpected Authenticode AuthAttr\n");
  501. return -EBADMSG;
  502. }
  503. /* We need to switch the 'CONT 0' to a 'SET OF' when we digest */
  504. sinfo->authattrs = value - (hdrlen - 1);
  505. sinfo->authattrs_len = vlen + (hdrlen - 1);
  506. return 0;
  507. }
  508. /*
  509. * Note the issuing certificate serial number
  510. */
  511. int pkcs7_sig_note_serial(void *context, size_t hdrlen,
  512. unsigned char tag,
  513. const void *value, size_t vlen)
  514. {
  515. struct pkcs7_parse_context *ctx = context;
  516. ctx->raw_serial = value;
  517. ctx->raw_serial_size = vlen;
  518. return 0;
  519. }
  520. /*
  521. * Note the issuer's name
  522. */
  523. int pkcs7_sig_note_issuer(void *context, size_t hdrlen,
  524. unsigned char tag,
  525. const void *value, size_t vlen)
  526. {
  527. struct pkcs7_parse_context *ctx = context;
  528. ctx->raw_issuer = value;
  529. ctx->raw_issuer_size = vlen;
  530. return 0;
  531. }
  532. /*
  533. * Note the issuing cert's subjectKeyIdentifier
  534. */
  535. int pkcs7_sig_note_skid(void *context, size_t hdrlen,
  536. unsigned char tag,
  537. const void *value, size_t vlen)
  538. {
  539. struct pkcs7_parse_context *ctx = context;
  540. pr_devel("SKID: %02x %zu [%*ph]\n", tag, vlen, (unsigned)vlen, value);
  541. ctx->raw_skid = value;
  542. ctx->raw_skid_size = vlen;
  543. return 0;
  544. }
  545. /*
  546. * Note the signature data
  547. */
  548. int pkcs7_sig_note_signature(void *context, size_t hdrlen,
  549. unsigned char tag,
  550. const void *value, size_t vlen)
  551. {
  552. struct pkcs7_parse_context *ctx = context;
  553. ctx->sinfo->sig->s = kmemdup(value, vlen, GFP_KERNEL);
  554. if (!ctx->sinfo->sig->s)
  555. return -ENOMEM;
  556. ctx->sinfo->sig->s_size = vlen;
  557. return 0;
  558. }
  559. /*
  560. * Note a signature information block
  561. */
  562. int pkcs7_note_signed_info(void *context, size_t hdrlen,
  563. unsigned char tag,
  564. const void *value, size_t vlen)
  565. {
  566. struct pkcs7_parse_context *ctx = context;
  567. struct pkcs7_signed_info *sinfo = ctx->sinfo;
  568. struct asymmetric_key_id *kid;
  569. if (ctx->msg->data_type == OID_msIndirectData && !sinfo->authattrs) {
  570. pr_warn("Authenticode requires AuthAttrs\n");
  571. return -EBADMSG;
  572. }
  573. /* Generate cert issuer + serial number key ID */
  574. if (!ctx->expect_skid) {
  575. kid = asymmetric_key_generate_id(ctx->raw_serial,
  576. ctx->raw_serial_size,
  577. ctx->raw_issuer,
  578. ctx->raw_issuer_size);
  579. } else {
  580. kid = asymmetric_key_generate_id(ctx->raw_skid,
  581. ctx->raw_skid_size,
  582. "", 0);
  583. }
  584. if (IS_ERR(kid))
  585. return PTR_ERR(kid);
  586. pr_devel("SINFO KID: %u [%*phN]\n", kid->len, kid->len, kid->data);
  587. sinfo->sig->auth_ids[0] = kid;
  588. sinfo->index = ++ctx->sinfo_index;
  589. *ctx->ppsinfo = sinfo;
  590. ctx->ppsinfo = &sinfo->next;
  591. ctx->sinfo = kzalloc(sizeof(struct pkcs7_signed_info), GFP_KERNEL);
  592. if (!ctx->sinfo)
  593. return -ENOMEM;
  594. ctx->sinfo->sig = kzalloc(sizeof(struct public_key_signature),
  595. GFP_KERNEL);
  596. if (!ctx->sinfo->sig)
  597. return -ENOMEM;
  598. return 0;
  599. }