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
c374a5c5
Commit
c374a5c5
authored
Apr 14, 2011
by
Jelte Jansen
Browse files
[trac781] make sig args for verify() also raw data
parent
cd3ce64a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/crypto/crypto.cc
View file @
c374a5c5
...
...
@@ -138,11 +138,11 @@ signHMAC(const void* data, size_t data_len, TSIGKey key,
bool
verifyHMAC
(
const
void
*
data
,
size_t
data_len
,
TSIGKey
key
,
const
isc
::
dns
::
OutputBuffer
&
result
)
const
void
*
sig
,
size_t
sig_len
)
{
HMAC
hmac
(
key
);
hmac
.
update
(
data
,
data_len
);
return
(
hmac
.
verify
(
result
.
getData
(),
result
.
getLength
()
));
return
(
hmac
.
verify
(
sig
,
sig_len
));
}
}
// namespace crypto
...
...
src/lib/crypto/crypto.h
View file @
c374a5c5
...
...
@@ -138,7 +138,8 @@ void signHMAC(const void* data,
bool
verifyHMAC
(
const
void
*
data
,
size_t
data_len
,
isc
::
dns
::
TSIGKey
key
,
const
isc
::
dns
::
OutputBuffer
&
mac
);
const
void
*
sig
,
size_t
sig_len
);
}
// namespace crypto
}
// namespace isc
...
...
src/lib/crypto/tests/crypto_unittests.cc
View file @
c374a5c5
...
...
@@ -49,13 +49,15 @@ namespace {
// Check whether we can verify it ourselves
EXPECT_TRUE
(
verifyHMAC
(
data_buf
.
getData
(),
data_buf
.
getLength
(),
key
,
hmac_sig
));
key
,
hmac_sig
.
getData
(),
hmac_sig
.
getLength
()));
// Change the sig by flipping the first octet, and check
// whether verification fails then
hmac_sig
.
writeUint8At
(
~
hmac_sig
[
0
],
0
);
EXPECT_FALSE
(
verifyHMAC
(
data_buf
.
getData
(),
data_buf
.
getLength
(),
key
,
hmac_sig
));
key
,
hmac_sig
.
getData
(),
hmac_sig
.
getLength
()));
}
}
...
...
@@ -291,5 +293,6 @@ TEST(CryptoTest, BadKey) {
EXPECT_THROW
(
signHMAC
(
data_buf
.
getData
(),
data_buf
.
getLength
(),
bad_key
,
hmac_sig
),
BadKey
);
EXPECT_THROW
(
verifyHMAC
(
data_buf
.
getData
(),
data_buf
.
getLength
(),
bad_key
,
hmac_sig
),
BadKey
);
bad_key
,
hmac_sig
.
getData
(),
hmac_sig
.
getLength
()),
BadKey
);
}
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