On Thu, Aug 19, 2021 at 05:11:36AM +0300, Vitaly Chikunov wrote: > After CRYPTO_secure_malloc_init OpenSSL will store private keys in > secure heap. This facility is only available since OpenSSL_1_1_0-pre1. > > Signed-off-by: Vitaly Chikunov <vt@xxxxxxxxxxxx> > --- > Change from v1: > - Do not use setfbuf to disable buffering as this is not proven to be > meaningful. > - Use secure heap for passwords too as suggested by Mimi Zohar. > - Fallback to OPENSSL_malloc for old OpenSSL as suggested by Mimi Zohar. > - Simplify logic of calling CRYPTO_secure_malloc_init (call it always on > OpenSSL init.) > - Should be applied after Bruno Meneguele's "evmctl: fix memory leak in > get_password" patch v2. > > src/evmctl.c | 143 ++++++++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 118 insertions(+), 25 deletions(-) > > @@ -2651,6 +2721,16 @@ int main(int argc, char *argv[]) > #endif > OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); > #endif > +#if OPENSSL_VERSION_NUMBER > 0x10100000 > + /* > + * This facility is available since OpenSSL_1_1_0-pre1. > + * 'Heap size' 8192 is chosen to be big enough, so that any single key > + * data could fit. 'Heap minsize' 64 is just to be efficient for small > + * buffers. > + */ > + CRYPTO_secure_malloc_init(8192, 64); > +#endif Forgot to check return value of this. Thanks,