Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
fix: Use .KeyID to reference key IDs instead of fingerprints
Browse files Browse the repository at this point in the history
  • Loading branch information
pojntfx committed Oct 28, 2022
1 parent c29075e commit 60805a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/components/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (c *Home) Render() app.UI {
c.createKeyModalOpen = false
c.keySuccessfullyGeneratedModalOpen = true

parsedKey, fingerprint, err := crypt.ReadKey(key, password)
parsedKey, _, err := crypt.ReadKey(key, password)
if err != nil {
c.panic(err, func() {})

Expand All @@ -469,8 +469,8 @@ func (c *Home) Render() app.UI {
}

c.keys = append(c.keys, PGPKey{
ID: fingerprint, // Since we don't generate subkeys, we'll only have one fingerprint
Label: fingerprint[0:10], // We can safely assume that the fingerprint is at least 10 chars long
ID: parsedKey.PrimaryKey.KeyIdString(),
Label: parsedKey.PrimaryKey.KeyIdShortString(),
FullName: id.Name,
Email: id.UserId.Email,
Private: parsedKey.PrivateKey != nil,
Expand Down Expand Up @@ -526,7 +526,7 @@ func (c *Home) Render() app.UI {
}

if parsedKey == nil {
parsedKey, fingerprint, err = crypt.ReadKey(key, "")
parsedKey, _, err = crypt.ReadKey(key, "")
if err != nil {
c.panic(err, func() {})

Expand All @@ -543,7 +543,7 @@ func (c *Home) Render() app.UI {

newKeys := []PGPKey{}
for _, candidate := range c.keys {
if candidate.ID == fingerprint {
if candidate.ID == parsedKey.PrimaryKey.KeyIdString() {
// Replace the key if the existing key is a public key and the imported key is a private key
if !candidate.Private && parsedKey.PrivateKey != nil {
continue
Expand All @@ -561,8 +561,8 @@ func (c *Home) Render() app.UI {
}

newKeys = append(newKeys, PGPKey{
ID: fingerprint, // Since we don't generate subkeys, we'll only have one fingerprint
Label: fingerprint[0:10], // We can safely assume that the fingerprint is at least 10 chars long
ID: parsedKey.PrimaryKey.KeyIdString(),
Label: parsedKey.PrimaryKey.KeyIdShortString(),
FullName: id.Name,
Email: id.UserId.Email,
Private: parsedKey.PrivateKey != nil,
Expand Down

0 comments on commit 60805a2

Please sign in to comment.