MCPcopy
hub / github.com/perkeep/perkeep / KeyIdFromRing

Function KeyIdFromRing

pkg/jsonsign/keys.go:176–191  ·  view source on GitHub ↗

KeyIdFromRing returns the public keyID contained in the secret ring file secRing. It expects only one keyID in this secret ring and returns an error otherwise.

(secRing string)

Source from the content-addressed store, hash-verified

174// ring file secRing. It expects only one keyID in this secret ring
175// and returns an error otherwise.
176func KeyIdFromRing(secRing string) (keyID string, err error) {
177 f, err := wkfs.Open(secRing)
178 if err != nil {
179 return "", fmt.Errorf("Could not open secret ring file %v: %v", secRing, err)
180 }
181 defer f.Close()
182 el, err := readKeyRing(f)
183 if err != nil {
184 return "", fmt.Errorf("Could not read secret ring file %s: %v", secRing, err)
185 }
186 if len(el) != 1 {
187 return "", fmt.Errorf("Secret ring file %v contained %d identities; expected 1", secRing, len(el))
188 }
189 ent := el[0]
190 return ent.PrimaryKey.KeyIdString(), nil
191}
192
193// GenerateNewSecRing creates a new secret ring file secRing, with
194// a new GPG identity. It returns the public keyID of that identity.

Callers 3

longIdentityMethod · 0.92
getOrMakeKeyringFunction · 0.92
initKeyIdMethod · 0.92

Calls 3

readKeyRingFunction · 0.85
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected