| 70 | } |
| 71 | |
| 72 | func (a *secureAgent) List() ([]*xagent.Key, error) { |
| 73 | // 动态加载最新的密钥列表 |
| 74 | metas, err := a.loadMetas() |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | |
| 79 | var ks []*xagent.Key |
| 80 | for _, m := range metas { |
| 81 | if m.PubKey == "" { |
| 82 | continue |
| 83 | } |
| 84 | pb, err := base64.StdEncoding.DecodeString(m.PubKey) |
| 85 | if err != nil { |
| 86 | continue |
| 87 | } |
| 88 | pk, err := ssh.ParsePublicKey(pb) |
| 89 | if err != nil { |
| 90 | continue |
| 91 | } |
| 92 | ks = append(ks, &xagent.Key{Format: pk.Type(), Blob: pk.Marshal(), Comment: m.Alias}) |
| 93 | } |
| 94 | return ks, nil |
| 95 | } |
| 96 | |
| 97 | func (a *secureAgent) Sign(pubkey ssh.PublicKey, data []byte) (*ssh.Signature, error) { |
| 98 | fp := ssh.FingerprintSHA256(pubkey) |