#include <isc/attributes.h>
#include <isc/buffer.h>
#include <isc/commandline.h>
+#include <isc/fips.h>
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/result.h>
#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
fprintf(stderr, " -l <file>: configuration file with dnssec-policy "
"statement\n");
fprintf(stderr, " -a <algorithm>:\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 <key size in bits>:\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");
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:
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;
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);
}
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);