Only run FIPS self tests when FIPS is enabled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openssl (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
The FIPS changes added in 1.0.2g-
The performance impact of running these FIPS tests on armhf (beaglebone and raspberry pi 2&3) is significant (~ 700ms). On amd64 it is measurable but far less significant (~ 10ms). On a long running process this may be insignificant, but for command line tools this is problematic. I've seen performance differences with wget, dig, nslookup, and host. I am sure there are others. The specific numbers above are from the sample code below.
The relevant initialization can be found in crypto/o_init.c:
static void init_fips_
{
char buf[2] = "0";
int fd;
/* Ensure the selftests always run */
FIPS_
/* For now, do not enforce fips mode via env var
if (getenv(
buf[0] = '1';
} else if ((fd = open(FIPS_
if ((fd = open(FIPS_
while (read(fd, buf, sizeof(buf)) < 0 && errno == EINTR) ; close(fd);
}
/* Failure reading the fips mode switch file means just not
* switching into FIPS mode. We would break too many things
* otherwise..
*/
if (buf[0] != '1') {
/* drop down to non-FIPS mode if it is not requested */
} else {
/* abort if selftest failed */
}
}
I would like to see these tests only run if /proc/sys/
1. openssl must read a 1 from /proc/sys/
2. The selftests must pass
3. The integrity check must pass
To see the performance differences you can build and time the following program:
#include <stdio.h>
#include <openssl/ssl.h>
int main() {
OpenSSL_
}
To measure the system performance without FIPS I installed 1.0.2g-1ubuntu2 from: https:/
When I run the original 1.0.2g-1ubuntu4.1 on my Raspberry Pi I see the following times:
real 0m0.690s
real 0m0.683s
real 0m0.705s
real 0m0.690s
The same system with 1.0.2g-1ubuntu4.1 modified and the call to FIPS_mode_set(1) commented out:
real 0m0.010s
real 0m0.010s
real 0m0.009s
real 0m0.012s
real 0m0.010s
The same system with 1.0.2g-1ubuntu2:
real 0m0.010s
real 0m0.009s
real 0m0.009s
real 0m0.011s
real 0m0.012s
Here is some information about my system:
$ lsb_release -rd
Description: Ubuntu 16.04 LTS
Release: 16.04
$ apt-cache policy libssl1.0.0
libssl1.0.0:
Installed: 1.0.2g-1ubuntu4.1
Candidate: 1.0.2g-1ubuntu4.1
Version table:
*** 1.0.2g-1ubuntu4.1 500
500 http://
1.
500 http://
This is a FIPS 140-2 requirement. init_library is to satisfy the FIPS 140-2, Section 4.9 requirement that power-up selftest be run when the module is powered-up. This must be done regardless of whether the module is to be run in FIPS mode or not. Reading /proc entry only indicates whether to run the module in FIPS mode.
The FIPS_mode_set(1) in init_fips_mode() called from OPENSSL_
Note: The FIPS code in openssl in Xenial is a work-in-progress and is not complete.
All effort is made to optimize the power-up selftest as mush as possible.