Passwordfile library: Util::OpenSsl Namespace Reference

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

Loading...
Searching...
No Matches
Classes | Functions
Util::OpenSsl Namespace Reference

Contains functions utilizing the usage of OpenSSL. More...

## Classes
struct | Sha256Sum
struct | TOTP

## Functions
PASSWORD_FILE_EXPORT void | init ()
| Initializes OpenSSL.
PASSWORD_FILE_EXPORT void | clean ()
| Cleans resources of OpenSSL.
PASSWORD_FILE_EXPORT Sha256Sum | computeSha256Sum (const unsigned char *buffer, std::size_t size)
| Computes a SHA-256 sum using OpenSSL.
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.
PASSWORD_FILE_EXPORT std::uint32_t | generateRandomNumber (std::uint32_t min, std::uint32_t max)
| Generates a random number using OpenSSL.
PASSWORD_FILE_EXPORT TOTP | computeTOTP (std::string_view url, CppUtilities::DateTime time)
| Compute a token following the TOTP standard (RFC 6238).

## Detailed Description

Contains functions utilizing the usage of OpenSSL.

## Function Documentation

## ◆ clean()

void Util::OpenSsl::clean | ( |  | ) |

Cleans resources of OpenSSL.

Definition at line 119 of file openssl.cpp.

## ◆ computeHmacSha256()

Sha256Sum Util::OpenSsl::computeHmacSha256 | ( | const unsigned char * | key,
|  | std::size_t | keySize,
|  | const unsigned char * | data,
|  | std::size_t | dataSize )

Computes an HMAC-SHA256 using OpenSSL.

Definition at line 140 of file openssl.cpp.

## ◆ computeSha256Sum()

Sha256Sum Util::OpenSsl::computeSha256Sum | ( | const unsigned char * | buffer,
|  | std::size_t | size )

Computes a SHA-256 sum using OpenSSL.

Definition at line 130 of file openssl.cpp.

## ◆ computeTOTP()

TOTP Util::OpenSsl::computeTOTP | ( | std::string_view | url,
|  | CppUtilities::DateTime | time )

Compute a token following the TOTP standard (RFC 6238).

Parameters

  url | Specifies a URL containing the secret and parameters, e.g. "otpauth://totp/some/path?secret=ABCDABCDABCDABCD&period=30&digits=6&issuer=some_issuer".
  time | Specifies the time to compute the for (UTC).

Returns
  Returns the token with as many number of digits as specified in the URL.

Exceptions

Throws a CppUtilities::ConversionException if URL parameters are invalid/missing.

- Throws an Io::CryptoException if an error occurs during cryptographic computation.

Definition at line 177 of file openssl.cpp.

## ◆ generateRandomNumber()

std::uint32_t Util::OpenSsl::generateRandomNumber | ( | std::uint32_t | min,
|  | std::uint32_t | max )

Generates a random number using OpenSSL.

Definition at line 153 of file openssl.cpp.

## ◆ init()

void Util::OpenSsl::init | ( |  | ) |

Initializes OpenSSL.

Definition at line 108 of file openssl.cpp.