Skip to content

Commit

Permalink
mask pin input
Browse files Browse the repository at this point in the history
  • Loading branch information
solipsis committed Apr 2, 2018
1 parent 24762a7 commit 9ff0a38
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions cmd/flashWrite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cmd

import (
"encoding/binary"
"encoding/hex"
"fmt"
"os"

"github.com/spf13/cobra"
)

func init() {
flashWriteCmd.Flags().StringVarP(&memAddress, "address", "a", "", "memory address to begin writing")
flashWriteCmd.Flags().StringVarP(&writeData, "data", "d", "", "data to write in hex")
rootCmd.AddCommand(flashWriteCmd)
}

// Data to write to device
var writeData string

var flashWriteCmd = &cobra.Command{
Use: "flashWrite",
Short: "Write data over flash sectors",
Long: "Writes data over flash sectors",
Run: func(cmd *cobra.Command, args []string) {

// data to write
data := mustParseHex(writeData)

// Convert hex address to uint32
addr := binary.BigEndian.Uint32(mustParseHex(memAddress))

resp, err := kk.FlashWrite(addr, data)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Println(hex.EncodeToString(resp))
},
}
1 change: 1 addition & 0 deletions pkg/keepkey/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func promptPin() (string, error) {
prompt := promptui.Prompt{
Label: "Pin",
Validate: validate,
Mask: '*',
}
res, err := prompt.Run()
if err != nil {
Expand Down

0 comments on commit 9ff0a38

Please sign in to comment.