Clean up StreamCipher::Key::globalKey in crashHandler
This commit is contained in:
parent
b5ed7dcdf8
commit
8470a326a2
|
@ -29,6 +29,7 @@
|
||||||
#include "flow/Platform.actor.h"
|
#include "flow/Platform.actor.h"
|
||||||
#include "flow/Arena.h"
|
#include "flow/Arena.h"
|
||||||
|
|
||||||
|
#include "flow/StreamCipher.h"
|
||||||
#include "flow/Trace.h"
|
#include "flow/Trace.h"
|
||||||
#include "flow/Error.h"
|
#include "flow/Error.h"
|
||||||
|
|
||||||
|
@ -3237,6 +3238,8 @@ void crashHandler(int sig) {
|
||||||
|
|
||||||
bool error = (sig != SIGUSR2);
|
bool error = (sig != SIGUSR2);
|
||||||
|
|
||||||
|
StreamCipher::Key::cleanup();
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
TraceEvent(error ? SevError : SevInfo, error ? "Crash" : "ProcessTerminated")
|
TraceEvent(error ? SevError : SevInfo, error ? "Crash" : "ProcessTerminated")
|
||||||
.detail("Signal", sig)
|
.detail("Signal", sig)
|
||||||
|
|
|
@ -91,6 +91,14 @@ const StreamCipher::Key& StreamCipher::Key::getKey() {
|
||||||
return *globalKey;
|
return *globalKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StreamCipher::Key::~Key() {
|
||||||
|
memset(arr.data(), 0, arr.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamCipher::Key::cleanup() {
|
||||||
|
globalKey.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void forceLinkStreamCipherTests() {}
|
void forceLinkStreamCipherTests() {}
|
||||||
|
|
||||||
TEST_CASE("flow/StreamCipher") {
|
TEST_CASE("flow/StreamCipher") {
|
||||||
|
|
|
@ -35,12 +35,13 @@ class Key : NonCopyable {
|
||||||
std::array<unsigned char, 16> arr;
|
std::array<unsigned char, 16> arr;
|
||||||
static std::unique_ptr<Key> globalKey;
|
static std::unique_ptr<Key> globalKey;
|
||||||
struct ConstructorTag {};
|
struct ConstructorTag {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Key(ConstructorTag) {}
|
Key(ConstructorTag) {}
|
||||||
const unsigned char* data() const { return arr.data(); }
|
~Key();
|
||||||
|
unsigned char const* data() const { return arr.data(); }
|
||||||
static void initializeRandomKey();
|
static void initializeRandomKey();
|
||||||
static const Key& getKey();
|
static const Key& getKey();
|
||||||
|
static void cleanup();
|
||||||
};
|
};
|
||||||
using IV = std::array<unsigned char, 16>;
|
using IV = std::array<unsigned char, 16>;
|
||||||
void registerCipherForCleanup(EVP_CIPHER_CTX*) noexcept;
|
void registerCipherForCleanup(EVP_CIPHER_CTX*) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue