forked from softhsm/SoftHSMv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebase OpenSSL FIPS stuff (todo: static, win32 and redhat)
- Loading branch information
Showing
33 changed files
with
435 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# FIPS 140-2 | ||
|
||
The OpenSSL crypto backend can be a FIPS 140-2 capable library, | ||
cf. the OpenSSL FIPS 140 documents SecurityPolicy and UserGuide. | ||
|
||
## Introduction | ||
|
||
Please read the OpenSSL FIPS 140 documents about to get | ||
a FIPS Capable OpenSSL library. | ||
|
||
## Hard points | ||
|
||
Reread the OpenSSL FIPS 140 documents as they are hard to apply. | ||
|
||
Note the following is for Unix/Linux. | ||
|
||
Now I suppose you have a >= 1.0.1e capable static library (a | ||
dynamic library is far easier but always possible and often | ||
dubious from a security point of view... BTW if you have built | ||
a FIPS Capable OpenSSL library you should not be afraid of | ||
extra complexity :-). | ||
|
||
Do not forget to compile OpenSSL with position indepent code | ||
(aka PIC) as the libsofthsm.so requires it. The FIPS module | ||
canister is already compiled this way. | ||
|
||
A usual issue is the C++ compiler not compiling .c files as C code. | ||
A simple test can show this, put in foo.c file this code: | ||
|
||
foo() { char *x = "ab"; } | ||
|
||
and compile with the C and C++ compilers with all warnings: | ||
the C++ compiler should raise an extra warning or error about | ||
the no type for foo() and/or for the char* string constant. | ||
|
||
When this raises some errors in the fispld script, you have to | ||
insert '-x c' and '-x none' before and after each .c file | ||
in the C++ commands, for instance using this wrapper: | ||
|
||
-------------------------------- cut here -------------------------------- | ||
#!/bin/sh | ||
|
||
commands="g++" | ||
|
||
for elem in $@ | ||
do | ||
case $elem in | ||
*.c) commands+=" -x c $elem -x none";; | ||
*) commands+=" $elem";; | ||
esac | ||
done | ||
|
||
exec $commands | ||
-------------------------------- end -------------------------------- | ||
|
||
In any cases you have to set CC and CXX to fipsld. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
AC_DEFUN([ACX_OPENSSL_FIPS],[ | ||
AC_MSG_CHECKING(for OpenSSL FIPS capable library) | ||
tmp_CPPFLAGS=$CPPFLAGS | ||
tmp_LIBS=$LIBS | ||
CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES" | ||
LIBS="$LIBS $CRYPTO_LIBS" | ||
# check whether we can build an application which can | ||
# "reference the OpenSSL FIPS object module" | ||
AC_LANG_PUSH([C]) | ||
AC_RUN_IFELSE([ | ||
AC_LANG_SOURCE([[ | ||
#include <openssl/crypto.h> | ||
int main() | ||
{ | ||
return !FIPS_mode_set(1); | ||
} | ||
]]) | ||
],[ | ||
AC_MSG_RESULT([Found working FIPS_mode_set()]) | ||
],[ | ||
AC_MSG_RESULT([FIPS_mode_set(1) failed]) | ||
AC_MSG_ERROR([OpenSSL library is not FIPS capable]) | ||
],[]) | ||
AC_LANG_POP([C]) | ||
# build missing fips_premain_dso tool | ||
if test "x${FIPSLD_CC}" != "x"; then | ||
THERE="`echo $CC | sed -e 's|[[^/]]*$||'`".. | ||
if test "x${FIPSLIBDIR}" != "x"; then | ||
PREMAIN_C="${FIPSLIBDIR}/fips_premain.c" | ||
elif test -f "${THERE}/fips/fips_premain.c"; then | ||
PREMAIN_C="${THERE}/fips/fips_premain.c" | ||
elif test -f "${THERE}/lib/fips_premain.c"; then | ||
PREMAIN_C="${THERE}/lib/fips_premain.c" | ||
else | ||
AC_MSG_WARN([can't find fips_premain.c]) | ||
fi | ||
$FIPSLD_CC $CPPFLAGS -DFINGERPRINT_PREMAIN_DSO_LOAD \ | ||
-o src/lib/fips_premain_dso $PREMAIN_C $LIBS | ||
fi | ||
CPPFLAGS=$tmp_CPPFLAGS | ||
LIBS=$tmp_LIBS | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.