summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-14 02:20:57 +0300
committerDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-14 11:05:04 +0300
commita0e5770f50462de82afaf7743a88c33414cb32dc (patch)
tree693845374a46f01468616d238ac71c4b4be919b6 /lib
parenta4978e8884cfb97af0d0f95fdaaa59c1cfa7e2d1 (diff)
downloadgnutls-a0e5770f50462de82afaf7743a88c33414cb32dc.tar.gz
pkcs7: add function to display signature information
Basically export print_pkcs7_info() in a way usable by external applications. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/gnutls/pkcs7.h4
-rw-r--r--lib/libgnutls.map1
-rw-r--r--lib/x509/pkcs7-output.c31
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/includes/gnutls/pkcs7.h b/lib/includes/gnutls/pkcs7.h
index 8a6c2034f0..58ea4aaf81 100644
--- a/lib/includes/gnutls/pkcs7.h
+++ b/lib/includes/gnutls/pkcs7.h
@@ -144,6 +144,10 @@ int gnutls_pkcs7_print(gnutls_pkcs7_t pkcs7,
gnutls_certificate_print_formats_t format,
gnutls_datum_t * out);
+int gnutls_pkcs7_print_signature_info(gnutls_pkcs7_signature_info_st * info,
+ gnutls_certificate_print_formats_t format,
+ gnutls_datum_t * out);
+
/* *INDENT-OFF* */
#ifdef __cplusplus
}
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 512e403bb6..ac6be479f1 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -1328,6 +1328,7 @@ GNUTLS_3_6_14
{
global:
gnutls_ext_get_name2;
+ gnutls_pkcs7_print_signature_info;
} GNUTLS_3_6_13;
GNUTLS_FIPS140_3_4 {
diff --git a/lib/x509/pkcs7-output.c b/lib/x509/pkcs7-output.c
index bcffbaafd5..3d686df228 100644
--- a/lib/x509/pkcs7-output.c
+++ b/lib/x509/pkcs7-output.c
@@ -185,6 +185,37 @@ static void print_pkcs7_info(gnutls_pkcs7_signature_info_st * info,
}
/**
+ * gnutls_pkcs7_print_signature_info:
+ * @info: The PKCS7 signature info struct to be printed
+ * @format: Indicate the format to use
+ * @out: Newly allocated datum with null terminated string.
+ *
+ * This function will pretty print a PKCS #7 signature info structure, suitable
+ * for display to a human.
+ *
+ * Currently the supported formats are %GNUTLS_CRT_PRINT_FULL and
+ * %GNUTLS_CRT_PRINT_COMPACT.
+ *
+ * The output @out needs to be deallocated using gnutls_free().
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ * negative error value.
+ *
+ * Since: 3.6.14
+ **/
+int gnutls_pkcs7_print_signature_info(gnutls_pkcs7_signature_info_st * info,
+ gnutls_certificate_print_formats_t format,
+ gnutls_datum_t * out)
+{
+ gnutls_buffer_st str;
+
+ _gnutls_buffer_init(&str);
+ print_pkcs7_info(info, &str, format);
+
+ return _gnutls_buffer_to_datum(&str, out, 1);
+}
+
+/**
* gnutls_pkcs7_crt_print:
* @pkcs7: The PKCS7 struct to be printed
* @format: Indicate the format to use