aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/x509/pkcs7.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/x509/pkcs7.c')
-rw-r--r--src/daemon/https/x509/pkcs7.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/daemon/https/x509/pkcs7.c b/src/daemon/https/x509/pkcs7.c
index 8b0b6b54..45f2b03c 100644
--- a/src/daemon/https/x509/pkcs7.c
+++ b/src/daemon/https/x509/pkcs7.c
@@ -69,7 +69,8 @@ _decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata,
69 } 69 }
70 70
71 if ((result = MHD__asn1_create_element 71 if ((result = MHD__asn1_create_element
72 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", &c2)) != ASN1_SUCCESS) 72 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData",
73 &c2)) != ASN1_SUCCESS)
73 { 74 {
74 MHD_gnutls_assert (); 75 MHD_gnutls_assert ();
75 return MHD_gtls_asn2err (result); 76 return MHD_gtls_asn2err (result);
@@ -158,8 +159,8 @@ MHD_gnutls_pkcs7_init (MHD_gnutls_pkcs7_t * pkcs7)
158 if (*pkcs7) 159 if (*pkcs7)
159 { 160 {
160 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), 161 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
161 "PKIX1.pkcs-7-ContentInfo", 162 "PKIX1.pkcs-7-ContentInfo",
162 &(*pkcs7)->pkcs7); 163 &(*pkcs7)->pkcs7);
163 if (result != ASN1_SUCCESS) 164 if (result != ASN1_SUCCESS)
164 { 165 {
165 MHD_gnutls_assert (); 166 MHD_gnutls_assert ();
@@ -205,8 +206,9 @@ MHD_gnutls_pkcs7_deinit (MHD_gnutls_pkcs7_t pkcs7)
205 * 206 *
206 **/ 207 **/
207int 208int
208MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * data, 209MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7,
209 MHD_gnutls_x509_crt_fmt_t format) 210 const MHD_gnutls_datum_t * data,
211 MHD_gnutls_x509_crt_fmt_t format)
210{ 212{
211 int result = 0, need_free = 0; 213 int result = 0, need_free = 0;
212 MHD_gnutls_datum_t _data; 214 MHD_gnutls_datum_t _data;
@@ -224,7 +226,7 @@ MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * da
224 opaque *out; 226 opaque *out;
225 227
226 result = MHD__gnutls_fbase64_decode (PEM_PKCS7, data->data, data->size, 228 result = MHD__gnutls_fbase64_decode (PEM_PKCS7, data->data, data->size,
227 &out); 229 &out);
228 230
229 if (result <= 0) 231 if (result <= 0)
230 { 232 {
@@ -241,7 +243,8 @@ MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * da
241 } 243 }
242 244
243 245
244 result = MHD__asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL); 246 result =
247 MHD__asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL);
245 if (result != ASN1_SUCCESS) 248 if (result != ASN1_SUCCESS)
246 { 249 {
247 result = MHD_gtls_asn2err (result); 250 result = MHD_gtls_asn2err (result);
@@ -277,8 +280,8 @@ cleanup:
277 **/ 280 **/
278int 281int
279MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7, 282MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
280 int indx, void *certificate, 283 int indx, void *certificate,
281 size_t * certificate_size) 284 size_t * certificate_size)
282{ 285{
283 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 286 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
284 int result, len; 287 int result, len;
@@ -327,7 +330,7 @@ MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
327 int start, end; 330 int start, end;
328 331
329 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, 332 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size,
330 root2, &start, &end); 333 root2, &start, &end);
331 334
332 if (result != ASN1_SUCCESS) 335 if (result != ASN1_SUCCESS)
333 { 336 {
@@ -432,14 +435,14 @@ MHD_gnutls_pkcs7_get_crt_count (MHD_gnutls_pkcs7_t pkcs7)
432 **/ 435 **/
433int 436int
434MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7, 437MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7,
435 MHD_gnutls_x509_crt_fmt_t format, void *output_data, 438 MHD_gnutls_x509_crt_fmt_t format, void *output_data,
436 size_t * output_data_size) 439 size_t * output_data_size)
437{ 440{
438 if (pkcs7 == NULL) 441 if (pkcs7 == NULL)
439 return GNUTLS_E_INVALID_REQUEST; 442 return GNUTLS_E_INVALID_REQUEST;
440 443
441 return MHD__gnutls_x509_export_int (pkcs7->pkcs7, format, PEM_PKCS7, 444 return MHD__gnutls_x509_export_int (pkcs7->pkcs7, format, PEM_PKCS7,
442 output_data, output_data_size); 445 output_data, output_data_size);
443} 446}
444 447
445/* Creates an empty signed data structure in the pkcs7 448/* Creates an empty signed data structure in the pkcs7
@@ -478,7 +481,7 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata)
478 /* id-data */ 481 /* id-data */
479 result = 482 result =
480 MHD__asn1_write_value (*sdata, "encapContentInfo.eContentType", 483 MHD__asn1_write_value (*sdata, "encapContentInfo.eContentType",
481 "1.2.840.113549.1.7.5", 1); 484 "1.2.840.113549.1.7.5", 1);
482 if (result != ASN1_SUCCESS) 485 if (result != ASN1_SUCCESS)
483 { 486 {
484 MHD_gnutls_assert (); 487 MHD_gnutls_assert ();
@@ -486,7 +489,8 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata)
486 goto cleanup; 489 goto cleanup;
487 } 490 }
488 491
489 result = MHD__asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0); 492 result =
493 MHD__asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0);
490 if (result != ASN1_SUCCESS) 494 if (result != ASN1_SUCCESS)
491 { 495 {
492 MHD_gnutls_assert (); 496 MHD_gnutls_assert ();
@@ -531,7 +535,8 @@ cleanup:
531 * 535 *
532 **/ 536 **/
533int 537int
534MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crt) 538MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
539 const MHD_gnutls_datum_t * crt)
535{ 540{
536 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 541 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
537 int result; 542 int result;
@@ -585,7 +590,7 @@ MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t
585 590
586 result = 591 result =
587 MHD__asn1_write_value (c2, "certificates.?LAST.certificate", crt->data, 592 MHD__asn1_write_value (c2, "certificates.?LAST.certificate", crt->data,
588 crt->size); 593 crt->size);
589 if (result != ASN1_SUCCESS) 594 if (result != ASN1_SUCCESS)
590 { 595 {
591 MHD_gnutls_assert (); 596 MHD_gnutls_assert ();
@@ -735,7 +740,7 @@ cleanup:
735 **/ 740 **/
736int 741int
737MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7, 742MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
738 int indx, void *crl, size_t * crl_size) 743 int indx, void *crl, size_t * crl_size)
739{ 744{
740 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 745 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
741 int result; 746 int result;
@@ -763,7 +768,7 @@ MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
763 /* Get the raw CRL 768 /* Get the raw CRL
764 */ 769 */
765 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, 770 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size,
766 root2, &start, &end); 771 root2, &start, &end);
767 772
768 if (result != ASN1_SUCCESS) 773 if (result != ASN1_SUCCESS)
769 { 774 {
@@ -849,7 +854,8 @@ MHD_gnutls_pkcs7_get_crl_count (MHD_gnutls_pkcs7_t pkcs7)
849 * 854 *
850 **/ 855 **/
851int 856int
852MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crl) 857MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
858 const MHD_gnutls_datum_t * crl)
853{ 859{
854 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 860 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
855 int result; 861 int result;