a bunch of updates, including verify function

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
Dave Henderson
2018-08-09 00:30:16 -04:00
parent 946aa8c3f3
commit 008a314137
6 changed files with 318 additions and 52 deletions

View File

@ -1,8 +1,12 @@
package cmd
import (
"bytes"
"context"
"github.com/pkg/errors"
"github.com/hairyhenderson/go-onerng"
"github.com/spf13/cobra"
)
@ -78,7 +82,17 @@ func verifyCmd(ctx context.Context) *cobra.Command {
Use: "verify",
Short: "Verify that OneRNG's firmware has not been tampered with.",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
o := onerng.OneRNG{Path: opts.Device}
err := o.Init(ctx)
if err != nil {
return errors.Wrapf(err, "init failed before image verification")
}
image, err := o.Image(ctx)
if err != nil {
return errors.Wrapf(err, "image extraction failed before verification")
}
err = onerng.Verify(ctx, bytes.NewBuffer(image), publicKey)
return err
},
}
}