|
@@ -8,6 +8,7 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"io"
|
|
"io"
|
|
|
"math"
|
|
"math"
|
|
|
|
|
+ "math/bits"
|
|
|
"net/netip"
|
|
"net/netip"
|
|
|
"os"
|
|
"os"
|
|
|
"strings"
|
|
"strings"
|
|
@@ -44,6 +45,20 @@ type caFlags struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func newCaFlags() *caFlags {
|
|
func newCaFlags() *caFlags {
|
|
|
|
|
+ // prevent running out of memory on 32-bit systems by defaulting to
|
|
|
|
|
+ // RFC9106's recommendation for memory-constrained environments
|
|
|
|
|
+ var (
|
|
|
|
|
+ defaultArgonMemory uint
|
|
|
|
|
+ defaultArgonIterations uint
|
|
|
|
|
+ )
|
|
|
|
|
+ if bits.UintSize == 32 {
|
|
|
|
|
+ defaultArgonMemory = 64 * 1024
|
|
|
|
|
+ defaultArgonIterations = 3
|
|
|
|
|
+ } else {
|
|
|
|
|
+ defaultArgonMemory = 2 * 1024 * 1024
|
|
|
|
|
+ defaultArgonIterations = 1
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
cf := caFlags{set: flag.NewFlagSet("ca", flag.ContinueOnError)}
|
|
cf := caFlags{set: flag.NewFlagSet("ca", flag.ContinueOnError)}
|
|
|
cf.set.Usage = func() {}
|
|
cf.set.Usage = func() {}
|
|
|
cf.name = cf.set.String("name", "", "Required: name of the certificate authority")
|
|
cf.name = cf.set.String("name", "", "Required: name of the certificate authority")
|
|
@@ -55,9 +70,9 @@ func newCaFlags() *caFlags {
|
|
|
cf.groups = cf.set.String("groups", "", "Optional: comma separated list of groups. This will limit which groups subordinate certs can use")
|
|
cf.groups = cf.set.String("groups", "", "Optional: comma separated list of groups. This will limit which groups subordinate certs can use")
|
|
|
cf.networks = cf.set.String("networks", "", "Optional: comma separated list of ip address and network in CIDR notation. This will limit which ip addresses and networks subordinate certs can use in networks")
|
|
cf.networks = cf.set.String("networks", "", "Optional: comma separated list of ip address and network in CIDR notation. This will limit which ip addresses and networks subordinate certs can use in networks")
|
|
|
cf.unsafeNetworks = cf.set.String("unsafe-networks", "", "Optional: comma separated list of ip address and network in CIDR notation. This will limit which ip addresses and networks subordinate certs can use in unsafe networks")
|
|
cf.unsafeNetworks = cf.set.String("unsafe-networks", "", "Optional: comma separated list of ip address and network in CIDR notation. This will limit which ip addresses and networks subordinate certs can use in unsafe networks")
|
|
|
- cf.argonMemory = cf.set.Uint("argon-memory", 2*1024*1024, "Optional: Argon2 memory parameter (in KiB) used for encrypted private key passphrase")
|
|
|
|
|
|
|
+ cf.argonMemory = cf.set.Uint("argon-memory", defaultArgonMemory, "Optional: Argon2 memory parameter (in KiB) used for encrypted private key passphrase")
|
|
|
cf.argonParallelism = cf.set.Uint("argon-parallelism", 4, "Optional: Argon2 parallelism parameter used for encrypted private key passphrase")
|
|
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.argonIterations = cf.set.Uint("argon-iterations", defaultArgonIterations, "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.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", "25519", "EdDSA/ECDSA Curve (25519, P256)")
|
|
|
cf.p11url = p11Flag(cf.set)
|
|
cf.p11url = p11Flag(cf.set)
|