File tree Expand file tree Collapse file tree 5 files changed +25
-16
lines changed
Expand file tree Collapse file tree 5 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,12 @@ header='/*
147147 * variables is desired, proper accessor functions are available. This implies
148148 * that changes to the data structures in newer versions of the library are not
149149 * considered as API changes!
150+ *
151+ * \note The leancrypto library performs an automated initialization during
152+ * its startup using constructors. If your execution environment does not offer
153+ * such constructors, or the library is compiled statically, the function
154+ * `lc_init` must be called by the consuming application before any leancrypto
155+ * API is invoked.
150156 */
151157'
152158
Original file line number Diff line number Diff line change 2626extern "C" {
2727#endif
2828
29- /* Enable these declarations only if there is no automatic constructor */
30- #ifndef LC_CONSTRUCTOR_AUTOMATIC_AVAILABLE
3129void ascon_fastest_impl (void );
3230void sha256_fastest_impl (void );
3331void sha512_fastest_impl (void );
3432void sha3_fastest_impl (void );
3533void aes_fastest_impl (void );
3634void kyber_riscv_rvv_selector (void );
37- #endif /* LC_CONSTRUCTOR_AUTOMATIC_AVAILABLE */
3835
3936#ifdef __cplusplus
4037}
Original file line number Diff line number Diff line change 6969
7070#define LC_INIT_FUNCTION (ret , symbol , param ...) DSO_PUBLIC ret symbol(param)
7171
72+ #ifdef LC_STATIC
73+ #define LC_TEST_FUNC (ret , symbol , param ...) \
74+ int lc_init(unsigned int flags); \
75+ static ret __ ## symbol(param); \
76+ ret symbol(param) { lc_init(0); return __ ## symbol(argc, argv); } \
77+ static ret __ ## symbol(param)
78+ #else
7279#define LC_TEST_FUNC (ret , symbol , param ...) ret symbol(param)
80+ #endif
7381
7482#pragma GCC diagnostic pop
7583
8593 void _func(void)
8694#else /* LC_EFI */
8795
88- #define LC_CONSTRUCTOR_AUTOMATIC_AVAILABLE
89-
9096#define LC_CONSTRUCTOR (_func ) \
91- static void __attribute__((constructor)) _func(void); \
92- static void _func(void)
97+ void __attribute__((constructor)) _func(void); \
98+ void _func(void)
9399#endif /* LC_EFI */
94100
95101#endif /* LINUX_KERNEL */
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ internal_src += files([
77])
88
99src_fips += files ([
10- ' fips_integrity_check.c'
10+ ' fips_integrity_check.c' ,
11+ ' leancrypto_init.c' ,
1112])
1213
1314if get_option (' efi' ).disabled()
@@ -17,10 +18,6 @@ if get_option('efi').disabled()
1718 src_fips += files ([
1819 ' status.c'
1920 ])
20- else
21- internal_src += files ([
22- ' leancrypto_init.c' ,
23- ])
2421endif
2522
2623if get_option (' efi' ).enabled()
Original file line number Diff line number Diff line change @@ -232,6 +232,13 @@ if get_option('pkcs7_debug').enabled()
232232 add_global_arguments ([ ' -DLC_PKCS7_DEBUG' ], language : ' c' )
233233endif
234234
235+ # Whether to build the shared library alongside the static library
236+ build_shared = (get_option (' default_library' ) != ' static' and
237+ get_option (' efi' ).disabled())
238+ if (not build_shared)
239+ add_global_arguments ([ ' -DLC_STATIC' ], language : ' c' )
240+ endif
241+
235242# 64 bit time to not suffer from Y2038 problem
236243add_global_arguments ([ ' -D_TIME_BITS=64' ], language : ' c' )
237244
@@ -631,10 +638,6 @@ leancrypto_support_libs_fips = [ ]
631638# External libraries leancrypto should link to
632639leancrypto_link = [ ]
633640
634- # Whether to build the shared library alongside the static library
635- build_shared = (get_option (' default_library' ) != ' static' and
636- get_option (' efi' ).disabled())
637-
638641foreach n : subdirs
639642 subdir (n)
640643endforeach
You can’t perform that action at this time.
0 commit comments