summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2020-03-14 11:24:38 +0000
committerGraham Leggett <minfrin@apache.org>2020-03-14 11:24:38 +0000
commit52dbdcd96d6ee6d45e682e5212d78a5ad7bafd94 (patch)
treee74769cea077ede026c5235e7c2e586441512fb2 /crypto
parent0d3396ba10cc9f417c81ef539a6d8a4251812aae (diff)
downloadapr-52dbdcd96d6ee6d45e682e5212d78a5ad7bafd94.tar.gz
Add APU_CRYPTO_PRNG_RECOMMENDED_DRIVER to make it easier to choose the
correct driver on a platform. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1875186 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'crypto')
-rw-r--r--crypto/apr_crypto_prng.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/apr_crypto_prng.c b/crypto/apr_crypto_prng.c
index 2e511bba7..3238e9010 100644
--- a/crypto/apr_crypto_prng.c
+++ b/crypto/apr_crypto_prng.c
@@ -54,6 +54,11 @@
#include <stdlib.h> /* for malloc() */
+#if APU_HAVE_OPENSSL
+/** Recommended prng driver for this platform */
+#define APU_CRYPTO_PRNG_RECOMMENDED_DRIVER "openssl"
+#endif
+
/* Be consistent with the .h (the seed is xor-ed with key on reseed). */
#if CPRNG_KEY_SIZE != APR_CRYPTO_PRNG_SEED_SIZE
#error apr_crypto_prng handles stream ciphers with 256bit keys only
@@ -322,6 +327,7 @@ APR_DECLARE(apr_status_t) apr_crypto_prng_create(apr_crypto_prng_t **pcprng,
else if (cprng_global && cprng_global->crypto) {
cprng->crypto = cprng_global->crypto;
}
+#ifdef APU_CRYPTO_PRNG_RECOMMENDED_DRIVER
else {
const apr_crypto_driver_t *driver = NULL;
if (!pool) {
@@ -334,7 +340,7 @@ APR_DECLARE(apr_status_t) apr_crypto_prng_create(apr_crypto_prng_t **pcprng,
return rv;
}
- rv = apr_crypto_get_driver(&driver, "openssl",
+ rv = apr_crypto_get_driver(&driver, APU_CRYPTO_PRNG_RECOMMENDED_DRIVER,
NULL, NULL, pool);
if (rv != APR_SUCCESS) {
cprng_cleanup(cprng);
@@ -347,6 +353,11 @@ APR_DECLARE(apr_status_t) apr_crypto_prng_create(apr_crypto_prng_t **pcprng,
return rv;
}
}
+#else
+ else {
+ return APR_ENOTIMPL;
+ }
+#endif
rv = cprng->crypto->provider->cprng_stream_ctx_make(&cprng->ctx,
cprng->crypto, cprng->cipher, pool);