Skip to content
Snippets Groups Projects
Commit 3325866c authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Added function for DS algorithm length calculation.

- Copied from descriptor.c
parent 5aa6532e
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,15 @@ static knot_lookup_table_t dns_classes[] = {
{ 0, NULL }
};
/*! \brief DS digest lengths. */
enum knot_ds_algorithm_len
{
KNOT_DS_DIGEST_LEN_SHA1 = 20, /* 20B - RFC 3658 */
KNOT_DS_DIGEST_LEN_SHA256 = 32, /* 32B - RFC 4509 */
KNOT_DS_DIGEST_LEN_GOST = 32, /* 32B - RFC 5933 */
KNOT_DS_DIGEST_LEN_SHA384 = 48 /* 48B - RFC 6605 */
};
/*!
* \brief RR type descriptors.
*/
......@@ -282,3 +291,20 @@ int knot_rrtype_is_metatype(const uint16_t type)
type == KNOT_RRTYPE_ANY);
}
size_t knot_ds_digest_length(uint8_t algorithm)
{
switch (algorithm) {
case KNOT_DS_ALG_SHA1:
return KNOT_DS_DIGEST_LEN_SHA1;
case KNOT_DS_ALG_SHA256:
return KNOT_DS_DIGEST_LEN_SHA256;
case KNOT_DS_ALG_GOST:
return KNOT_DS_DIGEST_LEN_GOST;
case KNOT_DS_ALG_SHA384:
return KNOT_DS_DIGEST_LEN_SHA384;
default:
return 0;
}
}
......@@ -115,6 +115,38 @@ enum knot_rdata_wireformat {
KNOT_RDATA_WF_END = 0,
};
/*! \brief Constants for DNSSEC algorithm types.
*
* Source: http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml
*/
enum knot_dnssec_algorithm
{
KNOT_DNSSEC_ALG_RSAMD5 = 1,
KNOT_DNSSEC_ALG_DH = 2,
KNOT_DNSSEC_ALG_DSA = 3,
KNOT_DNSSEC_ALG_RSASHA1 = 5,
KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1 = 6,
KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1 = 7,
KNOT_DNSSEC_ALG_RSASHA256 = 8,
KNOT_DNSSEC_ALG_RSASHA512 = 10,
KNOT_DNSSEC_ALG_ECC_GOST = 12,
KNOT_DNSSEC_ALG_ECDSAP256SHA256 = 13,
KNOT_DNSSEC_ALG_ECDSAP384SHA384 = 14
};
/*! \brief Constants for DNSSEC algorithm types.
*
* Source: http://www.iana.org/assignments/ds-rr-types/ds-rr-types.xml
*/
enum knot_ds_algorithm
{
KNOT_DS_ALG_SHA1 = 1, /* 20B - RFC 3658 */
KNOT_DS_ALG_SHA256 = 2, /* 32B - RFC 4509 */
KNOT_DS_ALG_GOST = 3, /* 32B - RFC 5933 */
KNOT_DS_ALG_SHA384 = 4 /* 48B - RFC 6605 */
};
/*!
* \brief Structure describing rdata.
*/
......@@ -235,6 +267,14 @@ int descriptor_item_is_remainder(const int item);
*/
int knot_rrtype_is_metatype(const uint16_t type);
/*!
* \brief Return length of DS digest for given algorithm.
*
* \param algorithm Algorithm code to be used
*
* \retval Digest length for given algorithm.
*/
size_t knot_ds_digest_length(uint8_t algorithm);
#endif // _KNOT_DESCRIPTOR_NEW_H_
/*! @} */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment