Kea 2.7.6
isc::dhcp::AuthKey Class Reference

Authentication keys. More...

#include <host.h>

Public Member Functions

 AuthKey ()
 Constructor.
 
 AuthKey (const std::string &key)
 Constructor.
 
 AuthKey (const std::vector< uint8_t > &key)
 Constructor.
 
const std::vector< uint8_t > & getAuthKey () const
 Return auth key.
 
bool operator!= (const AuthKey &other) const
 Inequality operator.
 
bool operator== (const AuthKey &other) const
 Equality operator.
 
void setAuthKey (const std::string &key)
 Set auth key value from hexadecimal.
 
void setAuthKey (const std::vector< uint8_t > &key)
 Set auth key value from binary.
 
std::string toText () const
 Return text format for keys.
 

Static Public Member Functions

static std::vector< uint8_t > getRandomKeyString ()
 Random string is generated by default will be used for the keys to be used for signing Reconfigure Message.
 

Detailed Description

Authentication keys.

This class represents authentication keys to be used for calculating HMAC in the authentication field of the reconfigure message.

Definition at line 76 of file host.h.

Constructor & Destructor Documentation

◆ AuthKey() [1/3]

isc::dhcp::AuthKey::AuthKey ( const std::vector< uint8_t > & key)

Constructor.

Constructor for assigning auth keys in host reservation. Ensures the key length is not greater than 16 bytes.

Parameters
keyauth key in binary to be stored.

Definition at line 28 of file host.cc.

References setAuthKey().

+ Here is the call graph for this function:

◆ AuthKey() [2/3]

isc::dhcp::AuthKey::AuthKey ( const std::string & key)

Constructor.

Constructor for assigning auth keys in host reservation. Ensures the key length is not greater than AUTH_KEY_LEN (16) bytes so TEXT_AUTH_KEY_LEN (32) hexadecimal digits. See setKey for constraints on its input format.

Parameters
keyauth key in hexadecimal to be stored.

Definition at line 32 of file host.cc.

References setAuthKey().

+ Here is the call graph for this function:

◆ AuthKey() [3/3]

isc::dhcp::AuthKey::AuthKey ( )

Constructor.

Constructor for generating auth keys, with no argument. shall use the internal function for generationg random keys.

Definition at line 36 of file host.cc.

References getRandomKeyString().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAuthKey()

const std::vector< uint8_t > & isc::dhcp::AuthKey::getAuthKey ( ) const
inline

Return auth key.

Returns
auth key in binary.

Definition at line 128 of file host.h.

◆ getRandomKeyString()

std::vector< uint8_t > isc::dhcp::AuthKey::getRandomKeyString ( )
static

Random string is generated by default will be used for the keys to be used for signing Reconfigure Message.

Returns
Random binary string of 16 bytes.

Definition at line 41 of file host.cc.

References isc::dhcp::AUTH_KEY_LEN, and isc::cryptolink::random().

Referenced by AuthKey().

+ Here is the call graph for this function:

◆ operator!=()

bool isc::dhcp::AuthKey::operator!= ( const AuthKey & other) const

Inequality operator.

inequality operator to compare two AuthKey objects.

Parameters
otherAuthkey to be compared against.

Definition at line 82 of file host.cc.

◆ operator==()

bool isc::dhcp::AuthKey::operator== ( const AuthKey & other) const

Equality operator.

equality operator to compare two AuthKey objects.

Parameters
otherAuthkey to be compared against.

Definition at line 77 of file host.cc.

◆ setAuthKey() [1/2]

void isc::dhcp::AuthKey::setAuthKey ( const std::string & key)

Set auth key value from hexadecimal.

Set the key value. If the size is greater than 16 bytes, we resize to 16 bytes.

Parameters
keyauth key in hexadecimal to be stored.
Exceptions
BadValueif the string is not a valid hexadecimal encoding, for instance has a not hexadecimal or odd number of digits.

Definition at line 62 of file host.cc.

References isc::util::encode::decodeHex(), isc_throw, and setAuthKey().

+ Here is the call graph for this function:

◆ setAuthKey() [2/2]

void isc::dhcp::AuthKey::setAuthKey ( const std::vector< uint8_t > & key)

Set auth key value from binary.

Set the key value. Doesn't throw an exception.

Parameters
keyauth key in binary to be stored

Definition at line 54 of file host.cc.

References isc::dhcp::AUTH_KEY_LEN.

Referenced by AuthKey(), AuthKey(), and setAuthKey().

◆ toText()

std::string isc::dhcp::AuthKey::toText ( ) const

Return text format for keys.

Returns
auth key as a string of hexadecimal digits.

Definition at line 46 of file host.cc.

References isc::util::encode::encodeHex().

Referenced by isc::dhcp::Host::toText().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: