* Remove unused options from rublon default config * Remove safe|secure options * Allow 9 digits long passcode for passcode bypass * Change name of 'Mobile Passcode' to 'Passcode' * Do not display any prompt when user is waiting * remove unused alloca.h header * Add autopushPrompt option * Change name OTP method * Change enrolement message handling * ad static string ctor * Addded postrm script * Rename 01_rublon_ssh.conf to 01-rublon-ssh.conf * restart sshd service after rublon package instalation * Fix sshd not restarting bug on ubuntu 24.04 * disable logging from websocket-io * change package name to match old package name * Fix compilation issue when using non owning ptr * Set version to 2.0.0
49 lines
1.3 KiB
C++
Executable File
49 lines
1.3 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include <openssl/evp.h>
|
|
#include <openssl/hmac.h>
|
|
#include <openssl/sha.h>
|
|
|
|
#include <rublon/utils.hpp>
|
|
|
|
namespace rublon {
|
|
|
|
inline std::array< char, SHA256_DIGEST_LENGTH * 2 + 1 > SHA256(const char * const path) {
|
|
std::string fileContent;
|
|
readFile(path, fileContent);
|
|
|
|
std::array< char, SHA256_DIGEST_LENGTH * 2 + 1 > xRublon{};
|
|
std::array< unsigned char, SHA256_DIGEST_LENGTH + 1 > hash{};
|
|
|
|
SHA256_CTX ctx;
|
|
SHA256_Init(&ctx);
|
|
|
|
SHA256_Update(&ctx, fileContent.data(), fileContent.size());
|
|
SHA256_Final(hash.data(), &ctx);
|
|
|
|
for(unsigned int i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
|
sprintf(&xRublon[i * 2], "%02x", ( unsigned int ) hash[i]);
|
|
|
|
return xRublon;
|
|
}
|
|
|
|
// +1 for \0
|
|
inline std::array< char, 64 + 1 > signData(std::string_view data, std::string_view secretKey) {
|
|
std::array< char, 64 + 1 > xRublon;
|
|
std::array< unsigned char, EVP_MAX_MD_SIZE > md;
|
|
unsigned int md_len{};
|
|
|
|
HMAC(EVP_sha256(), secretKey.data(), secretKey.size(), ( unsigned const char * ) data.data(), data.size(), md.data(), &md_len);
|
|
|
|
for(unsigned int i = 0; i < md_len; i++)
|
|
sprintf(&xRublon[i * 2], "%02x", ( unsigned int ) md[i]);
|
|
|
|
return xRublon;
|
|
}
|
|
|
|
} // namespace rublon
|