ima-evm-utils: rework openssl init
PATCH v2 1/1 ima-evm-utils: rework openssl init
Remove deprecated call to OpenSSL_add_all_algorithms(). Allow to disable openssl config loading via configure `--disable-openssl-conf' option.
Finish engine initialization properly by calling ENGINE_set_default(), as suggested by James Bottomley.
---
- v1 is "ima-evm-utils: remove redundant call to OpenSSL_add_all_algorithms"
- everything is changed as suggested in mailing list, not just redundant OpenSSL_add_all_algorithms() call is removed.
configure.ac | 6 ++++++ src/evmctl.c | 1 + src/libimaevm.c | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-)
configure.ac +6 -0
@@ -39,6 +39,12 @@ AC_ARG_WITH(kernel_headers, [AS_HELP_STRING([--with-kernel-headers=PATH], [KERNEL_HEADERS="$withval"], [KERNEL_HEADERS=/lib/modules/$(uname -r)/source]) +AC_ARG_ENABLE([openssl_conf], + [AS_HELP_STRING([--disable-openssl-conf], [disable loading of openssl config by libimaevm])], + if test "$enable_openssl_conf" = "no"; then + AC_DEFINE(DISABLE_OPENSSL_CONF, 1, [Define to disable loading of openssl config by libimaevm.]) + fi) + #debug support - yes for a while PKG_ARG_ENABLE(debug, "yes", DEBUG, [Enable Debug support]) if test $pkg_cv_enable_debug = yes; then
src/evmctl.c +1 -0
@@ -1904,6 +1904,7 @@ int main(int argc, char *argv[])ENGINE_free (eng); eng =NULL ; } +ENGINE_set_default (eng,ENGINE_METHOD_ALL );break ;case 140 :/* --xattr-user */ xattr_ima ="user.ima" ;
src/libimaevm.c +6 -2
@@ -976,7 +976,11 @@ int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const cstatic void libinit () { -OpenSSL_add_all_algorithms (); -OPENSSL_add_all_algorithms_conf (); + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | + OPENSSL_INIT_ADD_ALL_DIGESTS | +#ifndef DISABLE_OPENSSL_CONF +OPENSSL_INIT_LOAD_CONFIG | +#endif + OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); ERR_load_crypto_strings(); }
Signature · 1 line
2.11.0
Mimi Zohar
maintainerQuoted 7 lines · Vitaly Chikunov
Remove deprecated call to
OpenSSL_add_all_algorithms(). Allow to disable openssl config loading via configure `--disable-openssl-conf' option.
Finish engine initialization properly by callingENGINE_set_default(), as suggested by James Bottomley.Signed-off-by Vitaly Chikunov <[email protected]>
Thanks!
Mimi
Mimi Zohar
maintainerHi Vitaly,
Quoted 6 lines · Vitaly Chikunov
Remove deprecated call to
OpenSSL_add_all_algorithms(). Allow to disable openssl config loading via configure `--disable-openssl-conf' option.
Finish engine initialization properly by callingENGINE_set_default(), as suggested by James Bottomley.
Thanks, could you also display the status under "Give some feedback".
Mimi
Quoted 58 lines
Signed-off-by Vitaly Chikunov <[email protected]>---
- v1 is "ima-evm-utils: remove redundant call toOpenSSL_add_all_algorithms"
- everything is changed as suggested in mailing list, not just redundantOpenSSL_add_all_algorithms()call is removed.configure.ac | 6 ++++++ src/evmctl.c | 1 + src/libimaevm.c | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-)configure.ac +6
-0@@ -39,6 +39,12 @@ AC_ARG_WITH(kernel_headers, [AS_HELP_STRING([--with-kernel-headers=PATH], [KERNEL_HEADERS="$withval"], [KERNEL_HEADERS=/lib/modules/$(uname -r)/source]) +AC_ARG_ENABLE([openssl_conf], + [AS_HELP_STRING([--disable-openssl-conf], [disable loading of openssl config by libimaevm])], + if test "$enable_openssl_conf" = "no"; then + AC_DEFINE(DISABLE_OPENSSL_CONF, 1, [Define to disable loading of openssl config by libimaevm.]) + fi) + #debug support - yes for a while PKG_ARG_ENABLE(debug, "yes", DEBUG, [Enable Debug support]) if test $pkg_cv_enable_debug = yes; thensrc/evmctl.c +1
-0@@ -1904,6 +1904,7 @@ int main(int argc, char *argv[])ENGINE_free (eng); eng =NULL ; } +ENGINE_set_default (eng,ENGINE_METHOD_ALL );break ;case 140 :/* --xattr-user */ xattr_ima ="user.ima" ;src/libimaevm.c +6
-2@@ -976,7 +976,11 @@ int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const cstatic void libinit () { -OpenSSL_add_all_algorithms (); -OPENSSL_add_all_algorithms_conf (); + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | + OPENSSL_INIT_ADD_ALL_DIGESTS | +#ifndef DISABLE_OPENSSL_CONF +OPENSSL_INIT_LOAD_CONFIG | +#endif + OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); ERR_load_crypto_strings(); }
Mimi,
Quoted 10 lines · Mimi Zohar
Quoted 6 lines · Vitaly Chikunov
Remove deprecated call to
OpenSSL_add_all_algorithms(). Allow to disable openssl config loading via configure `--disable-openssl-conf' option.
Finish engine initialization properly by callingENGINE_set_default(), as suggested by James Bottomley.Thanks, could you also display the status under "Give some feedback".
OK.
Quoted 62 lines
Mimi
Quoted 58 lines
Signed-off-by Vitaly Chikunov <[email protected]>---
- v1 is "ima-evm-utils: remove redundant call toOpenSSL_add_all_algorithms"
- everything is changed as suggested in mailing list, not just redundantOpenSSL_add_all_algorithms()call is removed.configure.ac | 6 ++++++ src/evmctl.c | 1 + src/libimaevm.c | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-)configure.ac +6
-0@@ -39,6 +39,12 @@ AC_ARG_WITH(kernel_headers, [AS_HELP_STRING([--with-kernel-headers=PATH], [KERNEL_HEADERS="$withval"], [KERNEL_HEADERS=/lib/modules/$(uname -r)/source]) +AC_ARG_ENABLE([openssl_conf], + [AS_HELP_STRING([--disable-openssl-conf], [disable loading of openssl config by libimaevm])], + if test "$enable_openssl_conf" = "no"; then + AC_DEFINE(DISABLE_OPENSSL_CONF, 1, [Define to disable loading of openssl config by libimaevm.]) + fi) + #debug support - yes for a while PKG_ARG_ENABLE(debug, "yes", DEBUG, [Enable Debug support]) if test $pkg_cv_enable_debug = yes; thensrc/evmctl.c +1
-0@@ -1904,6 +1904,7 @@ int main(int argc, char *argv[])ENGINE_free (eng); eng =NULL ; } +ENGINE_set_default (eng,ENGINE_METHOD_ALL );break ;case 140 :/* --xattr-user */ xattr_ima ="user.ima" ;src/libimaevm.c +6
-2@@ -976,7 +976,11 @@ int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const cstatic void libinit () { -OpenSSL_add_all_algorithms (); -OPENSSL_add_all_algorithms_conf (); + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | + OPENSSL_INIT_ADD_ALL_DIGESTS | +#ifndef DISABLE_OPENSSL_CONF +OPENSSL_INIT_LOAD_CONFIG | +#endif + OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); ERR_load_crypto_strings(); }
Mimi,
Quoted 64 lines · Vitaly Chikunov
Quoted 10 lines · Mimi Zohar
Quoted 6 lines · Vitaly Chikunov
Remove deprecated call to
OpenSSL_add_all_algorithms(). Allow to disable openssl config loading via configure `--disable-openssl-conf' option.
Finish engine initialization properly by callingENGINE_set_default(), as suggested by James Bottomley.Thanks, could you also display the status under "Give some feedback".
OK.
Quoted 50 lines
Mimi
Quoted 46 lines
Signed-off-by Vitaly Chikunov <[email protected]>---
- v1 is "ima-evm-utils: remove redundant call toOpenSSL_add_all_algorithms"
- everything is changed as suggested in mailing list, not just redundantOpenSSL_add_all_algorithms()call is removed.configure.ac | 6 ++++++ src/evmctl.c | 1 + src/libimaevm.c | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-)configure.ac +6
-0@@ -39,6 +39,12 @@ AC_ARG_WITH(kernel_headers, [AS_HELP_STRING([--with-kernel-headers=PATH], [KERNEL_HEADERS="$withval"], [KERNEL_HEADERS=/lib/modules/$(uname -r)/source]) +AC_ARG_ENABLE([openssl_conf], + [AS_HELP_STRING([--disable-openssl-conf], [disable loading of openssl config by libimaevm])], + if test "$enable_openssl_conf" = "no"; then + AC_DEFINE(DISABLE_OPENSSL_CONF, 1, [Define to disable loading of openssl config by libimaevm.]) + fi) + #debug support - yes for a while PKG_ARG_ENABLE(debug, "yes", DEBUG, [Enable Debug support]) if test $pkg_cv_enable_debug = yes; thensrc/evmctl.c +1
-0@@ -1904,6 +1904,7 @@ int main(int argc, char *argv[])ENGINE_free (eng); eng =NULL ; } +ENGINE_set_default (eng,ENGINE_METHOD_ALL );break ;case 140 :/* --xattr-user */ xattr_ima ="user.ima" ;src/libimaevm.c +0
-0@@ -976,7 +976,11 @@ int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const c
Quoted 10 lines
Quoted 10 lines
src/libimaevm.c int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const c · line 984
Quoted 10 lines
src/libimaevm.c +6
-2static void libinit () { -OpenSSL_add_all_algorithms (); -OPENSSL_add_all_algorithms_conf (); + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | + OPENSSL_INIT_ADD_ALL_DIGESTS | +#ifndef DISABLE_OPENSSL_CONF +OPENSSL_INIT_LOAD_CONFIG | +#endif + OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
I think now, that libimaevm should not load config, because it is library and that decision should be of the program that uses it.
Thus, src/libimaevm.c:libinit should only call
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);
(like OpenSSL_add_all_algorithms*() was doing) and option --disable-openssl-conf should be removed.
But, evmctl should always call OPENSSL_init_crypto() again, with OPENSSL_INIT_LOAD_CONFIG | OPENSSL_INIT_ENGINE_ALL_BUILTIN.
What do you think?
If you wish we can repurpose --disable-openssl-conf to affect evmctl instead of libimaevm.
Thanks,