refactor: Reduce number of SanityChecks return values

This commit is contained in:
Ryan Ofsky committed 2022-07-19 16:54:52 -04:00
1 parent b3e7de7ee6
commit 6db6552377
3 files changed
+10 -26

No files matched your search

+5 -4
View File
@@ -7,21 +7,22 @@
#include <key.h>
#include <random.h>
#include <util/time.h>
#include <util/translation.h>
namespace kernel {
std::optional<SanityCheckError> SanityChecks(const Context&)
std::optional<bilingual_str> SanityChecks(const Context&)
{
if (!ECC_InitSanityCheck()) {
return SanityCheckError::ERROR_ECC;
return Untranslated("Elliptic curve cryptography sanity check failure. Aborting.");
}
if (!Random_SanityCheck()) {
return SanityCheckError::ERROR_RANDOM;
return Untranslated("OS cryptographic RNG sanity check failure. Aborting.");
}
if (!ChronoSanityCheck()) {
return SanityCheckError::ERROR_CHRONO;
return Untranslated("Clock epoch mismatch. Aborting.");
}
return std::nullopt;
+3 -7
View File
@@ -7,20 +7,16 @@
#include <optional>
struct bilingual_str;
namespace kernel {
struct Context;
enum class SanityCheckError {
ERROR_ECC,
ERROR_RANDOM,
ERROR_CHRONO,
};
/**
* Ensure a usable environment with all necessary library support.
*/
std::optional<SanityCheckError> SanityChecks(const Context&);
std::optional<bilingual_str> SanityChecks(const Context&);
}