aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/x509/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/x509/common.c')
-rw-r--r--src/daemon/https/x509/common.c105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/daemon/https/x509/common.c b/src/daemon/https/x509/common.c
index 9134597e..dd442564 100644
--- a/src/daemon/https/x509/common.c
+++ b/src/daemon/https/x509/common.c
@@ -446,108 +446,3 @@ MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src,
446 return algo; 446 return algo;
447} 447}
448 448
449/* Reads the DER signed data from the certificate and allocates space and
450 * returns them into signed_data.
451 */
452int
453MHD__gnutls_x509_get_signed_data (ASN1_TYPE src,
454 const char *src_name,
455 MHD_gnutls_datum_t * signed_data)
456{
457 MHD_gnutls_datum_t der;
458 int start, end, result;
459
460 result = MHD__gnutls_x509_der_encode (src, "", &der, 0);
461 if (result < 0)
462 {
463 MHD_gnutls_assert ();
464 return result;
465 }
466
467 /* Get the signed data
468 */
469 result = MHD__asn1_der_decoding_startEnd (src, der.data, der.size, src_name,
470 &start, &end);
471 if (result != ASN1_SUCCESS)
472 {
473 result = MHD_gtls_asn2err (result);
474 MHD_gnutls_assert ();
475 goto cleanup;
476 }
477
478 result =
479 MHD__gnutls_set_datum (signed_data, &der.data[start], end - start + 1);
480
481 if (result < 0)
482 {
483 MHD_gnutls_assert ();
484 goto cleanup;
485 }
486
487 result = 0;
488
489cleanup:MHD__gnutls_free_datum (&der);
490
491 return result;
492}
493
494/* Reads the DER signature from the certificate and allocates space and
495 * returns them into signed_data.
496 */
497int
498MHD__gnutls_x509_get_signature (ASN1_TYPE src,
499 const char *src_name,
500 MHD_gnutls_datum_t * signature)
501{
502 int bits, result, len;
503
504 signature->data = NULL;
505 signature->size = 0;
506
507 /* Read the signature
508 */
509 bits = 0;
510 result = MHD__asn1_read_value (src, src_name, NULL, &bits);
511
512 if (result != ASN1_MEM_ERROR)
513 {
514 result = MHD_gtls_asn2err (result);
515 MHD_gnutls_assert ();
516 goto cleanup;
517 }
518
519 if (bits % 8 != 0)
520 {
521 MHD_gnutls_assert ();
522 result = GNUTLS_E_CERTIFICATE_ERROR;
523 goto cleanup;
524 }
525
526 len = bits / 8;
527
528 signature->data = MHD_gnutls_malloc (len);
529 if (signature->data == NULL)
530 {
531 MHD_gnutls_assert ();
532 result = GNUTLS_E_MEMORY_ERROR;
533 return result;
534 }
535
536 /* read the bit string of the signature
537 */
538 bits = len;
539 result = MHD__asn1_read_value (src, src_name, signature->data, &bits);
540
541 if (result != ASN1_SUCCESS)
542 {
543 result = MHD_gtls_asn2err (result);
544 MHD_gnutls_assert ();
545 goto cleanup;
546 }
547
548 signature->size = len;
549
550 return 0;
551
552cleanup:return result;
553}