Skip to content

feat: Add PKCS#11 support for platform key(s) #3222

@bencorrado

Description

@bencorrado

Is your feature request related to a problem? Please describe.

When using auroraboot to build a UKI we should be able to pass a URI for a PKCS#11 device that is holding the RSA private key.

Describe the solution you'd like

Add support to go-ukify and auroraboot to pass in a URI, passcode and/or module link to allow for the private key (primarily db.key) to be stored on a hardware key instead of plaintext on the filesystem.

Describe alternatives you've considered

Keep using a more insecure option of keys in plaintext on the filesystem.

Additional context

For auroraboot something like changing/adding:

		&cli.StringFlag{
			Name:  "sb-key-uri",
			Value: "",
			Usage: "Override SBKey with a PKCS#11 URI (e.g. 'pkcs11:manufacturer=piv_II;id=%02'). If empty, the default file-based key will be used.",
		},
		&cli.StringFlag{
			Name:  "pkcs11-pin",
			Value: "",
			Usage: "PIN for the PKCS#11 token (YubiKey); required when using a pkcs11 URI",
		},
		&cli.StringFlag{
			Name:  "pkcs11-path",
			Value: "/usr/lib/libykcs11.so",
			Usage: "Path to the PKCS#11 module (default: /usr/lib/libykcs11.so)",
		},

...

		// Check if the keys directory contains the required files
		requiredFiles := []string{"db.der", "db.auth", "KEK.der", "KEK.auth", "PK.der", "PK.auth", "tpm2-pcr-private.pem"}
		// If no SBKey override is provided, then require "db.key".
		if ctx.String("sb-key-uri") == "" {
			requiredFiles = append(requiredFiles, "db.key")
		}

...


			var sbKey string
			if ctx.String("sb-key-uri") != "" {
				// Use the provided PKCS#11 URI.
				sbKey = ctx.String("sb-key-uri")
			} else {
				// Otherwise use the default file-based SBKey.
				sbKey = filepath.Join(ctx.String("keys"), "db.key")
			}

			builder := &uki.Builder{
				Arch:          config.Arch,
				Version:       kairosVersion,
				SdStubPath:    stub,
				KernelPath:    filepath.Join(artifactsTempDir, "vmlinuz"),
				InitrdPath:    filepath.Join(artifactsTempDir, "initrd"),
				Cmdline:       entry.Cmdline,
				OsRelease:     filepath.Join(sourceDir, "etc/os-release"),
				OutUKIPath:    entry.FileName + ".efi",
				PCRKey:        filepath.Join(ctx.String("keys"), "tpm2-pcr-private.pem"),
				SBKey:         sbKey,
				SBCert:        filepath.Join(ctx.String("keys"), "db.pem"),
				SdBootPath:    systemdBoot,
				OutSdBootPath: outputSystemdBootEfi,
				Splash:        ctx.String("splash"),
			        PKCS11Pin:    ctx.String("pkcs11-pin"),
			        PKCS11Path:   ctx.String("pkcs11-path"),
			}

and adding support for github.com/ThalesIgnite/crypto11 to go-ukifiy and the handlers to support the auroraboot parts above.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions