diff options
author | minfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68> | 2020-03-14 11:28:08 +0000 |
---|---|---|
committer | minfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68> | 2020-03-14 11:28:08 +0000 |
commit | bdafff67944e830ce186358aa7c3dfe692fc9fdf (patch) | |
tree | 6c91d01710943cf092ab5c33317ee587325664ca | |
parent | b15c266559745d823a2761c4da6f705a4825d61d (diff) | |
download | libapr-util-bdafff67944e830ce186358aa7c3dfe692fc9fdf.tar.gz |
Backport r1875186
Add APU_CRYPTO_PRNG_RECOMMENDED_DRIVER to make it easier to choose the
correct driver on a platform.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/branches/1.7.x@1875187 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | crypto/apr_crypto_prng.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/apr_crypto_prng.c b/crypto/apr_crypto_prng.c index f1de33c1..bdc4ecab 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 @@ -328,6 +333,7 @@ APU_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) { @@ -340,7 +346,7 @@ APU_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); @@ -353,6 +359,11 @@ APU_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); |