You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cms.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. /** @file
  20. *
  21. * Cryptographic Message Syntax (PKCS #7)
  22. *
  23. * The format of CMS messages is defined in RFC 5652.
  24. *
  25. */
  26. #include <stdint.h>
  27. #include <string.h>
  28. #include <time.h>
  29. #include <errno.h>
  30. #include <ipxe/asn1.h>
  31. #include <ipxe/x509.h>
  32. #include <ipxe/uaccess.h>
  33. #include <ipxe/cms.h>
  34. /* Disambiguate the various error causes */
  35. #define EACCES_NON_SIGNING \
  36. __einfo_error ( EINFO_EACCES_NON_SIGNING )
  37. #define EINFO_EACCES_NON_SIGNING \
  38. __einfo_uniqify ( EINFO_EACCES, 0x01, "Not a signing certificate" )
  39. #define EACCES_NON_CODE_SIGNING \
  40. __einfo_error ( EINFO_EACCES_NON_CODE_SIGNING )
  41. #define EINFO_EACCES_NON_CODE_SIGNING \
  42. __einfo_uniqify ( EINFO_EACCES, 0x02, "Not a code-signing certificate" )
  43. #define EACCES_INCOMPLETE \
  44. __einfo_error ( EINFO_EACCES_INCOMPLETE )
  45. #define EINFO_EACCES_INCOMPLETE \
  46. __einfo_uniqify ( EINFO_EACCES, 0x03, "Incomplete certificate chain" )
  47. #define EACCES_WRONG_NAME \
  48. __einfo_error ( EINFO_EACCES_WRONG_NAME )
  49. #define EINFO_EACCES_WRONG_NAME \
  50. __einfo_uniqify ( EINFO_EACCES, 0x04, "Incorrect certificate name" )
  51. #define EINVAL_DIGEST \
  52. __einfo_error ( EINFO_EINVAL_DIGEST )
  53. #define EINFO_EINVAL_DIGEST \
  54. __einfo_uniqify ( EINFO_EINVAL, 0x01, "Not a digest algorithm" )
  55. #define EINVAL_PUBKEY \
  56. __einfo_error ( EINFO_EINVAL_PUBKEY )
  57. #define EINFO_EINVAL_PUBKEY \
  58. __einfo_uniqify ( EINFO_EINVAL, 0x02, "Not a public-key algorithm" )
  59. #define ENOTSUP_SIGNEDDATA \
  60. __einfo_error ( EINFO_ENOTSUP_SIGNEDDATA )
  61. #define EINFO_ENOTSUP_SIGNEDDATA \
  62. __einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Not a digital signature" )
  63. #define ENOTSUP_DIGEST \
  64. __einfo_error ( EINFO_ENOTSUP_DIGEST )
  65. #define EINFO_ENOTSUP_DIGEST \
  66. __einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported digest algorithm" )
  67. #define ENOTSUP_PUBKEY \
  68. __einfo_error ( EINFO_ENOTSUP_PUBKEY )
  69. #define EINFO_ENOTSUP_PUBKEY \
  70. __einfo_uniqify ( EINFO_ENOTSUP, 0x03, \
  71. "Unsupported public-key algorithm" )
  72. /** "pkcs7-signedData" object identifier */
  73. static uint8_t oid_signeddata[] = { ASN1_OID_SIGNEDDATA };
  74. /** "pkcs7-signedData" object identifier cursor */
  75. static struct asn1_cursor oid_signeddata_cursor =
  76. ASN1_OID_CURSOR ( oid_signeddata );
  77. /**
  78. * Parse CMS signature content type
  79. *
  80. * @v sig CMS signature
  81. * @v raw ASN.1 cursor
  82. * @ret rc Return status code
  83. */
  84. static int cms_parse_content_type ( struct cms_signature *sig,
  85. const struct asn1_cursor *raw ) {
  86. struct asn1_cursor cursor;
  87. /* Enter contentType */
  88. memcpy ( &cursor, raw, sizeof ( cursor ) );
  89. asn1_enter ( &cursor, ASN1_OID );
  90. /* Check OID is pkcs7-signedData */
  91. if ( asn1_compare ( &cursor, &oid_signeddata_cursor ) != 0 ) {
  92. DBGC ( sig, "CMS %p does not contain signedData:\n", sig );
  93. DBGC_HDA ( sig, 0, raw->data, raw->len );
  94. return -ENOTSUP_SIGNEDDATA;
  95. }
  96. DBGC ( sig, "CMS %p contains signedData\n", sig );
  97. return 0;
  98. }
  99. /**
  100. * Parse CMS signature signer identifier
  101. *
  102. * @v sig CMS signature
  103. * @v info Signer information to fill in
  104. * @v raw ASN.1 cursor
  105. * @ret rc Return status code
  106. */
  107. static int cms_parse_signer_identifier ( struct cms_signature *sig,
  108. struct cms_signer_info *info,
  109. const struct asn1_cursor *raw ) {
  110. struct asn1_cursor cursor;
  111. int rc;
  112. /* Enter issuerAndSerialNumber */
  113. memcpy ( &cursor, raw, sizeof ( cursor ) );
  114. asn1_enter ( &cursor, ASN1_SEQUENCE );
  115. /* Record issuer */
  116. memcpy ( &info->issuer, &cursor, sizeof ( info->issuer ) );
  117. if ( ( rc = asn1_shrink ( &info->issuer, ASN1_SEQUENCE ) ) != 0 ) {
  118. DBGC ( sig, "CMS %p/%p could not locate issuer: %s\n",
  119. sig, info, strerror ( rc ) );
  120. DBGC_HDA ( sig, 0, raw->data, raw->len );
  121. return rc;
  122. }
  123. DBGC ( sig, "CMS %p/%p issuer is:\n", sig, info );
  124. DBGC_HDA ( sig, 0, info->issuer.data, info->issuer.len );
  125. asn1_skip_any ( &cursor );
  126. /* Record serialNumber */
  127. memcpy ( &info->serial, &cursor, sizeof ( info->serial ) );
  128. if ( ( rc = asn1_shrink ( &info->serial, ASN1_INTEGER ) ) != 0 ) {
  129. DBGC ( sig, "CMS %p/%p could not locate serialNumber: %s\n",
  130. sig, info, strerror ( rc ) );
  131. DBGC_HDA ( sig, 0, raw->data, raw->len );
  132. return rc;
  133. }
  134. DBGC ( sig, "CMS %p/%p serial number is:\n", sig, info );
  135. DBGC_HDA ( sig, 0, info->serial.data, info->serial.len );
  136. return 0;
  137. }
  138. /**
  139. * Parse CMS signature digest algorithm
  140. *
  141. * @v sig CMS signature
  142. * @v info Signer information to fill in
  143. * @v raw ASN.1 cursor
  144. * @ret rc Return status code
  145. */
  146. static int cms_parse_digest_algorithm ( struct cms_signature *sig,
  147. struct cms_signer_info *info,
  148. const struct asn1_cursor *raw ) {
  149. struct asn1_algorithm *algorithm;
  150. /* Identify algorithm */
  151. algorithm = asn1_algorithm ( raw );
  152. if ( ! algorithm ) {
  153. DBGC ( sig, "CMS %p/%p could not identify digest algorithm:\n",
  154. sig, info );
  155. DBGC_HDA ( sig, 0, raw->data, raw->len );
  156. return -ENOTSUP_DIGEST;
  157. }
  158. /* Check algorithm is a digest algorithm */
  159. if ( ! algorithm->digest ) {
  160. DBGC ( sig, "CMS %p/%p algorithm %s is not a digest "
  161. "algorithm\n", sig, info, algorithm->name );
  162. return -EINVAL_DIGEST;
  163. }
  164. /* Record digest algorithm */
  165. info->digest = algorithm->digest;
  166. DBGC ( sig, "CMS %p/%p digest algorithm is %s\n",
  167. sig, info, algorithm->name );
  168. return 0;
  169. }
  170. /**
  171. * Parse CMS signature algorithm
  172. *
  173. * @v sig CMS signature
  174. * @v info Signer information to fill in
  175. * @v raw ASN.1 cursor
  176. * @ret rc Return status code
  177. */
  178. static int cms_parse_signature_algorithm ( struct cms_signature *sig,
  179. struct cms_signer_info *info,
  180. const struct asn1_cursor *raw ) {
  181. struct asn1_algorithm *algorithm;
  182. /* Identify algorithm */
  183. algorithm = asn1_algorithm ( raw );
  184. if ( ! algorithm ) {
  185. DBGC ( sig, "CMS %p/%p could not identify public-key "
  186. "algorithm:\n", sig, info );
  187. DBGC_HDA ( sig, 0, raw->data, raw->len );
  188. return -ENOTSUP_PUBKEY;
  189. }
  190. /* Check algorithm is a signature algorithm */
  191. if ( ! algorithm->pubkey ) {
  192. DBGC ( sig, "CMS %p/%p algorithm %s is not a public-key "
  193. "algorithm\n", sig, info, algorithm->name );
  194. return -EINVAL_PUBKEY;
  195. }
  196. /* Record signature algorithm */
  197. info->pubkey = algorithm->pubkey;
  198. DBGC ( sig, "CMS %p/%p public-key algorithm is %s\n",
  199. sig, info, algorithm->name );
  200. return 0;
  201. }
  202. /**
  203. * Parse CMS signature value
  204. *
  205. * @v sig CMS signature
  206. * @v info Signer information to fill in
  207. * @v raw ASN.1 cursor
  208. * @ret rc Return status code
  209. */
  210. static int cms_parse_signature_value ( struct cms_signature *sig,
  211. struct cms_signer_info *info,
  212. const struct asn1_cursor *raw ) {
  213. struct asn1_cursor cursor;
  214. int rc;
  215. /* Enter signature */
  216. memcpy ( &cursor, raw, sizeof ( cursor ) );
  217. if ( ( rc = asn1_enter ( &cursor, ASN1_OCTET_STRING ) ) != 0 ) {
  218. DBGC ( sig, "CMS %p/%p could not locate signature:\n",
  219. sig, info );
  220. DBGC_HDA ( sig, 0, raw->data, raw->len );
  221. return rc;
  222. }
  223. /* Record signature */
  224. info->signature = cursor.data;
  225. info->signature_len = cursor.len;
  226. DBGC ( sig, "CMS %p/%p signature value is:\n", sig, info );
  227. DBGC_HDA ( sig, 0, info->signature, info->signature_len );
  228. return 0;
  229. }
  230. /**
  231. * Parse CMS signature signer information
  232. *
  233. * @v sig CMS signature
  234. * @v info Signer information to fill in
  235. * @v raw ASN.1 cursor
  236. * @ret rc Return status code
  237. */
  238. static int cms_parse_signer_info ( struct cms_signature *sig,
  239. struct cms_signer_info *info,
  240. const struct asn1_cursor *raw ) {
  241. struct asn1_cursor cursor;
  242. int rc;
  243. /* Enter signerInfo */
  244. memcpy ( &cursor, raw, sizeof ( cursor ) );
  245. asn1_enter ( &cursor, ASN1_SEQUENCE );
  246. /* Skip version */
  247. asn1_skip ( &cursor, ASN1_INTEGER );
  248. /* Parse sid */
  249. if ( ( rc = cms_parse_signer_identifier ( sig, info, &cursor ) ) != 0 )
  250. return rc;
  251. asn1_skip_any ( &cursor );
  252. /* Parse digestAlgorithm */
  253. if ( ( rc = cms_parse_digest_algorithm ( sig, info, &cursor ) ) != 0 )
  254. return rc;
  255. asn1_skip_any ( &cursor );
  256. /* Skip signedAttrs, if present */
  257. asn1_skip_if_exists ( &cursor, ASN1_EXPLICIT_TAG ( 0 ) );
  258. /* Parse signatureAlgorithm */
  259. if ( ( rc = cms_parse_signature_algorithm ( sig, info, &cursor ) ) != 0)
  260. return rc;
  261. asn1_skip_any ( &cursor );
  262. /* Parse signature */
  263. if ( ( rc = cms_parse_signature_value ( sig, info, &cursor ) ) != 0 )
  264. return rc;
  265. return 0;
  266. }
  267. /**
  268. * Parse CMS signature from ASN.1 data
  269. *
  270. * @v sig CMS signature
  271. * @v data Raw signature data
  272. * @v len Length of raw data
  273. * @ret rc Return status code
  274. */
  275. int cms_parse ( struct cms_signature *sig, const void *data, size_t len ) {
  276. struct asn1_cursor cursor;
  277. int rc;
  278. /* Initialise signature */
  279. memset ( sig, 0, sizeof ( *sig ) );
  280. cursor.data = data;
  281. cursor.len = len;
  282. /* Enter contentInfo */
  283. asn1_enter ( &cursor, ASN1_SEQUENCE );
  284. /* Parse contentType */
  285. if ( ( rc = cms_parse_content_type ( sig, &cursor ) ) != 0 )
  286. return rc;
  287. asn1_skip_any ( &cursor );
  288. /* Enter content */
  289. asn1_enter ( &cursor, ASN1_EXPLICIT_TAG ( 0 ) );
  290. /* Enter signedData */
  291. asn1_enter ( &cursor, ASN1_SEQUENCE );
  292. /* Skip version */
  293. asn1_skip ( &cursor, ASN1_INTEGER );
  294. /* Skip digestAlgorithms */
  295. asn1_skip ( &cursor, ASN1_SET );
  296. /* Skip encapContentInfo */
  297. asn1_skip ( &cursor, ASN1_SEQUENCE );
  298. /* Record certificates */
  299. memcpy ( &sig->certificates, &cursor, sizeof ( sig->certificates ) );
  300. if ( ( rc = asn1_enter ( &sig->certificates,
  301. ASN1_EXPLICIT_TAG ( 0 ) ) ) != 0 ) {
  302. DBGC ( sig, "CMS %p could not locate certificates:\n", sig );
  303. DBGC_HDA ( sig, 0, data, len );
  304. return rc;
  305. }
  306. asn1_skip_any ( &cursor );
  307. /* Skip crls, if present */
  308. asn1_skip_if_exists ( &cursor, ASN1_EXPLICIT_TAG ( 1 ) );
  309. /* Enter signerInfos */
  310. asn1_enter ( &cursor, ASN1_SET );
  311. /* Parse first signerInfo */
  312. if ( ( rc = cms_parse_signer_info ( sig, &sig->info, &cursor ) ) != 0 )
  313. return rc;
  314. return 0;
  315. }
  316. /** CMS certificate chain context */
  317. struct cms_chain_context {
  318. /** Signature */
  319. struct cms_signature *sig;
  320. /** Signer information */
  321. struct cms_signer_info *info;
  322. };
  323. /**
  324. * Parse next certificate in chain
  325. *
  326. * @v cert X.509 certificate to parse
  327. * @v previous Previous X.509 certificate, or NULL
  328. * @v ctx Chain context
  329. * @ret rc Return status code
  330. */
  331. static int cms_parse_next ( struct x509_certificate *cert,
  332. const struct x509_certificate *previous,
  333. void *ctx ) {
  334. struct cms_chain_context *context = ctx;
  335. struct cms_signature *sig = context->sig;
  336. struct cms_signer_info *info = context->info;
  337. struct asn1_cursor cursor;
  338. int rc;
  339. /* Search for relevant certificate */
  340. memcpy ( &cursor, &sig->certificates, sizeof ( cursor ) );
  341. while ( cursor.len ) {
  342. /* Parse certificate */
  343. if ( ( rc = x509_parse ( cert, cursor.data,
  344. cursor.len ) ) != 0 ) {
  345. DBGC ( sig, "CMS %p/%p could not parse certificate:\n",
  346. sig, info );
  347. DBGC_HDA ( sig, 0, cursor.data, cursor.len );
  348. return rc;
  349. }
  350. if ( previous == NULL ) {
  351. /* First certificate: check issuer and serial
  352. * number against signer info
  353. */
  354. if ( ( asn1_compare ( &info->issuer,
  355. &cert->issuer.raw ) == 0 ) &&
  356. ( asn1_compare ( &info->serial,
  357. &cert->serial.raw ) == 0 ) ) {
  358. return 0;
  359. }
  360. } else {
  361. /* Subsequent certificates: check subject
  362. * against previous certificate's issuer.
  363. */
  364. if ( asn1_compare ( &previous->issuer.raw,
  365. &cert->subject.raw ) == 0 ) {
  366. return 0;
  367. }
  368. }
  369. /* Move to next certificate */
  370. asn1_skip_any ( &cursor );
  371. }
  372. DBGC ( sig, "CMS %p/%p reached end of certificate chain\n", sig, info );
  373. return -EACCES_INCOMPLETE;
  374. }
  375. /**
  376. * Calculate digest of CMS-signed data
  377. *
  378. * @v sig CMS signature
  379. * @v info Signer information
  380. * @v data Signed data
  381. * @v len Length of signed data
  382. * @v out Digest output
  383. */
  384. static void cms_digest ( struct cms_signature *sig,
  385. struct cms_signer_info *info,
  386. userptr_t data, size_t len, void *out ) {
  387. struct digest_algorithm *digest = info->digest;
  388. uint8_t ctx[ digest->ctxsize ];
  389. uint8_t block[ digest->blocksize ];
  390. size_t offset = 0;
  391. size_t frag_len;
  392. /* Initialise digest */
  393. digest_init ( digest, ctx );
  394. /* Process data one block at a time */
  395. while ( len ) {
  396. frag_len = len;
  397. if ( frag_len > sizeof ( block ) )
  398. frag_len = sizeof ( block );
  399. copy_from_user ( block, data, offset, frag_len );
  400. digest_update ( digest, ctx, block, frag_len );
  401. offset += frag_len;
  402. len -= frag_len;
  403. }
  404. /* Finalise digest */
  405. digest_final ( digest, ctx, out );
  406. DBGC ( sig, "CMS %p/%p digest value:\n", sig, info );
  407. DBGC_HDA ( sig, 0, out, digest->digestsize );
  408. }
  409. /**
  410. * Verify digest of CMS-signed data
  411. *
  412. * @v sig CMS signature
  413. * @v info Signer information
  414. * @v cert Corresponding certificate
  415. * @v data Signed data
  416. * @v len Length of signed data
  417. * @ret rc Return status code
  418. */
  419. static int cms_verify_digest ( struct cms_signature *sig,
  420. struct cms_signer_info *info,
  421. struct x509_certificate *cert,
  422. userptr_t data, size_t len ) {
  423. struct digest_algorithm *digest = info->digest;
  424. struct pubkey_algorithm *pubkey = info->pubkey;
  425. struct x509_public_key *public_key = &cert->subject.public_key;
  426. uint8_t digest_out[ digest->digestsize ];
  427. uint8_t ctx[ pubkey->ctxsize ];
  428. int rc;
  429. /* Generate digest */
  430. cms_digest ( sig, info, data, len, digest_out );
  431. /* Initialise public-key algorithm */
  432. if ( ( rc = pubkey_init ( pubkey, ctx, public_key->raw.data,
  433. public_key->raw.len ) ) != 0 ) {
  434. DBGC ( sig, "CMS %p/%p could not initialise public key: %s\n",
  435. sig, info, strerror ( rc ) );
  436. goto err_init;
  437. }
  438. /* Verify digest */
  439. if ( ( rc = pubkey_verify ( pubkey, ctx, digest, digest_out,
  440. info->signature,
  441. info->signature_len ) ) != 0 ) {
  442. DBGC ( sig, "CMS %p/%p signature verification failed: %s\n",
  443. sig, info, strerror ( rc ) );
  444. return rc;
  445. }
  446. pubkey_final ( pubkey, ctx );
  447. err_init:
  448. return rc;
  449. }
  450. /**
  451. * Verify CMS signature signer information
  452. *
  453. * @v sig CMS signature
  454. * @v info Signer information
  455. * @v data Signed data
  456. * @v len Length of signed data
  457. * @v name Required common name, or NULL to allow any name
  458. * @v time Time at which to validate certificates
  459. * @v root Root certificate store, or NULL to use default
  460. * @ret rc Return status code
  461. */
  462. static int cms_verify_signer_info ( struct cms_signature *sig,
  463. struct cms_signer_info *info,
  464. userptr_t data, size_t len,
  465. const char *name, time_t time,
  466. struct x509_root *root ) {
  467. struct cms_chain_context context;
  468. struct x509_certificate cert;
  469. int rc;
  470. /* Validate certificate chain */
  471. context.sig = sig;
  472. context.info = info;
  473. if ( ( rc = x509_validate_chain ( cms_parse_next, &context, time, root,
  474. &cert ) ) != 0 ) {
  475. DBGC ( sig, "CMS %p/%p could not validate chain: %s\n",
  476. sig, info, strerror ( rc ) );
  477. return rc;
  478. }
  479. /* Check that certificate can create digital signatures */
  480. if ( ! ( cert.extensions.usage.bits & X509_DIGITAL_SIGNATURE ) ) {
  481. DBGC ( sig, "CMS %p/%p certificate cannot create signatures\n",
  482. sig, info );
  483. return -EACCES_NON_SIGNING;
  484. }
  485. /* Check that certificate can sign code */
  486. if ( ! ( cert.extensions.ext_usage.bits & X509_CODE_SIGNING ) ) {
  487. DBGC ( sig, "CMS %p/%p certificate is not code-signing\n",
  488. sig, info );
  489. return -EACCES_NON_CODE_SIGNING;
  490. }
  491. /* Check certificate name, if applicable */
  492. if ( ( name != NULL ) &&
  493. ( ( cert.subject.name.len != strlen ( name ) ) ||
  494. ( memcmp ( cert.subject.name.data, name,
  495. cert.subject.name.len ) != 0 ) ) ) {
  496. DBGC ( sig, "CMS %p/%p certificate name incorrect\n",
  497. sig, info );
  498. return -EACCES_WRONG_NAME;
  499. }
  500. /* Verify digest */
  501. if ( ( rc = cms_verify_digest ( sig, info, &cert, data, len ) ) != 0 )
  502. return rc;
  503. return 0;
  504. }
  505. /**
  506. * Verify CMS signature
  507. *
  508. * @v sig CMS signature
  509. * @v data Signed data
  510. * @v len Length of signed data
  511. * @v name Required common name, or NULL to allow any name
  512. * @v time Time at which to validate certificates
  513. * @v root Root certificate store, or NULL to use default
  514. * @ret rc Return status code
  515. */
  516. int cms_verify ( struct cms_signature *sig, userptr_t data, size_t len,
  517. const char *name, time_t time, struct x509_root *root ) {
  518. int rc;
  519. /* Verify using first signerInfo */
  520. if ( ( rc = cms_verify_signer_info ( sig, &sig->info, data, len,
  521. name, time, root ) ) != 0 )
  522. return rc;
  523. return 0;
  524. }