diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-06-17 16:40:15 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-06-17 16:40:41 +0200 |
commit | aa68821a7e149a7a62d15a1096c079293d808e71 (patch) | |
tree | 160660c4688a62572747fa1f31c165e93be27511 /lib | |
parent | 1a901b6ca3c25125f1fb83959a208642c218b0cb (diff) | |
download | gnutls-aa68821a7e149a7a62d15a1096c079293d808e71.tar.gz |
Added gnutls_pkcs7_get_signature_count
Diffstat (limited to 'lib')
-rw-r--r-- | lib/includes/gnutls/pkcs7.h | 2 | ||||
-rw-r--r-- | lib/libgnutls.map | 1 | ||||
-rw-r--r-- | lib/x509/pkcs7.c | 30 |
3 files changed, 32 insertions, 1 deletions
diff --git a/lib/includes/gnutls/pkcs7.h b/lib/includes/gnutls/pkcs7.h index f0088953ef..fbc449f50c 100644 --- a/lib/includes/gnutls/pkcs7.h +++ b/lib/includes/gnutls/pkcs7.h @@ -54,6 +54,8 @@ int gnutls_pkcs7_export2(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format, gnutls_datum_t * out); +int gnutls_pkcs7_get_signature_count(gnutls_pkcs7_t pkcs7); + int gnutls_pkcs7_get_crt_count(gnutls_pkcs7_t pkcs7); int gnutls_pkcs7_get_crt_raw(gnutls_pkcs7_t pkcs7, int indx, void *certificate, size_t * certificate_size); diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 44b6420a4e..da956f7ce8 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1039,6 +1039,7 @@ GNUTLS_3_4 gnutls_pkcs7_get_attr; gnutls_pkcs7_print; gnutls_x509_crt_verify_data2; + gnutls_pkcs7_get_signature_count; local: *; }; diff --git a/lib/x509/pkcs7.c b/lib/x509/pkcs7.c index 3f61a80cfe..e5d6d1619a 100644 --- a/lib/x509/pkcs7.c +++ b/lib/x509/pkcs7.c @@ -405,7 +405,7 @@ gnutls_pkcs7_get_crt_raw(gnutls_pkcs7_t pkcs7, * This function will return the number of certifcates in the PKCS7 * or RFC2630 certificate set. * - * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a + * Returns: On success, a positive number is returned, otherwise a * negative error value. **/ int gnutls_pkcs7_get_crt_count(gnutls_pkcs7_t pkcs7) @@ -483,6 +483,34 @@ static time_t parse_time(gnutls_pkcs7_t pkcs7, const char *root) } /** + * gnutls_pkcs7_get_signature_count: + * @pkcs7: should contain a #gnutls_pkcs7_t type + * + * This function will return the number of signatures in the PKCS7 + * structure. + * + * Returns: On success, a positive number is returned, otherwise a + * negative error value. + * + * Since: 3.4.3 + **/ +int gnutls_pkcs7_get_signature_count(gnutls_pkcs7_t pkcs7) +{ + int ret, count; + + if (pkcs7 == NULL) + return GNUTLS_E_INVALID_REQUEST; + + ret = asn1_number_of_elements(pkcs7->signed_data, "signerInfos", &count); + if (ret != ASN1_SUCCESS) { + gnutls_assert(); + return 0; + } + + return count; +} + +/** * gnutls_pkcs7_get_signature_info: * @pkcs7: should contain a #gnutls_pkcs7_t type * @idx: the index of the signature info to check |