Commit 42e197f
Initialize mechanism list before initializing OpenSSL in icainit
In libica's library constructor OpenSSL is initialized since commit
05c4e36 "Ensure OpenSSL config is loaded
before creating libica's own library context". This will also cause OpenSSL
to evaluate the OpenSSL config file and load providers configured there.
Even without this commit, it can happen when libica is in FIPS mode, that
OpenSSL gets implicitly initialized by OpenSSL usage within the FIPS power
on tests, which run as part of the library constructor.
If OpenSSL has been initialized by the application already, then the attempt
to initialize OpenSSL again by libica is a no-operation. However, if the libica
constructor is the very first to initialize OpenSSL this can cause problems.
For applications that link against libica (via -lica), the libica library
constructor is run before the applications main function, and thus it will
most likely be the very first OpenSSL initialization attempt.
If the IBMCA provider is configured in the OpenSSL config file, then it
is loaded and initialized during OpenSSL initialization triggered by the libica
constructor. During IBMCA provider initialization, it loads libica and queries
libica's mechanism list.
The problem is that this happens while we are still in the middle of the
libica library constructor, and haven't fully initialized libica.
Especially the mechanism list has not yet been set up, and thus the IBMCA
provider will get a mechanism list where all algorithms are marked as being
not supported. The IBMCA provider will thus not register any of its algorithms,
and thus can not be used subsequentially by the application.
Unfortunately OpenSSL evaluates the config file only once, and also the IBMCA
provider queries the libica mechanism list only once, so the situation will not
change for the lifetime of the calling application.
To fix this, make sure that the mechanism list is initialized before the libica
constructor initializes OpenSSL. That way, the IBMCA provider loaded due to
the OpenSL initialization attempt from within the libica library constructor
will get a valid mechanism list.
Since some mechanisms are dependent on the FIPS flag of libica, it must
evaluate the system's FIPS state before it initializes OpenSSL, but finalize
the FIPS setup (loading the FIPS provider, etc) only after OpenSSL has been
initialized. For that the fips_init() function has been split into two parts.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>1 parent 50ca5f0 commit 42e197f
3 files changed
Lines changed: 35 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | 274 | | |
276 | 275 | | |
| 276 | + | |
| 277 | + | |
277 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
281 | 287 | | |
282 | 288 | | |
283 | 289 | | |
284 | | - | |
285 | | - | |
286 | 290 | | |
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
293 | | - | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
300 | 304 | | |
301 | | - | |
| 305 | + | |
302 | 306 | | |
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
307 | | - | |
| 311 | + | |
308 | 312 | | |
309 | 313 | | |
310 | | - | |
311 | | - | |
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
| |||
124 | 134 | | |
125 | 135 | | |
126 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
127 | 149 | | |
128 | 150 | | |
129 | 151 | | |
| |||
135 | 157 | | |
136 | 158 | | |
137 | 159 | | |
138 | | - | |
| 160 | + | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
142 | 164 | | |
143 | 165 | | |
144 | 166 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 167 | | |
151 | 168 | | |
152 | 169 | | |
| |||
0 commit comments