diff options
| author | Miloslav Trmač <mitr@redhat.com> | 2010-10-21 19:21:56 +0200 |
|---|---|---|
| committer | Miloslav Trmač <mitr@redhat.com> | 2010-10-21 19:21:56 +0200 |
| commit | eeee1d64aebbf2d29b322730d1bc4bee0661a07f (patch) | |
| tree | 65d80c6801f6e5d37961664a0c5a18bdc40b0c39 /lib | |
| parent | 9a27ed0fb407c404938dadd7d3a347515729f0bb (diff) | |
| download | ncrypto-eeee1d64aebbf2d29b322730d1bc4bee0661a07f.tar.gz ncrypto-eeee1d64aebbf2d29b322730d1bc4bee0661a07f.tar.xz ncrypto-eeee1d64aebbf2d29b322730d1bc4bee0661a07f.zip | |
Add random data generation
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ncrypto_local.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ncrypto_local.c b/lib/ncrypto_local.c index 8c65789..366963a 100644 --- a/lib/ncrypto_local.c +++ b/lib/ncrypto_local.c @@ -32,6 +32,7 @@ Red Hat author: Miloslav Trmač <mitr@redhat.com> */ #include <glib.h> #include <openssl/evp.h> +#include <openssl/rand.h> #include <ncrypto/ncrypto.h> @@ -44,6 +45,16 @@ ckr_openssl (void) return CKR_GENERAL_ERROR; } + /* Random numbers */ + +CK_RV +ncr_get_random_bytes (void *dest, size_t size) +{ + /* This is not strong enough, we need cryptographically strong random + numbers! */ + return RAND_pseudo_bytes (dest, size) != 0 ? CKR_OK : ckr_openssl (); +} + /* Symmetric keys */ struct ncr_symm_key |
