예제 #1
0
파일: fcrypt.go 프로젝트: kisom/cryptutils
func keyList(ks *store.KeyStore, cfg *config) error {
	updated := time.Unix(ks.Timestamp, 0).Format(timeFormat)
	fmt.Println("Key store was last updated", updated)
	fmt.Printf("%d keys stored\n", len(ks.Keys))
	fmt.Println("Owner public key:")
	h := sha256.New()
	h.Write(ks.PublicKey)
	fmt.Printf("\tFingerprint: %x\n", h.Sum(nil))
	if len(ks.Keys) > 0 {
		fmt.Println("Key store:")
		for k, v := range ks.Keys {
			fmt.Printf("\t%s\n", k)
			ut := time.Unix(v.Timestamp, 0)
			st := time.Unix(v.SignatureTime, 0)
			signer, ok := ks.FindPublic(v.KeySigner)
			if !ok {
				signer = "<unknown>"
			}
			h = sha256.New()
			h.Write(v.Keys)
			fmt.Printf("\t\tLast update: %s\n", ut.Format(timeFormat))
			fmt.Printf("\t\t  Signed at: %s\n", st.Format(timeFormat))
			fmt.Printf("\t\t  Signed by: %s\n", signer)
			fmt.Printf("\t\tFingerprint: %x\n", h.Sum(nil))
		}
	}
	return nil
}
예제 #2
0
파일: fcrypt.go 프로젝트: kisom/cryptutils
func importVerified(ks *store.KeyStore, cfg *config) error {
	keyData, err := util.ReadFile(cfg.Args[0])
	if err != nil {
		return err
	}

	if cfg.Label == "self" {
		cfg.Label, err = util.ReadLine("Label: ")
		if err != nil {
			return err
		}
	}

	if !ks.ImportVerifiedKey(cfg.Label, keyData) {
		return errors.New("verified import failed")
	}

	vkey, err := store.ParseVerifiedKey(keyData)
	if err != nil {
		return err
	}

	label, ok := ks.FindPublic(vkey.Signer)
	if !ok {
		return errors.New("invalid signer on key")

	}

	fmt.Printf("Imported public key signed by '%s'.\n", label)
	return nil
}