namespace detail {
namespace nsec3 {
-ParseNSEC3ParamResult
-parseNSEC3ParamText(const char* const rrtype_name,
- const string& rdata_str, istringstream& iss,
- vector<uint8_t>& salt)
-{
- unsigned int hashalg, flags, iterations;
- string iterations_str, salthex;
-
- iss >> hashalg >> flags >> iterations_str >> salthex;
- if (iss.bad() || iss.fail()) {
- isc_throw(InvalidRdataText, "Invalid " << rrtype_name <<
- " text: " << rdata_str);
- }
- if (hashalg > 0xff) {
- isc_throw(InvalidRdataText, rrtype_name <<
- " hash algorithm out of range: " << hashalg);
- }
- if (flags > 0xff) {
- isc_throw(InvalidRdataText, rrtype_name << " flags out of range: " <<
- flags);
- }
- // Convert iteration. To reject an invalid case where there's no space
- // between iteration and salt, we extract this field as string and convert
- // to integer.
- try {
- iterations = boost::lexical_cast<unsigned int>(iterations_str);
- } catch (const boost::bad_lexical_cast&) {
- isc_throw(InvalidRdataText, "Bad " << rrtype_name <<
- " iteration: " << iterations_str);
- }
- if (iterations > 0xffff) {
- isc_throw(InvalidRdataText, rrtype_name <<
- " iterations out of range: " <<
- iterations);
- }
-
- // Salt is up to 255 bytes, and space is not allowed in the HEX encoding,
- // so the encoded string cannot be longer than the double of max length
- // of the actual salt.
- if (salthex.size() > 255 * 2) {
- isc_throw(InvalidRdataText, rrtype_name << " salt is too long: "
- << salthex.size() << " (encoded) bytes");
- }
- if (salthex != "-") { // "-" means a 0-length salt
- decodeHex(salthex, salt);
- }
-
- return (ParseNSEC3ParamResult(hashalg, flags, iterations));
-}
-
ParseNSEC3ParamResult
parseNSEC3ParamFromLexer(const char* const rrtype_name,
MasterLexer& lexer, vector<uint8_t>& salt)
#include <util/buffer.h>
#include <stdint.h>
-
-#include <sstream>
-#include <string>
#include <vector>
namespace isc {
/// \brief Convert textual representation of NSEC3 parameters.
///
-/// This function takes an input string stream that consists of a complete
+/// This function takes an input MasterLexer that points at a complete
/// textual representation of an NSEC3 or NSEC3PARAM RDATA and parses it
/// extracting the hash algorithm, flags, iterations, and salt fields.
///
/// The salt will be stored in the given vector. The vector is expected
/// to be empty, but if not, the existing content will be overridden.
///
-/// On successful return the given input stream will reach the end of the
+/// On successful return the given MasterLexer will reach the end of the
/// salt field.
///
/// \exception isc::BadValue The salt is not a valid hex string.
-/// \exception InvalidRdataText The given string is otherwise invalid for
-/// NSEC3 or NSEC3PARAM fields.
-///
-/// \param rrtype_name Either "NSEC3" or "NSEC3PARAM"; used as part of
-/// exception messages.
-/// \param rdata_str A complete textual string of the RDATA; used as part of
-/// exception messages.
-/// \param iss Input stream that consists of a complete textual string of
-/// the RDATA.
-/// \param salt A placeholder for the salt field value of the RDATA.
-/// Expected to be empty, but it's not checked (and will be overridden).
-///
-/// \return The hash algorithm, flags, iterations in the form of
-/// ParseNSEC3ParamResult.
-ParseNSEC3ParamResult parseNSEC3ParamText(const char* const rrtype_name,
- const std::string& rdata_str,
- std::istringstream& iss,
- std::vector<uint8_t>& salt);
-
-/// \brief Convert textual representation of NSEC3 parameters
-/// (MasterLexer variant).
-///
-/// This function is identical to \c parseNSEC3ParamText(), except that
-/// it reads the NSEC3 parameters from a MasterLexer.
-///
-/// \exception isc::BadValue The salt is not a valid hex string.
-/// \exception InvalidRdataText The given string is otherwise invalid for
+/// \exception InvalidRdataText The given RDATA is otherwise invalid for
/// NSEC3 or NSEC3PARAM fields.
/// \exception MasterLexer::LexerError There was a failure reading a
/// field from the MasterLexer.