Skip to content
Snippets Groups Projects
Verified Commit d59fceb5 authored by Daniel Lyubomirov's avatar Daniel Lyubomirov
Browse files

[17] Crypto configuration tuning

parent 2a1b80f6
No related branches found
No related tags found
1 merge request!97Crypto Storage and LoginWithNewDevice and LoginWithPreviouslyAddedDevice APIs
#include "vereign/crypto/rand.hh"
#include "vereign/kvstore/sqlite_storage.hh" #include "vereign/kvstore/sqlite_storage.hh"
#include <boost/core/ignore_unused.hpp> #include <boost/core/ignore_unused.hpp>
#include <iostream> #include <iostream>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <openssl/digest.h>
#include <openssl/evp.h>
#include <vereign/core/string.hh> #include <vereign/core/string.hh>
#include <vereign/bytes/view.hh> #include <vereign/bytes/view.hh>
...@@ -17,13 +20,5 @@ auto main(int argc, char** argv) -> int { ...@@ -17,13 +20,5 @@ auto main(int argc, char** argv) -> int {
boost::ignore_unused(argc); boost::ignore_unused(argc);
boost::ignore_unused(argv); boost::ignore_unused(argv);
auto dir = fs::TempDir("trtr_");
auto rm = fs::RemoveAllGuard{dir};
std::cout << dir << std::endl;
std::ofstream f{fs::path::Join(dir, "hello")};
f << "ops";
f.close();
return 0; return 0;
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace { namespace {
// FIXME: should these be injected and provided by the integrator // FIXME: should these be injected and provided by the integrator
constexpr int tagSizeBytes = 64; constexpr int tagSizeBytes = 16;
constexpr int lockRetryCount = 10; constexpr int lockRetryCount = 10;
constexpr auto lockRetrySleep = std::chrono::milliseconds{1000}; constexpr auto lockRetrySleep = std::chrono::milliseconds{1000};
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace { namespace {
// FIXME: should these be injected and provided by the integrator // FIXME: should these be injected and provided by the integrator
constexpr int iterations = 1 << 18; constexpr int iterations = 1 << 18;
constexpr int saltSizeBytes = 64; constexpr int saltSizeBytes = 16;
constexpr int aesKeySizeBytes = 32; constexpr int aesKeySizeBytes = 32;
constexpr int lockRetryCount = 10; constexpr int lockRetryCount = 10;
...@@ -44,12 +44,13 @@ void CryptoStorageImpl::Open(const std::string& pin) { ...@@ -44,12 +44,13 @@ void CryptoStorageImpl::Open(const std::string& pin) {
bytes::Buffer key{aesKeySizeBytes}; bytes::Buffer key{aesKeySizeBytes};
int result = PKCS5_PBKDF2_HMAC_SHA1( int result = PKCS5_PBKDF2_HMAC(
pin.data(), pin.data(),
pin.length(), pin.length(),
salt.View().Data(), salt.View().Data(),
salt.View().Size(), salt.View().Size(),
iterations, iterations,
EVP_sha256(),
key.FreeCap(), key.FreeCap(),
key.end() key.end()
); );
...@@ -70,12 +71,13 @@ void CryptoStorageImpl::Reset(const std::string& pin) { ...@@ -70,12 +71,13 @@ void CryptoStorageImpl::Reset(const std::string& pin) {
bytes::Buffer key{aesKeySizeBytes}; bytes::Buffer key{aesKeySizeBytes};
int result = PKCS5_PBKDF2_HMAC_SHA1( int result = PKCS5_PBKDF2_HMAC(
pin.data(), pin.data(),
pin.length(), pin.length(),
salt.View().Data(), salt.View().Data(),
salt.View().Size(), salt.View().Size(),
iterations, iterations,
EVP_sha256(),
key.FreeCap(), key.FreeCap(),
key.end() key.end()
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment