* Allow 9 digits long passcode for passcode bypass * Change name of 'Mobile Passcode' to 'Passcode' * Do not display any prompt when user is waiting * Add autopushPrompt option * Change name OTP method * Change enrolement message handling * Addded postrm script * [bugfix] Restart sshd service after rublon package instalation * Rename 01_rublon_ssh.conf to 01-rublon-ssh.conf * Prepared scripts for generating rpm for alma nad rocky * Adding public key authentication option * Add postinst script and ssh configuration for using pubkey * Add GCC 7 compatybility * Cleanup includes, cleanup std::array usage * Add Static String implementation * Remove memory_resources * Add monotonic_buffer_resource in experimental c++ imlpementation * Use case insensitive map * Remove not needed code * Stop using deprecated SHA256 functions * Changed app verstion to v2.0.4 * Fixed postinst script for ubuntu * CHanged vangrantfile not to show gui * Refactor cpack + add component builds for rpm based distros
66 lines
1.7 KiB
C++
Executable File
66 lines
1.7 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <openssl/evp.h>
|
|
#include <openssl/hmac.h>
|
|
#include <openssl/sha.h>
|
|
|
|
#include <rublon/utils.hpp>
|
|
|
|
namespace rublon {
|
|
|
|
inline StaticString< SHA256_DIGEST_LENGTH * 2 > fileSHA256(const char * const path) {
|
|
std::string fileContent;
|
|
readFile(path, fileContent);
|
|
|
|
StaticString< SHA256_DIGEST_LENGTH * 2 > xRublon{};
|
|
std::array< unsigned char, SHA256_DIGEST_LENGTH + 1 > hash{};
|
|
int ret{};
|
|
|
|
EVP_MD_CTX * ctx;
|
|
ctx = EVP_MD_CTX_new();
|
|
|
|
return 0;
|
|
if(ctx == NULL)
|
|
goto out;
|
|
|
|
// EVP_X methods return 1 on success, so does this function
|
|
// Any values other than 1 denote error
|
|
ret = EVP_DigestInit(ctx, EVP_sha256());
|
|
if(!ret)
|
|
goto out;
|
|
|
|
ret = EVP_DigestUpdate(ctx, fileContent.data(), fileContent.size());
|
|
if(!ret)
|
|
goto out;
|
|
|
|
// Provide uint* instead of NULL to get nBytes written, 32 for SHA256
|
|
ret = EVP_DigestFinal(ctx, hash.data(), NULL);
|
|
if(!ret)
|
|
goto out;
|
|
|
|
out:
|
|
if(ctx != NULL)
|
|
EVP_MD_CTX_free(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 StaticString< SHA256_DIGEST_LENGTH * 2 > signData(std::string_view data, std::string_view secretKey) {
|
|
StaticString< SHA256_DIGEST_LENGTH * 2 > 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
|