Use apr function for random bytes
authorSimo Sorce <simo@redhat.com>
Tue, 10 Mar 2015 16:15:50 +0000 (12:15 -0400)
committerSimo Sorce <simo@redhat.com>
Tue, 10 Mar 2015 16:23:31 +0000 (12:23 -0400)
The apr function is thread safe while the OpenSSL one depdns on setting
up custom locking, which is hard in a library.

src/crypto.c

index 78429c8..a902d63 100644 (file)
@@ -57,13 +57,13 @@ apr_status_t SEAL_KEY_CREATE(apr_pool_t *p, struct seal_key **skey,
         memcpy(n->ekey, keys->value, keylen);
         memcpy(n->hkey, keys->value + keylen, keylen);
     } else {
-        ret = RAND_bytes(n->ekey, keylen);
+        ret = apr_generate_random_bytes(n->ekey, keylen);
         if (ret == 0) {
             ret = EFAULT;
             goto done;
         }
 
-        ret = RAND_bytes(n->hkey, keylen);
+        ret = apr_generate_random_bytes(n->hkey, keylen);
         if (ret == 0) {
             ret = EFAULT;
             goto done;
@@ -98,7 +98,7 @@ apr_status_t SEAL_BUFFER(apr_pool_t *p, struct seal_key *skey,
 
     /* confounder to avoid exposing random numbers directly to clients
      * as IVs */
-    ret = RAND_bytes(rbuf, sizeof(rbuf));
+    ret = apr_generate_random_bytes(rbuf, sizeof(rbuf));
     if (ret == 0) goto done;
 
     if (cipher->length == 0) {