]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: included unit test for gnutls_pkcs11_obj_export
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 13 Mar 2017 08:28:25 +0000 (09:28 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 13 Mar 2017 16:31:22 +0000 (17:31 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
tests/pkcs11/pkcs11-obj-import.c

index 560820b97ac1b6718d30a009fce7cd280d376147..1f60b08bb62fcb7947c8b415583c6cfbb2470a56 100644 (file)
@@ -66,7 +66,7 @@ int pin_func(void* userdata, int attempt, const char* url, const char *label,
 
 void doit(void)
 {
-       char buf[128];
+       static char buf[1024];
        int ret;
        const char *lib, *bin;
        gnutls_x509_crt_t crt;
@@ -170,6 +170,16 @@ void doit(void)
        assert(tmp2.size == tmp.size);
        assert(memcmp(tmp.data, tmp2.data, tmp.size) == 0);
        gnutls_free(tmp2.data);
+
+       /* check gnutls_pkcs11_obj_export */
+       buf_size = 4;
+       assert(gnutls_pkcs11_obj_export(obj, buf, &buf_size) == GNUTLS_E_SHORT_MEMORY_BUFFER);
+
+       buf_size = sizeof(buf);
+       assert(gnutls_pkcs11_obj_export(obj, buf, &buf_size)>=0);
+       assert(buf_size == tmp.size);
+       assert(memcmp(buf, tmp.data, tmp.size) == 0);
+
        gnutls_free(tmp.data);
 
        /* The ID is constant and copied from the certificate */