diff options
| author | Miloslav Trmač <mitr@redhat.com> | 2010-12-02 16:05:58 +0100 |
|---|---|---|
| committer | Miloslav Trmač <mitr@redhat.com> | 2010-12-02 16:05:58 +0100 |
| commit | 73f2df61b947fc2a4352ec305e3783b5071078c5 (patch) | |
| tree | fa50f33194e58c6610136e330af801fa6d9d78fa /lib | |
| parent | 24c1c8a9e044cc7fe1c5c9343c0cdaaf57da9aa6 (diff) | |
| parent | 5e1bd25811ad476fee2cba5ec3ce83d20c74baf6 (diff) | |
Merge branch 'local', drop openssl helper
Conflicts:
lib/ncrypto_local.c
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ncrypto_local.c | 21 | ||||
| -rw-r--r-- | lib/ncrypto_nss.c | 19 |
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/ncrypto_local.c b/lib/ncrypto_local.c index 5a138fc..1d761cd 100644 --- a/lib/ncrypto_local.c +++ b/lib/ncrypto_local.c @@ -28,34 +28,15 @@ Red Hat author: Miloslav Trmač <mitr@redhat.com> */ #include <stdbool.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <glib.h> -#include <openssl/rand.h> #include <ncrypto/ncrypto.h> #include "internal.h" - /* Helpers */ - -static CK_RV -ckr_openssl (void) -{ - /* FIXME: better error handling? This will be replaced anyway. */ - 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 */ CK_RV diff --git a/lib/ncrypto_nss.c b/lib/ncrypto_nss.c index a430c3f..46716ea 100644 --- a/lib/ncrypto_nss.c +++ b/lib/ncrypto_nss.c @@ -114,6 +114,25 @@ ncr_close (void) return res; } + /* Random numbers */ + +CK_RV +ncr_get_random_bytes (void *dest, size_t size) +{ + CK_RV res; + + g_return_val_if_fail (dest != NULL, CKR_ARGUMENTS_BAD); + g_return_val_if_fail (size <= INT_MAX, CKR_ARGUMENTS_BAD); + + res = ensure_ncr_is_open (); + if (res != CKR_OK) + return res; + + if (PK11_GenerateRandom (dest, size) != SECSuccess) + return CKR_GENERAL_ERROR; + return CKR_OK; +} + /* Asymmetric keys */ struct ncr_public_key |
