summaryrefslogtreecommitdiff
path: root/src/pkcs11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkcs11.c')
-rw-r--r--src/pkcs11.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pkcs11.c b/src/pkcs11.c
index 5290f63833..5b206ac1f5 100644
--- a/src/pkcs11.c
+++ b/src/pkcs11.c
@@ -812,3 +812,33 @@ pkcs11_mechanism_list (FILE * outfile, const char *url, unsigned int login,
return;
}
+
+void
+pkcs11_get_random (FILE * outfile, const char *url, unsigned bytes, common_info_st * info)
+{
+ int ret;
+ uint8_t* output;
+
+ pkcs11_common ();
+
+ if (url == NULL)
+ url = "pkcs11:";
+
+ output = malloc(bytes);
+ if (output == NULL)
+ {
+ fprintf(stderr, "Memory error\n");
+ exit(1);
+ }
+
+ ret = gnutls_pkcs11_token_get_random (url, output, bytes);
+ if (ret < 0)
+ {
+ fprintf(stderr, "gnutls_pkcs11_token_get_random: %s\n", gnutls_strerror(ret));
+ exit(1);
+ }
+
+ fwrite(output, 1, bytes, outfile);
+
+ return;
+}