diff --git a/cmd/nebula-cert/ca.go b/cmd/nebula-cert/ca.go index 3145f445..8fafb587 100644 --- a/cmd/nebula-cert/ca.go +++ b/cmd/nebula-cert/ca.go @@ -3,6 +3,7 @@ package main import ( "crypto/ecdsa" "crypto/elliptic" + "crypto/fips140" "crypto/rand" "flag" "fmt" @@ -43,6 +44,13 @@ type caFlags struct { subnets *string } +func defaultCurve() string { + if fips140.Enforced() { + return "P256" + } + return "25519" +} + func newCaFlags() *caFlags { cf := caFlags{set: flag.NewFlagSet("ca", flag.ContinueOnError)} cf.set.Usage = func() {} @@ -59,7 +67,7 @@ func newCaFlags() *caFlags { cf.argonParallelism = cf.set.Uint("argon-parallelism", 4, "Optional: Argon2 parallelism parameter used for encrypted private key passphrase") cf.argonIterations = cf.set.Uint("argon-iterations", 1, "Optional: Argon2 iterations parameter used for encrypted private key passphrase") cf.encryption = cf.set.Bool("encrypt", false, "Optional: prompt for passphrase and write out-key in an encrypted format") - cf.curve = cf.set.String("curve", "25519", "EdDSA/ECDSA Curve (25519, P256)") + cf.curve = cf.set.String("curve", defaultCurve(), "EdDSA/ECDSA Curve (25519, P256)") cf.p11url = p11Flag(cf.set) cf.ips = cf.set.String("ips", "", "Deprecated, see -networks") diff --git a/cmd/nebula-cert/keygen.go b/cmd/nebula-cert/keygen.go index dea6c4af..9574156f 100644 --- a/cmd/nebula-cert/keygen.go +++ b/cmd/nebula-cert/keygen.go @@ -24,7 +24,7 @@ func newKeygenFlags() *keygenFlags { cf.set.Usage = func() {} cf.outPubPath = cf.set.String("out-pub", "", "Required: path to write the public key to") cf.outKeyPath = cf.set.String("out-key", "", "Required: path to write the private key to") - cf.curve = cf.set.String("curve", "25519", "ECDH Curve (25519, P256)") + cf.curve = cf.set.String("curve", defaultCurve(), "ECDH Curve (25519, P256)") cf.p11url = p11Flag(cf.set) return &cf }