libfilezilla
Loading...
Searching...
No Matches
Namespaces | Functions
util.hpp File Reference

Various utility functions. More...

#include "libfilezilla.hpp"
#include "time.hpp"
#include <cstdint>
Include dependency graph for util.hpp:

Go to the source code of this file.

Namespaces

namespace  fz
 The namespace used by libfilezilla.
 

Functions

void sleep (duration const &d)
 Sleep current thread for the specified duration.
 
void yield ()
 Relinquish control for a brief amount of time.
 
int64_t random_number (int64_t min, int64_t max)
 Get a secure random integer uniformly distributed in the closed interval [min, max].
 
std::vector< uint8_trandom_bytes (size_t size)
 Get random uniformly distributed bytes.
 
void random_bytes (size_t size, uint8_t *destination)
 
void random_bytes (size_t size, buffer &destination)
 
uint64_t bitscan (uint64_t v)
 Returns index of the least-significant set bit.
 
uint64_t bitscan_reverse (uint64_t v)
 Returns index of the most-significant set bit.
 
bool equal_consttime (std::basic_string_view< uint8_t > const &lhs, std::basic_string_view< uint8_t > const &rhs)
 Secure equality test in constant time.
 
template<typename First , typename Second , std::enable_if_t< sizeof(typename First::value_type)==sizeof(uint8_t) &&sizeof(typename Second::value_type)==sizeof(uint8_t)> * = nullptr>
bool equal_consttime (First const &lhs, Second const &rhs)
 
template<typename T , typename std::enable_if_t< std::is_final_v< T > > * = nullptr>
Tmove_assign_through_move_constructor (T *p, T &&op) noexcept
 Helper to move-assign guaranteeing same member destruction order as the destructor.
 
void wipe (void *p, size_t n)
 Securely wipes the memory.
 
void wipe (std::string &s)
 Securely wipes the entire storage of the container.
 
void wipe (std::vector< uint8_t > &v)
 
void wipe_unused (std::string &s)
 Securely wipes the unused space in these containers.
 
void wipe_unused (std::vector< uint8_t > &v)
 

Detailed Description

Various utility functions.