aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/x509/crl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/x509/crl.c')
-rw-r--r--src/daemon/https/x509/crl.c74
1 files changed, 40 insertions, 34 deletions
diff --git a/src/daemon/https/x509/crl.c b/src/daemon/https/x509/crl.c
index 17703b91..e023a193 100644
--- a/src/daemon/https/x509/crl.c
+++ b/src/daemon/https/x509/crl.c
@@ -56,8 +56,8 @@ MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl)
56 if (*crl) 56 if (*crl)
57 { 57 {
58 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), 58 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
59 "PKIX1.CertificateList", 59 "PKIX1.CertificateList",
60 &(*crl)->crl); 60 &(*crl)->crl);
61 if (result != ASN1_SUCCESS) 61 if (result != ASN1_SUCCESS)
62 { 62 {
63 MHD_gnutls_assert (); 63 MHD_gnutls_assert ();
@@ -104,8 +104,8 @@ MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl)
104 **/ 104 **/
105int 105int
106MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl, 106MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl,
107 const MHD_gnutls_datum_t * data, 107 const MHD_gnutls_datum_t * data,
108 MHD_gnutls_x509_crt_fmt_t format) 108 MHD_gnutls_x509_crt_fmt_t format)
109{ 109{
110 int result = 0, need_free = 0; 110 int result = 0, need_free = 0;
111 MHD_gnutls_datum_t _data; 111 MHD_gnutls_datum_t _data;
@@ -125,7 +125,8 @@ MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl,
125 { 125 {
126 opaque *out; 126 opaque *out;
127 127
128 result = MHD__gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out); 128 result =
129 MHD__gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out);
129 130
130 if (result <= 0) 131 if (result <= 0)
131 { 132 {
@@ -181,7 +182,7 @@ cleanup:
181 **/ 182 **/
182int 183int
183MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf, 184MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf,
184 size_t * sizeof_buf) 185 size_t * sizeof_buf)
185{ 186{
186 if (crl == NULL) 187 if (crl == NULL)
187 { 188 {
@@ -190,8 +191,8 @@ MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf,
190 } 191 }
191 192
192 return MHD__gnutls_x509_parse_dn (crl->crl, 193 return MHD__gnutls_x509_parse_dn (crl->crl,
193 "tbsCertList.issuer.rdnSequence", 194 "tbsCertList.issuer.rdnSequence",
194 buf, sizeof_buf); 195 buf, sizeof_buf);
195} 196}
196 197
197/** 198/**
@@ -221,9 +222,9 @@ MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf,
221 **/ 222 **/
222int 223int
223MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl, 224MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl,
224 const char *oid, int indx, 225 const char *oid, int indx,
225 unsigned int raw_flag, void *buf, 226 unsigned int raw_flag, void *buf,
226 size_t * sizeof_buf) 227 size_t * sizeof_buf)
227{ 228{
228 if (crl == NULL) 229 if (crl == NULL)
229 { 230 {
@@ -232,8 +233,8 @@ MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl,
232 } 233 }
233 234
234 return MHD__gnutls_x509_parse_dn_oid (crl->crl, 235 return MHD__gnutls_x509_parse_dn_oid (crl->crl,
235 "tbsCertList.issuer.rdnSequence", 236 "tbsCertList.issuer.rdnSequence",
236 oid, indx, raw_flag, buf, sizeof_buf); 237 oid, indx, raw_flag, buf, sizeof_buf);
237} 238}
238 239
239/** 240/**
@@ -255,7 +256,7 @@ MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl,
255 **/ 256 **/
256int 257int
257MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl, 258MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl,
258 int indx, void *oid, size_t * sizeof_oid) 259 int indx, void *oid, size_t * sizeof_oid)
259{ 260{
260 if (crl == NULL) 261 if (crl == NULL)
261 { 262 {
@@ -264,8 +265,8 @@ MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl,
264 } 265 }
265 266
266 return MHD__gnutls_x509_get_dn_oid (crl->crl, 267 return MHD__gnutls_x509_get_dn_oid (crl->crl,
267 "tbsCertList.issuer.rdnSequence", indx, 268 "tbsCertList.issuer.rdnSequence", indx,
268 oid, sizeof_oid); 269 oid, sizeof_oid);
269} 270}
270 271
271 272
@@ -297,7 +298,7 @@ MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl)
297 298
298 result = 299 result =
299 MHD__gnutls_x509_read_value (crl->crl, "signatureAlgorithm.algorithm", 300 MHD__gnutls_x509_read_value (crl->crl, "signatureAlgorithm.algorithm",
300 &sa, 0); 301 &sa, 0);
301 302
302 if (result < 0) 303 if (result < 0)
303 { 304 {
@@ -324,7 +325,7 @@ MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl)
324 **/ 325 **/
325int 326int
326MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl, 327MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl,
327 char *sig, size_t * sizeof_sig) 328 char *sig, size_t * sizeof_sig)
328{ 329{
329 int result; 330 int result;
330 int bits, len; 331 int bits, len;
@@ -391,7 +392,7 @@ MHD_gnutls_x509_crl_get_version (MHD_gnutls_x509_crl_t crl)
391 len = sizeof (version); 392 len = sizeof (version);
392 if ((result = 393 if ((result =
393 MHD__asn1_read_value (crl->crl, "tbsCertList.version", version, 394 MHD__asn1_read_value (crl->crl, "tbsCertList.version", version,
394 &len)) != ASN1_SUCCESS) 395 &len)) != ASN1_SUCCESS)
395 { 396 {
396 MHD_gnutls_assert (); 397 MHD_gnutls_assert ();
397 return MHD_gtls_asn2err (result); 398 return MHD_gtls_asn2err (result);
@@ -468,7 +469,7 @@ MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl)
468 469
469 result = 470 result =
470 MHD__asn1_number_of_elements (crl->crl, 471 MHD__asn1_number_of_elements (crl->crl,
471 "tbsCertList.revokedCertificates", &count); 472 "tbsCertList.revokedCertificates", &count);
472 473
473 if (result != ASN1_SUCCESS) 474 if (result != ASN1_SUCCESS)
474 { 475 {
@@ -495,8 +496,8 @@ MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl)
495 **/ 496 **/
496int 497int
497MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx, 498MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx,
498 unsigned char *serial, 499 unsigned char *serial,
499 size_t * serial_size, time_t * t) 500 size_t * serial_size, time_t * t)
500{ 501{
501 502
502 int result, _serial_size; 503 int result, _serial_size;
@@ -515,7 +516,8 @@ MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx,
515 "tbsCertList.revokedCertificates.?%u.revocationDate", indx + 1); 516 "tbsCertList.revokedCertificates.?%u.revocationDate", indx + 1);
516 517
517 _serial_size = *serial_size; 518 _serial_size = *serial_size;
518 result = MHD__asn1_read_value (crl->crl, serial_name, serial, &_serial_size); 519 result =
520 MHD__asn1_read_value (crl->crl, serial_name, serial, &_serial_size);
519 521
520 *serial_size = _serial_size; 522 *serial_size = _serial_size;
521 if (result != ASN1_SUCCESS) 523 if (result != ASN1_SUCCESS)
@@ -547,7 +549,7 @@ MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx,
547 -*/ 549 -*/
548int 550int
549MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, 551MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
550 MHD_gnutls_datum_t * dn) 552 MHD_gnutls_datum_t * dn)
551{ 553{
552 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 554 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
553 int result, len1; 555 int result, len1;
@@ -564,14 +566,15 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
564 */ 566 */
565 if ((result = 567 if ((result =
566 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertList", 568 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertList",
567 &c2)) != ASN1_SUCCESS) 569 &c2)) != ASN1_SUCCESS)
568 { 570 {
569 MHD_gnutls_assert (); 571 MHD_gnutls_assert ();
570 return MHD_gtls_asn2err (result); 572 return MHD_gtls_asn2err (result);
571 } 573 }
572 574
573 result = 575 result =
574 MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data); 576 MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList",
577 &crl_signed_data);
575 if (result < 0) 578 if (result < 0)
576 { 579 {
577 MHD_gnutls_assert (); 580 MHD_gnutls_assert ();
@@ -579,7 +582,8 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
579 } 582 }
580 583
581 result = 584 result =
582 MHD__asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size, NULL); 585 MHD__asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size,
586 NULL);
583 if (result != ASN1_SUCCESS) 587 if (result != ASN1_SUCCESS)
584 { 588 {
585 /* couldn't decode DER */ 589 /* couldn't decode DER */
@@ -591,8 +595,8 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
591 595
592 result = 596 result =
593 MHD__asn1_der_decoding_startEnd (c2, crl_signed_data.data, 597 MHD__asn1_der_decoding_startEnd (c2, crl_signed_data.data,
594 crl_signed_data.size, "issuer", 598 crl_signed_data.size, "issuer",
595 &start1, &end1); 599 &start1, &end1);
596 600
597 if (result != ASN1_SUCCESS) 601 if (result != ASN1_SUCCESS)
598 { 602 {
@@ -633,8 +637,8 @@ cleanup:
633 **/ 637 **/
634int 638int
635MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, 639MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
636 MHD_gnutls_x509_crt_fmt_t format, void *output_data, 640 MHD_gnutls_x509_crt_fmt_t format,
637 size_t * output_data_size) 641 void *output_data, size_t * output_data_size)
638{ 642{
639 if (crl == NULL) 643 if (crl == NULL)
640 { 644 {
@@ -643,7 +647,7 @@ MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
643 } 647 }
644 648
645 return MHD__gnutls_x509_export_int (crl->crl, format, PEM_CRL, 649 return MHD__gnutls_x509_export_int (crl->crl, format, PEM_CRL,
646 output_data, output_data_size); 650 output_data, output_data_size);
647} 651}
648 652
649/*- 653/*-
@@ -657,14 +661,16 @@ MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
657 * 661 *
658 -*/ 662 -*/
659int 663int
660MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, MHD_gnutls_x509_crl_t src) 664MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest,
665 MHD_gnutls_x509_crl_t src)
661{ 666{
662 int ret; 667 int ret;
663 size_t der_size; 668 size_t der_size;
664 opaque *der; 669 opaque *der;
665 MHD_gnutls_datum_t tmp; 670 MHD_gnutls_datum_t tmp;
666 671
667 ret = MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size); 672 ret =
673 MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size);
668 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) 674 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
669 { 675 {
670 MHD_gnutls_assert (); 676 MHD_gnutls_assert ();