Hi Vitaly, On Sun, 2021-08-22 at 03:10 +0300, Vitaly Chikunov wrote: > After CRYPTO_secure_malloc_init OpenSSL will store private keys ^and passwords > in > secure heap. This facility is only available since OpenSSL_1_1_0-pre1. > > Signed-off-by: Vitaly Chikunov <vt@xxxxxxxxxxxx> Initially we started out discussing ways of protecting passwords, which this patch does. Thank you! I'm not sure, however, it is protecting the private keys. Does read_priv_pkey() also use the secure heap or is PEM_read_PrivateKey() already safe? > --- > src/evmctl.c | 148 +++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 121 insertions(+), 27 deletions(-) > > diff --git a/src/evmctl.c b/src/evmctl.c > > @@ -188,7 +207,9 @@ static int bin2file(const char *file, const char *ext, const unsigned char *data > return err; > } > > -static unsigned char *file2bin(const char *file, const char *ext, int *size) > +/* Return data in OpenSSL secure heap if 'secure' is true. */ > +static unsigned char *file2bin(const char *file, const char *ext, int *size, > + int secure) > { The only caller of file2bin() that sets "secure" is evm_calc_hmac(), but evm_calc_hmac() is a debugging tool, not meant for setting the real security.evm xattr. The kernel EVM HMAC key is an "encrypted" key type, which should be based on a "trusted" key. Neither of which are exposed to userspace unencrypted. Enabling DEBUG by default was suppose to be temporary. At this point, should it be disabled? As evm_calc_hmac() is only meant for debugging, do we really care whether evm_calc_hmac() uses a secure heap or stack for private keys or passwords? thanks, Mimi > FILE *fp; > size_t len;