Commit f31db29b authored by Jan Včelák's avatar Jan Včelák 🚀
Browse files

dnssec, implement dnssec_tsig_optimal_key_size()

parent 0427b228
......@@ -137,6 +137,11 @@ dnssec_tsig_algorithm_t dnssec_tsig_algorithm_from_name(const char *name);
*/
const char *dnssec_tsig_algorithm_to_name(dnssec_tsig_algorithm_t algorithm);
/*!
* Get optimal size of a TSIG algorithm.
*/
int dnssec_tsig_optimal_key_size(dnssec_tsig_algorithm_t algorithm);
struct dnssec_tsig_ctx;
/*!
......
......@@ -17,6 +17,7 @@
#include <assert.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
......@@ -143,6 +144,17 @@ const char *dnssec_tsig_algorithm_to_name(dnssec_tsig_algorithm_t algorithm)
return (found ? found->name : NULL);
}
_public_
int dnssec_tsig_optimal_key_size(dnssec_tsig_algorithm_t tsig)
{
gnutls_mac_algorithm_t mac = algorithm_to_gnutls(tsig);
if (mac == GNUTLS_MAC_UNKNOWN) {
return 0;
}
return gnutls_mac_get_key_size(mac) * CHAR_BIT;
}
_public_
int dnssec_tsig_new(dnssec_tsig_ctx_t **ctx_ptr,
dnssec_tsig_algorithm_t algorithm,
......
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