MCPcopy Create free account
hub / github.com/Mister-leo/fssh / LoadMasterKey

Function LoadMasterKey

internal/keychain/keychain.go:97–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func LoadMasterKey() ([]byte, error) {
98 // Gate access behind biometry prompt
99 if err := macos.RequireBiometry("解锁指纹受保护的主密钥以使用 SSH 私钥"); err != nil {
100 return nil, err
101 }
102 res, err := queryMasterKey(serviceNew)
103 if err != nil {
104 return nil, err
105 }
106 if len(res) == 0 {
107 // try old service for backward compatibility
108 res, err = queryMasterKey(serviceOld)
109 if err != nil {
110 return nil, err
111 }
112 if len(res) == 0 {
113 return nil, fmt.Errorf("master key not initialized")
114 }
115 }
116 return res[0].Data, nil
117}
118
119func queryMasterKey(svc string) ([]kc.QueryResult, error) {
120 q := kc.NewItem()

Callers 6

UnlockMasterKeyMethod · 0.92
importSSHKeysFunction · 0.92
cmdImportFunction · 0.92
cmdExportFunction · 0.92
cmdRemoveFunction · 0.92
cmdRekeyFunction · 0.92

Calls 2

RequireBiometryFunction · 0.92
queryMasterKeyFunction · 0.85

Tested by

no test coverage detected