30 int off = context.length();
31 buf =
new char[length * 3 +
off + 2];
32 strcpy(buf, context.c_str());
33 for (
unsigned int i = 0; i < length; i++) {
44 authentication_enabled(
false)
64 yCDebug(
AUTHHMAC,
"Cannot find auth.conf file. Authentication disabled.\n");
74 yCWarning(
AUTHHMAC,
"No \"AUTH\" group found in auth.conf file. Authentication disabled.\n");
80 if (!(key.length() > 0)) {
81 yCWarning(
AUTHHMAC,
"No \"key\" found in \"AUTH\" group in auth.conf file. Authentication disabled.\n");
88 strcpy(
reinterpret_cast<char*
>(
tmp), key.c_str());
91 srand(
static_cast<unsigned>(time(
nullptr)));
93 if (!authentication_enabled) {
95 authentication_enabled =
true;
103 if (!authentication_enabled) {
162 if (!authentication_enabled) {
235 return stream->
isOk();
248 return stream->
isOk();
251bool AuthHMAC::check_hmac(
unsigned char*
mac,
unsigned char*
mac_check)
255 std::string check =
"digest check ";
257 check +=
"successful";
267void AuthHMAC::fill_nonce(
unsigned char*
nonce)
269 std::random_device
rd;
270 std::mt19937
mt(
rd());
271 std::uniform_int_distribution<int>
dist(0, 255);
272 for (
unsigned int i = 0; i <
NONCE_LEN; i++) {
void show_hmac_debug(unsigned char *hex, unsigned int length, const std::string &context)
A simple collection of objects that can be described and transmitted in a portable way.
bool isNull() const override
Checks if the object is invalid.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
A mini-server for performing network communication in the background.
A simple abstraction for a block of bytes.
static void unlock()
Call post() on a global mutual-exclusion semaphore allocated by YARP.
static void lock()
Call wait() on a global mutual-exclusion semaphore allocated by YARP.
Simple specification of the minimum functions needed from output streams.
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
virtual void write(char ch)
Write a single byte to the stream.
A class for storing options and configuration information.
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
These options are loosely based on http://wiki.icub.org/wiki/YARP_ResourceFinder.
Helper class for finding config files and other external resources.
static ResourceFinder & getResourceFinderSingleton()
Access a ResourceFinder singleton whose lifetime will match that of the YARP library.
std::string findFile(const std::string &name)
Find the full path to a file.
virtual std::string asString() const
Get string value.
bool authDest(yarp::os::InputStream *streamIn, yarp::os::OutputStream *streamOut)
bool authSource(yarp::os::InputStream *streamIn, yarp::os::OutputStream *streamOut)
#define yCInfo(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.