diff options
Diffstat (limited to 'crypto/apr_crypto.c')
-rw-r--r-- | crypto/apr_crypto.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/crypto/apr_crypto.c b/crypto/apr_crypto.c index 2352c703..2ca391a0 100644 --- a/crypto/apr_crypto.c +++ b/crypto/apr_crypto.c @@ -62,6 +62,11 @@ APR_TYPEDEF_STRUCT(apr_crypto_block_t, const apr_crypto_t *f; ) +typedef struct apr_crypto_clear_t { + void *buffer; + apr_size_t size; +} apr_crypto_clear_t; + #if !APU_DSO_BUILD #define DRIVER_LOAD(name,driver,pool,params) \ { \ @@ -124,6 +129,31 @@ APU_DECLARE(apr_status_t) apr_crypto_init(apr_pool_t *pool) return ret; } +static apr_status_t crypto_clear(void *ptr) +{ + apr_crypto_clear_t *clear = (apr_crypto_clear_t *)ptr; + + memset(clear->buffer, 0, clear->size); + clear->buffer = NULL; + clear->size = 0; + + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_crypto_clear(apr_pool_t *pool, + void *buffer, apr_size_t size) +{ + apr_crypto_clear_t *clear = apr_palloc(pool, sizeof(apr_crypto_clear_t)); + + clear->buffer = buffer; + clear->size = size; + + apr_pool_cleanup_register(pool, clear, crypto_clear, + apr_pool_cleanup_null); + + return APR_SUCCESS; +} + APU_DECLARE(apr_status_t) apr_crypto_get_driver( const apr_crypto_driver_t **driver, const char *name, const char *params, const apu_err_t **result, apr_pool_t *pool) |