Kea  2.1.7-git
isc::dhcp::AuthKey Class Reference

Authentication keys. More...

#include <host.h>

Public Member Functions

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

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. More...
 

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 75 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 25 of file host.cc.

◆ 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 29 of file host.cc.

◆ 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 33 of file host.cc.

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 127 of file host.h.

References operator!=(), operator==(), and toText().

+ Here is the call graph for this function:

◆ 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 38 of file host.cc.

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

+ 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 79 of file host.cc.

Referenced by getAuthKey(), and isc::dhcp::IPv6Resrv::getType().

◆ 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 74 of file host.cc.

Referenced by getAuthKey(), and isc::dhcp::IPv6Resrv::getType().

◆ setAuthKey() [1/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 51 of file host.cc.

References isc::dhcp::AUTH_KEY_LEN.

◆ setAuthKey() [2/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 59 of file host.cc.

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

+ Here is the call graph for this function:

◆ 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 43 of file host.cc.

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

Referenced by getAuthKey(), isc::dhcp::Host::getCfgOption6(), isc::dhcp::IPv6Resrv::getType(), and isc::dhcp::Host::toText().

+ Here is the call graph for this function:

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