summaryrefslogtreecommitdiff
path: root/fips140.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-08-17 23:55:39 -0400
committerGitHub <noreply@github.com>2018-08-17 23:55:39 -0400
commitf2171cbe2f498e05298f80ee671b011302e73c28 (patch)
treee7facf7f3bb39cea81d707956cdccdcefb047028 /fips140.cpp
parent522da15b13ab11613d9c7d7beae42b3d91a90596 (diff)
downloadcryptopp-git-f2171cbe2f498e05298f80ee671b011302e73c28.tar.gz
Remove Thread and Socket classes (GH #208, PR #703)
Also see https://groups.google.com/forum/#!topic/cryptopp-users/5btwLoxXXD4.
Diffstat (limited to 'fips140.cpp')
-rw-r--r--fips140.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/fips140.cpp b/fips140.cpp
index f95f4005..1f911fc5 100644
--- a/fips140.cpp
+++ b/fips140.cpp
@@ -6,7 +6,6 @@
#include "fips140.h"
#include "misc.h"
-#include "trdlocal.h" // needs to be included last for cygwin
NAMESPACE_BEGIN(CryptoPP)
@@ -16,10 +15,6 @@ NAMESPACE_BEGIN(CryptoPP)
#define CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 0
#endif
-#if (CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 && !defined(THREADS_AVAILABLE))
-#error FIPS 140-2 compliance requires the availability of thread local storage.
-#endif
-
#if (CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 && !defined(OS_RNG_AVAILABLE))
#error FIPS 140-2 compliance requires the availability of OS provided RNG.
#endif
@@ -41,29 +36,24 @@ PowerUpSelfTestStatus CRYPTOPP_API GetPowerUpSelfTestStatus()
return g_powerUpSelfTestStatus;
}
-#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2
-ThreadLocalStorage & AccessPowerUpSelfTestInProgress()
-{
- static ThreadLocalStorage selfTestInProgress;
- return selfTestInProgress;
-}
-#endif
+// One variable for all threads for compatibility. Previously this
+// was a ThreadLocalStorage variable, which is per-thread. Also see
+// https://github.com/weidai11/cryptopp/issues/208
+static bool s_inProgress = false;
bool PowerUpSelfTestInProgressOnThisThread()
{
#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2
- return AccessPowerUpSelfTestInProgress().GetValue() != NULLPTR;
-#else
- CRYPTOPP_ASSERT(false); // should not be called
- return false;
+ return s_inProgress;
#endif
+ return false;
}
void SetPowerUpSelfTestInProgressOnThisThread(bool inProgress)
{
CRYPTOPP_UNUSED(inProgress);
#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2
- AccessPowerUpSelfTestInProgress().SetValue((void *)inProgress);
+ s_inProgress = inProgress;
#endif
}