Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var KeyNew = cli.Command{ Name: "sk:new", Action: func(c *cli.Context) error { p := pui.Prompt{ Label: "Enter name of new signing key", } name, err := p.Run() if err != nil { panic(err) } if name == "" { return errors.New("please enter a name for this signing key") } p = pui.Prompt{ Label: "Enter password for signing key encryption", Mask: '*', } pw, err := p.Run() if err != nil { panic(err) } p = pui.Prompt{ Label: "Confirm password", Mask: '*', } pwConfirm, err := p.Run() if err != nil { panic(err) } if pw != pwConfirm { return errors.New("failed to confirm password") } pub, priv, err := ed25519.GenerateKey(rand.Reader) sk := SingingKey{ Name: name, PublicKey: pub[:], privateKey: priv[:], CreateAt: time.Now(), Version: uint8(1), } data, err := sk.Export([]byte(pw)) if err != nil { return err } fileName := fmt.Sprintf("%s_%d.signing_key.json", name, time.Now().Unix()) if err := ioutil.WriteFile(fileName, data, 0775); err != nil { return err } fmt.Println(fmt.Sprintf("wrote signing key to: %s", fileName)) return nil }, }
Functions ¶
This section is empty.
Types ¶
type SingingKey ¶
type SingingKey struct { Name string `json:"name"` PublicKey ed25519.PublicKey `json:"public_key"` PrivateKey scrypt.CipherText `json:"private_key"` CreateAt time.Time `json:"created_at"` Version uint8 `json:"version"` // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.