Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
f45511f0
Commit
f45511f0
authored
Jul 02, 2019
by
Francis Dupont
Browse files
[550-authentication-key-to-text-method-miss-spelled] Addressed comments
parent
d8276f10
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/cql_host_data_source.cc
View file @
f45511f0
...
...
@@ -85,24 +85,6 @@ struct OptionWrapper {
std
::
string
option_space_
;
};
/// @brief Maximum length of classes stored in a host_ipv4/6_client_classes
/// column.
static
constexpr
size_t
CLIENT_CLASSES_MAX_LENGTH
=
255u
;
/// @brief Maximum length of the hostname stored in DNS. This length is
/// restricted by the length of the domain-name carried in the Client FQDN
/// Option (see RFC4702 and RFC4704).
static
constexpr
size_t
HOSTNAME_MAX_LENGTH
=
255u
;
/// @brief Maximum length of option value
static
constexpr
size_t
OPTION_VALUE_MAX_LENGTH
=
4096u
;
/// @brief Maximum length of option value specified in textual format
static
constexpr
size_t
OPTION_FORMATTED_VALUE_MAX_LENGTH
=
8192u
;
/// @brief Maximum length of option space name
static
constexpr
size_t
OPTION_SPACE_MAX_LENGTH
=
128u
;
/// @brief Numeric value representing the last supported identifier. This value
/// is used to validate whether the identifier type stored in a database is
/// within bounds of supported identifiers.
...
...
@@ -1377,10 +1359,10 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
// hostname: text
hostname_
=
host
->
getHostname
();
if
(
hostname_
.
size
()
>
HOSTNAME_MAX_LEN
GTH
)
{
if
(
hostname_
.
size
()
>
HOSTNAME_MAX_LEN
)
{
isc_throw
(
BadValue
,
"CqlHostExchange::prepareExchange(): hostname "
<<
hostname_
<<
" of length "
<<
hostname_
.
size
()
<<
" is greater than allowed of "
<<
HOSTNAME_MAX_LEN
GTH
);
<<
" is greater than allowed of "
<<
HOSTNAME_MAX_LEN
);
}
// user_context: text
...
...
@@ -1393,20 +1375,20 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
// host_ipv4_client_classes: text
host_ipv4_client_classes_
=
host
->
getClientClasses4
().
toText
(
","
);
if
(
host_ipv4_client_classes_
.
size
()
>
CLIENT_CLASSES_MAX_LEN
GTH
)
{
if
(
host_ipv4_client_classes_
.
size
()
>
CLIENT_CLASSES_MAX_LEN
)
{
isc_throw
(
BadValue
,
"CqlHostExchange::prepareExchange(): "
"IPv4 client classes "
<<
host_ipv4_client_classes_
<<
" of length "
<<
host_ipv4_client_classes_
.
size
()
<<
" is greater than allowed of "
<<
CLIENT_CLASSES_MAX_LEN
GTH
);
<<
CLIENT_CLASSES_MAX_LEN
);
}
// host_ipv6_client_classes: text
host_ipv6_client_classes_
=
host
->
getClientClasses6
().
toText
(
","
);
if
(
host_ipv6_client_classes_
.
size
()
>
CLIENT_CLASSES_MAX_LEN
GTH
)
{
if
(
host_ipv6_client_classes_
.
size
()
>
CLIENT_CLASSES_MAX_LEN
)
{
isc_throw
(
BadValue
,
"CqlHostExchange::prepareExchange(): "
"IPv6 client classes "
<<
host_ipv6_client_classes_
<<
" of length "
<<
host_ipv6_client_classes_
.
size
()
<<
" is greater than allowed of "
<<
CLIENT_CLASSES_MAX_LEN
GTH
);
<<
CLIENT_CLASSES_MAX_LEN
);
}
if
(
reservation
==
NULL
)
{
...
...
@@ -1613,7 +1595,7 @@ CqlHostExchange::hashIntoId() const {
key_stream
<<
std
::
setw
(
4
)
<<
std
::
setfill
(
'-'
)
<<
reserved_ipv6_prefix_length_
;
key_stream
<<
std
::
setw
(
4
)
<<
std
::
setfill
(
'-'
)
<<
option_code_
;
key_stream
<<
std
::
setw
(
OPTION_SPACE_MAX_LEN
GTH
)
<<
std
::
setfill
(
'-'
)
key_stream
<<
std
::
setw
(
OPTION_SPACE_MAX_LEN
)
<<
std
::
setfill
(
'-'
)
<<
option_space_
;
const
std
::
string
key
=
key_stream
.
str
();
...
...
src/lib/dhcpsrv/host.cc
View file @
f45511f0
...
...
@@ -36,7 +36,7 @@ AuthKey::AuthKey() {
std
::
vector
<
uint8_t
>
AuthKey
::
getRandomKeyString
()
{
return
(
isc
::
cryptolink
::
random
(
A
uthKey
::
KEY_LEN
));
return
(
isc
::
cryptolink
::
random
(
A
UTH_
KEY_LEN
));
}
std
::
string
...
...
@@ -50,8 +50,8 @@ AuthKey::toText() const {
void
AuthKey
::
setAuthKey
(
const
std
::
vector
<
uint8_t
>&
key
)
{
authKey_
=
key
;
if
(
authKey_
.
size
()
>
A
uthKey
::
KEY_LEN
)
{
authKey_
.
resize
(
A
uthKey
::
KEY_LEN
);
if
(
authKey_
.
size
()
>
A
UTH_
KEY_LEN
)
{
authKey_
.
resize
(
A
UTH_
KEY_LEN
);
}
}
...
...
@@ -59,6 +59,7 @@ void
AuthKey
::
setAuthKey
(
const
std
::
string
&
key
)
{
if
(
key
.
empty
())
{
authKey_
.
clear
();
return
;
}
try
{
std
::
vector
<
uint8_t
>
bin
;
...
...
src/lib/dhcpsrv/host.h
View file @
f45511f0
...
...
@@ -24,18 +24,55 @@
namespace
isc
{
namespace
dhcp
{
/// @brief Maximum size of an IPv6 address represented as a text string.
///
/// This is 32 hexadecimal characters written in 8 groups of four, plus seven
/// colon separators.
const
size_t
ADDRESS6_TEXT_MAX_LEN
=
39
;
/// @brief Maximum length of classes stored in a dhcp4/6_client_classes
/// columns.
const
size_t
CLIENT_CLASSES_MAX_LEN
=
255
;
/// @brief Maximum length of the hostname stored in DNS.
///
/// This length is restricted by the length of the domain-name carried
/// in the Client FQDN %Option (see RFC4702 and RFC4704).
const
size_t
HOSTNAME_MAX_LEN
=
255
;
/// @brief Maximum length of option value.
const
size_t
OPTION_VALUE_MAX_LEN
=
4096
;
/// @brief Maximum length of option value specified in textual format.
const
size_t
OPTION_FORMATTED_VALUE_MAX_LEN
=
8192
;
/// @brief Maximum length of option space name.
const
size_t
OPTION_SPACE_MAX_LEN
=
128
;
/// @brief Maximum length of user context.
const
size_t
USER_CONTEXT_MAX_LEN
=
8192
;
/// @brief Maximum length of the server hostname.
const
size_t
SERVER_HOSTNAME_MAX_LEN
=
64
;
/// @brief Maximum length of the boot file name.
const
size_t
BOOT_FILE_NAME_MAX_LEN
=
128
;
/// @brief Maximum length of authentication keys - 128 bits.
const
uint8_t
AUTH_KEY_LEN
=
16
;
/// @brief Maximum length of authentication keys (coded in hexadecimal).
const
size_t
TEXT_AUTH_KEY_LEN
=
AUTH_KEY_LEN
*
2
;
/// @brief HostID (used only when storing in MySQL, PostgreSQL or Cassandra)
typedef
uint64_t
HostID
;
/// @brief Authentication keys.
///
/// This class represents authentication keys to be used for
/// calculating HMAC in the authentication field of the recofigure message.
/// calculating HMAC in the authentication field of the reco
n
figure message.
class
AuthKey
{
public:
/// @brief Length of the key - 128 bits.
const
static
uint8_t
KEY_LEN
=
16
;
/// @brief Constructor.
///
/// Constructor for assigning auth keys in host reservation.
...
...
@@ -46,7 +83,10 @@ public:
/// @brief Constructor.
///
/// Constructor for assigning auth keys in host reservation.
/// Ensures the key length is not greater than 16 bytes.
/// Ensures the key length is not greater than AUTH_KEY_LEN (16) bytes
/// so TEXT_AUTH_KEY_LEN (32) hexadecimal digits.
/// See @c setKey for constraints on its input format.
///
/// @param key auth key in hexadecimal to be stored.
AuthKey
(
const
std
::
string
&
key
);
...
...
@@ -76,7 +116,8 @@ public:
/// Set the key value.
/// If the size is greater than 16 bytes, we resize to 16 bytes.
/// @param key auth key in hexadecimal to be stored.
/// @throw BadValue if the string is not a valid hexadecimal encoding.
/// @throw BadValue if the string is not a valid hexadecimal encoding,
/// for instance has a not hexadecimal or odd number of digits.
void
setAuthKey
(
const
std
::
string
&
key
);
/// @brief Return auth key.
...
...
@@ -88,7 +129,7 @@ public:
/// @brief Return text format for keys.
///
/// @return auth key
in
hexadecimal.
/// @return auth key
as a string of
hexadecimal
digits
.
std
::
string
toText
()
const
;
///
...
...
src/lib/dhcpsrv/mysql_host_data_source.cc
View file @
f45511f0
...
...
@@ -39,43 +39,6 @@ using namespace std;
namespace
{
/// @brief Maximum size of an IPv6 address represented as a text string.
///
/// This is 32 hexadecimal characters written in 8 groups of four, plus seven
/// colon separators.
const
size_t
ADDRESS6_TEXT_MAX_LEN
=
39
;
/// @brief Maximum length of classes stored in a dhcp4/6_client_classes
/// columns.
const
size_t
CLIENT_CLASSES_MAX_LEN
=
255
;
/// @brief Maximum length of the hostname stored in DNS.
///
/// This length is restricted by the length of the domain-name carried
/// in the Client FQDN %Option (see RFC4702 and RFC4704).
const
size_t
HOSTNAME_MAX_LEN
=
255
;
/// @brief Maximum length of option value.
const
size_t
OPTION_VALUE_MAX_LEN
=
4096
;
/// @brief Maximum length of option value specified in textual format.
const
size_t
OPTION_FORMATTED_VALUE_MAX_LEN
=
8192
;
/// @brief Maximum length of option space name.
const
size_t
OPTION_SPACE_MAX_LEN
=
128
;
/// @brief Maximum length of user context.
const
size_t
USER_CONTEXT_MAX_LEN
=
8192
;
/// @brief Maximum length of the server hostname.
const
size_t
SERVER_HOSTNAME_MAX_LEN
=
64
;
/// @brief Maximum length of the boot file name.
const
size_t
BOOT_FILE_NAME_MAX_LEN
=
128
;
/// @brief Maximum length of keys (coded in hexadecimal).
const
size_t
KEY_LEN
=
16
*
2
;
/// @brief Numeric value representing last supported identifier.
///
/// This value is used to validate whether the identifier type stored in
...
...
@@ -407,7 +370,7 @@ public:
// auth key
bind_
[
13
].
buffer_type
=
MYSQL_TYPE_STRING
;
std
::
string
auth_key
=
host
->
getKey
().
toText
();
std
::
strncpy
(
auth_key_
,
auth_key
.
c_str
(),
KEY_LEN
);
std
::
strncpy
(
auth_key_
,
auth_key
.
c_str
(),
TEXT_AUTH_
KEY_LEN
);
auth_key_null_
=
auth_key
.
empty
()
?
MLM_TRUE
:
MLM_FALSE
;
bind_
[
13
].
buffer
=
auth_key_
;
bind_
[
13
].
buffer_length
=
auth_key
.
length
();
...
...
@@ -800,7 +763,7 @@ private:
unsigned
long
dhcp4_boot_file_name_length_
;
/// Authentication keys
char
auth_key_
[
KEY_LEN
];
char
auth_key_
[
TEXT_AUTH_
KEY_LEN
];
/// The length of the string for holding keys
unsigned
long
auth_key_length_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment