diff --git a/bin/dnssec/Makefile.am b/bin/dnssec/Makefile.am index 32c462620a..007c66f355 100644 --- a/bin/dnssec/Makefile.am +++ b/bin/dnssec/Makefile.am @@ -12,7 +12,8 @@ noinst_LTLIBRARIES = libdnssectool.la LDADD += \ libdnssectool.la \ $(LIBISC_LIBS) \ - $(LIBDNS_LIBS) + $(LIBDNS_LIBS) \ + $(OPENSSL_LIBS) bin_PROGRAMS = \ dnssec-cds \ @@ -31,7 +32,8 @@ libdnssectool_la_SOURCES = \ dnssec_keygen_CPPFLAGS = \ $(AM_CPPFLAGS) \ - $(LIBISCCFG_CFLAGS) + $(LIBISCCFG_CFLAGS) \ + $(OPENSSL_CFLAGS) dnssec_keygen_LDADD = \ $(LDADD) \ diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 35246e5f05..662c4462f5 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -61,9 +62,17 @@ #include "dnssectool.h" #define MAX_RSA 4096 /* should be long enough... */ +#define MAX_DH 4096 /* should be long enough... */ const char *program = "dnssec-keygen"; +/* + * These are are set here for backwards compatibility. They are + * raised to 2048 in FIPS mode. + */ +static int min_rsa = 1024; +static int min_dh = 128; + isc_log_t *lctx = NULL; noreturn static void @@ -139,16 +148,22 @@ usage(void) { fprintf(stderr, " -l : configuration file with dnssec-policy " "statement\n"); fprintf(stderr, " -a :\n"); - fprintf(stderr, " RSASHA1 | NSEC3RSASHA1 |\n"); + if (!isc_fips_mode()) { + fprintf(stderr, " RSASHA1 | NSEC3RSASHA1 |\n"); + } fprintf(stderr, " RSASHA256 | RSASHA512 |\n"); fprintf(stderr, " ECDSAP256SHA256 | ECDSAP384SHA384 |\n"); fprintf(stderr, " ED25519 | ED448\n"); fprintf(stderr, " -3: use NSEC3-capable algorithm\n"); fprintf(stderr, " -b :\n"); - fprintf(stderr, " RSASHA1:\t[1024..%d]\n", MAX_RSA); - fprintf(stderr, " NSEC3RSASHA1:\t[1024..%d]\n", MAX_RSA); - fprintf(stderr, " RSASHA256:\t[1024..%d]\n", MAX_RSA); - fprintf(stderr, " RSASHA512:\t[1024..%d]\n", MAX_RSA); + if (!isc_fips_mode()) { + fprintf(stderr, " RSASHA1:\t[%d..%d]\n", min_rsa, + MAX_RSA); + fprintf(stderr, " NSEC3RSASHA1:\t[%d..%d]\n", min_rsa, + MAX_RSA); + } + fprintf(stderr, " RSASHA256:\t[%d..%d]\n", min_rsa, MAX_RSA); + fprintf(stderr, " RSASHA512:\t[%d..%d]\n", min_rsa, MAX_RSA); fprintf(stderr, " ECDSAP256SHA256:\tignored\n"); fprintf(stderr, " ECDSAP384SHA384:\tignored\n"); fprintf(stderr, " ED25519:\tignored\n"); @@ -318,6 +333,17 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) { fatal("unsupported algorithm: %s", algstr); } + if (isc_fips_mode()) { + /* verify only in FIPS mode */ + switch (ctx->alg) { + case DST_ALG_RSASHA1: + case DST_ALG_NSEC3RSASHA1: + fatal("unsupported algorithm: %s", algstr); + default: + break; + } + } + if (ctx->use_nsec3) { switch (ctx->alg) { case DST_ALG_RSASHA1: @@ -360,6 +386,11 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) { switch (ctx->alg) { case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: + if (isc_fips_mode()) { + fatal("key size not specified (-b " + "option)"); + } + FALLTHROUGH; case DST_ALG_RSASHA256: case DST_ALG_RSASHA512: ctx->size = 2048; @@ -515,14 +546,14 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) { switch (ctx->alg) { case DNS_KEYALG_RSASHA1: case DNS_KEYALG_NSEC3RSASHA1: - case DNS_KEYALG_RSASHA256: - if (ctx->size != 0 && (ctx->size < 1024 || ctx->size > MAX_RSA)) - { - fatal("RSA key size %d out of range", ctx->size); + if (isc_fips_mode()) { + fatal("SHA1 based keys not supported in FIPS mode"); } - break; + FALLTHROUGH; + case DNS_KEYALG_RSASHA256: case DNS_KEYALG_RSASHA512: - if (ctx->size != 0 && (ctx->size < 1024 || ctx->size > MAX_RSA)) + if (ctx->size != 0 && + (ctx->size < min_rsa || ctx->size > MAX_RSA)) { fatal("RSA key size %d out of range", ctx->size); } @@ -1106,6 +1137,14 @@ main(int argc, char **argv) { fatal("could not initialize dst: %s", isc_result_totext(ret)); } + /* + * After dst_lib_init which will set FIPS mode if requested + * at build time. The minumums are both raised to 2048. + */ + if (isc_fips_mode()) { + min_rsa = min_dh = 2048; + } + setup_logging(mctx, &lctx); ctx.rdclass = strtoclass(classname);