-
Notifications
You must be signed in to change notification settings - Fork 285
Implement device-attestations for yubikeys #741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
e320ac5
922f431
99e3ef1
5a516de
cc946a7
8263b2c
305f143
9fcb4c2
e5c1afe
a96fabf
67b9a8b
6ad024e
9a45100
bf79b0c
d0b0ae6
07163ad
389fef8
377194e
4fc5893
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,10 @@ | |
| *.so | ||
| *.dylib | ||
|
|
||
| # Go Workspaces | ||
| go.work | ||
| go.work.sum | ||
|
|
||
| # Test binary, build with `go test -c` | ||
| *.test | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,11 @@ import ( | |
| "go.step.sm/crypto/pemutil" | ||
| ) | ||
|
|
||
| type Attestor interface { | ||
| crypto.Signer | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Embedding this interface could be an issue for a TPM EK, but I'll have to check out its usage. |
||
| Attest() ([]byte, error) | ||
| } | ||
|
|
||
| // CreateSigner reads a key from a file with a given name or creates a signer | ||
| // with the given kms and name uri. | ||
| func CreateSigner(kms, name string, opts ...pemutil.Options) (crypto.Signer, error) { | ||
|
|
@@ -33,6 +38,12 @@ func CreateSigner(kms, name string, opts ...pemutil.Options) (crypto.Signer, err | |
| return newKMSSigner(kms, name) | ||
| } | ||
|
|
||
| // CreateAttestor creates an attestor that will use `step-kms-plugin` with the | ||
| // given kms and uri. | ||
|
||
| func CreateAttestor(kms, name string) (Attestor, error) { | ||
| return newKMSSigner(kms, name) | ||
| } | ||
|
|
||
| // IsKMSSigner returns true if the given signer uses the step-kms-plugin signer. | ||
| func IsKMSSigner(signer crypto.Signer) (ok bool) { | ||
| _, ok = signer.(*kmsSigner) | ||
|
|
@@ -76,7 +87,7 @@ func exitError(cmd *exec.Cmd, err error) error { | |
| } | ||
|
|
||
| // newKMSSigner creates a signer using `step-kms-plugin` as the signer. | ||
| func newKMSSigner(kms, key string) (crypto.Signer, error) { | ||
| func newKMSSigner(kms, key string) (*kmsSigner, error) { | ||
| name, err := plugin.LookPath("kms") | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -152,3 +163,21 @@ func (s *kmsSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) | |
| } | ||
| return base64.StdEncoding.DecodeString(string(out)) | ||
| } | ||
|
|
||
| // Attest returns an attestation certificate using the `step-kms-plugin attest` | ||
| // command. | ||
| func (s *kmsSigner) Attest() ([]byte, error) { | ||
| args := []string{"attest"} | ||
| if s.kms != "" { | ||
| args = append(args, "--kms", s.kms) | ||
| } | ||
| args = append(args, s.key) | ||
|
|
||
| //nolint:gosec // arguments controlled by step. | ||
| cmd := exec.Command(s.name, args...) | ||
| out, err := cmd.Output() | ||
| if err != nil { | ||
| return nil, exitError(cmd, err) | ||
| } | ||
| return out, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,14 @@ func ACMECreateCertFlow(ctx *cli.Context, provisionerName string) error { | |
| } | ||
| ui.PrintSelected("Certificate", certFile) | ||
|
|
||
| _, err = pemutil.Serialize(af.priv, pemutil.ToFile(keyFile, 0600)) | ||
| if err != nil { | ||
| return errors.WithStack(err) | ||
| // We won't have a private key with attestation certificates | ||
| if af.priv != nil { | ||
| _, err = pemutil.Serialize(af.priv, pemutil.ToFile(keyFile, 0600)) | ||
| if err != nil { | ||
| return errors.WithStack(err) | ||
| } | ||
| ui.PrintSelected("Private Key", keyFile) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be an option to indicate that the private key is created and stored in the KMS for the attestation flow?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed with 9a45100 |
||
| } | ||
| ui.PrintSelected("Private Key", keyFile) | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
attestdescriptive enough? Should it be something likeattestation-uri?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 4fc5893