Passwordfile library: util/openssl.h Source File

Passwordfile library 5.2.1 C++ library to read/write passwords from/to encrypted files

Loading...
Searching...
No Matches
openssl.h
Go to the documentation of this file.
1#ifndef PASSWORD_FILE_UTIL_OPENSSL_H
2#define PASSWORD_FILE_UTIL_OPENSSL_H
3
4#include "../global.h"
5
6#include <c++utilities/chrono/timespan.h>
7
8#include <cstddef>
9#include <cstdint>
10#include <string>
11#include <string_view>
12
13 namespace CppUtilities {
14class DateTime;
15}
16
17 namespace Util {
18
19 namespace OpenSsl {
20
21 struct Sha256Sum {
22 static constexpr std::size_t size = 32;
23 unsigned char data[size] = { 0 };
24};
25
26 struct TOTP {
27 std::string digits;
28 CppUtilities::TimeSpan period;
29 CppUtilities::TimeSpan remaining;
30};
31
32 PASSWORD_FILE_EXPORT void init();
33 PASSWORD_FILE_EXPORT void clean();
34 PASSWORD_FILE_EXPORT Sha256Sum computeSha256Sum(const unsigned char *buffer, std::size_t size);
35 PASSWORD_FILE_EXPORT Sha256Sum computeHmacSha256(const unsigned char *key, std::size_t keySize, const unsigned char *data, std::size_t dataSize);
36 PASSWORD_FILE_EXPORT std::uint32_t generateRandomNumber(std::uint32_t min, std::uint32_t max);
37 PASSWORD_FILE_EXPORT TOTP computeTOTP(std::string_view url, CppUtilities::DateTime time);
38
39} // namespace OpenSsl
40} // namespace Util
41
42#endif // PASSWORD_FILE_UTIL_OPENSSL_H
global.h
PASSWORD_FILE_EXPORT
#define PASSWORD_FILE_EXPORT
Marks the symbol to be exported by the passwordfile library.
Definition global.h:14
CppUtilities
Definition openssl.h:13
Util::OpenSsl
Contains functions utilizing the usage of OpenSSL.
Definition openssl.h:19
Util::OpenSsl::generateRandomNumber
PASSWORD_FILE_EXPORT std::uint32_t generateRandomNumber(std::uint32_t min, std::uint32_t max)
Generates a random number using OpenSSL.
Definition openssl.cpp:184
Util::OpenSsl::init
PASSWORD_FILE_EXPORT void init()
Initializes OpenSSL.
Definition openssl.cpp:120
Util::OpenSsl::clean
PASSWORD_FILE_EXPORT void clean()
Cleans resources of OpenSSL.
Definition openssl.cpp:142
Util::OpenSsl::computeHmacSha256
PASSWORD_FILE_EXPORT Sha256Sum computeHmacSha256(const unsigned char *key, std::size_t keySize, const unsigned char *data, std::size_t dataSize)
Computes an HMAC-SHA256 using OpenSSL.
Definition openssl.cpp:171
Util::OpenSsl::computeTOTP
PASSWORD_FILE_EXPORT TOTP computeTOTP(std::string_view url, CppUtilities::DateTime time)
Compute a token following the TOTP standard (RFC 6238).
Definition openssl.cpp:208
Util::OpenSsl::computeSha256Sum
PASSWORD_FILE_EXPORT Sha256Sum computeSha256Sum(const unsigned char *buffer, std::size_t size)
Computes a SHA-256 sum using OpenSSL.
Definition openssl.cpp:161
Util
Contains utility classes and functions.
Definition openssl.h:17
Util::OpenSsl::Sha256Sum
Definition openssl.h:21
Util::OpenSsl::Sha256Sum::size
static constexpr std::size_t size
Definition openssl.h:22
Util::OpenSsl::Sha256Sum::data
unsigned char data[size]
Definition openssl.h:23
Util::OpenSsl::TOTP
Definition openssl.h:26
Util::OpenSsl::TOTP::remaining
CppUtilities::TimeSpan remaining
Definition openssl.h:29
Util::OpenSsl::TOTP::digits
std::string digits
Definition openssl.h:27
Util::OpenSsl::TOTP::period
CppUtilities::TimeSpan period
Definition openssl.h:28