Commit 67872ac4 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2124] Allow algorithm=0 and fingerprint-type=0

parent 5e7af00c
......@@ -43,14 +43,6 @@ SSHFP::SSHFP(InputBuffer& buffer, size_t rdata_len) {
algorithm_ = buffer.readUint8();
fingerprint_type_ = buffer.readUint8();
if (algorithm_ < 1) {
isc_throw(InvalidRdataText, "SSHFP algorithm number out of range");
}
if (fingerprint_type_ < 1) {
isc_throw(InvalidRdataText, "SSHFP fingerprint type out of range");
}
rdata_len -= 2;
fingerprint_.resize(rdata_len);
buffer.readData(&fingerprint_[0], rdata_len);
......@@ -68,11 +60,11 @@ SSHFP::SSHFP(const std::string& sshfp_str) {
isc_throw(InvalidRdataText, "Invalid SSHFP text");
}
if ((algorithm < 1) || (algorithm > 255)) {
if (algorithm > 255) {
isc_throw(InvalidRdataText, "SSHFP algorithm number out of range");
}
if ((fingerprint_type < 1) || (fingerprint_type > 255)) {
if (fingerprint_type > 255) {
isc_throw(InvalidRdataText, "SSHFP fingerprint type out of range");
}
......@@ -96,14 +88,6 @@ SSHFP::SSHFP(const std::string& sshfp_str) {
SSHFP::SSHFP(uint8_t algorithm, uint8_t fingerprint_type,
const std::string& fingerprint)
{
if (algorithm < 1) {
isc_throw(InvalidRdataText, "SSHFP algorithm number out of range");
}
if (fingerprint_type < 1) {
isc_throw(InvalidRdataText, "SSHFP fingerprint type out of range");
}
algorithm_ = algorithm;
fingerprint_type_ = fingerprint_type;
......
......@@ -71,11 +71,9 @@ TEST_F(Rdata_SSHFP_Test, algorithmTypes) {
EXPECT_NO_THROW(const generic::SSHFP rdata_sshfp("1 128 12ab"));
EXPECT_NO_THROW(const generic::SSHFP rdata_sshfp("1 255 12ab"));
// 0 is still reserved.
EXPECT_THROW(const generic::SSHFP rdata_sshfp("0 1 12ab"),
InvalidRdataText);
EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 0 12ab"),
InvalidRdataText);
// 0 is reserved, but we allow that too
EXPECT_NO_THROW(const generic::SSHFP rdata_sshfp("0 1 12ab"));
EXPECT_NO_THROW(const generic::SSHFP rdata_sshfp("1 0 12ab"));
// > 255 would be broken
EXPECT_THROW(const generic::SSHFP rdata_sshfp("256 1 12ab"),
......@@ -114,14 +112,12 @@ TEST_F(Rdata_SSHFP_Test, createFromWire) {
"rdata_sshfp_fromWire4.wire"));
// algorithm=0, fingerprint=1
EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
"rdata_sshfp_fromWire5.wire"),
InvalidRdataText);
EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
"rdata_sshfp_fromWire5.wire"));
// algorithm=5, fingerprint=0
EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
"rdata_sshfp_fromWire6.wire"),
InvalidRdataText);
EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
"rdata_sshfp_fromWire6.wire"));
// algorithm=255, fingerprint=255
EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment