Skip to content

Commit 1bd0ed8

Browse files
committed
Use apr function for random bytes
The apr function is thread safe while the OpenSSL one depdns on setting up custom locking, which is hard in a library.
1 parent d11c2c9 commit 1bd0ed8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/crypto.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ apr_status_t SEAL_KEY_CREATE(apr_pool_t *p, struct seal_key **skey,
5757
memcpy(n->ekey, keys->value, keylen);
5858
memcpy(n->hkey, keys->value + keylen, keylen);
5959
} else {
60-
ret = RAND_bytes(n->ekey, keylen);
60+
ret = apr_generate_random_bytes(n->ekey, keylen);
6161
if (ret == 0) {
6262
ret = EFAULT;
6363
goto done;
6464
}
6565

66-
ret = RAND_bytes(n->hkey, keylen);
66+
ret = apr_generate_random_bytes(n->hkey, keylen);
6767
if (ret == 0) {
6868
ret = EFAULT;
6969
goto done;
@@ -98,7 +98,7 @@ apr_status_t SEAL_BUFFER(apr_pool_t *p, struct seal_key *skey,
9898

9999
/* confounder to avoid exposing random numbers directly to clients
100100
* as IVs */
101-
ret = RAND_bytes(rbuf, sizeof(rbuf));
101+
ret = apr_generate_random_bytes(rbuf, sizeof(rbuf));
102102
if (ret == 0) goto done;
103103

104104
if (cipher->length == 0) {

0 commit comments

Comments
 (0)