forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ProtonMail/go-crypto to replace keybase/go-crypto (go-gitea#33402)
Fix go-gitea#33400 The keybase/go-crypto is no longer maintained and it generates malformed signatures, ProtonMail/go-crypto is the actively maintained fork.
- Loading branch information
1 parent
826fffb
commit 150acbf
Showing
12 changed files
with
55 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,8 @@ import ( | |
"code.gitea.io/gitea/modules/timeutil" | ||
"code.gitea.io/gitea/modules/util" | ||
|
||
"github.com/keybase/go-crypto/openpgp/packet" | ||
"github.com/ProtonMail/go-crypto/openpgp" | ||
"github.com/ProtonMail/go-crypto/openpgp/packet" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
|
@@ -403,3 +404,25 @@ func TestTryGetKeyIDFromSignature(t *testing.T) { | |
IssuerFingerprint: []uint8{0xb, 0x23, 0x24, 0xc7, 0xe6, 0xfe, 0x4f, 0x3a, 0x6, 0x26, 0xc1, 0x21, 0x3, 0x8d, 0x1a, 0x3e, 0xad, 0xdb, 0xea, 0x9c}, | ||
})) | ||
} | ||
|
||
func TestParseGPGKey(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
assert.NoError(t, db.Insert(db.DefaultContext, &user_model.EmailAddress{UID: 1, Email: "[email protected]", IsActivated: true})) | ||
|
||
// create a key for test email | ||
e, err := openpgp.NewEntity("name", "comment", "[email protected]", nil) | ||
require.NoError(t, err) | ||
k, err := parseGPGKey(db.DefaultContext, 1, e, true) | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, k.KeyID) | ||
assert.NotEmpty(t, k.Emails) // the key is valid, matches the email | ||
|
||
// then revoke the key | ||
for _, id := range e.Identities { | ||
id.Revocations = append(id.Revocations, &packet.Signature{RevocationReason: util.ToPointer(packet.KeyCompromised)}) | ||
} | ||
k, err = parseGPGKey(db.DefaultContext, 1, e, true) | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, k.KeyID) | ||
assert.Empty(t, k.Emails) // the key is revoked, matches no email | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,8 +134,7 @@ Note: This user hasn't uploaded any GPG keys. | |
=twTO | ||
-----END PGP PUBLIC KEY BLOCK----- | ||
`) | ||
-----END PGP PUBLIC KEY BLOCK-----`) | ||
// Import key | ||
// User1 <[email protected]> | ||
session := loginUser(t, "user1") | ||
|
@@ -169,8 +168,7 @@ C0TLXKur6NVYQMn01iyL+FZzRpEWNuYF3f9QeeLJ/+l2DafESNhNTy17+RPmacK6 | |
7XhJ1v6JYuh8kaYaEz8OpZDeh7f6Ho6PzJrsy/TKTKhGgZNINj1iaPFyOkQgKR5M | ||
GrE0MHOxUbc9tbtyk0F1SuzREUBH | ||
=DDXw | ||
-----END PGP PUBLIC KEY BLOCK----- | ||
`) | ||
-----END PGP PUBLIC KEY BLOCK-----`) | ||
// Export new key | ||
testExportUserGPGKeys(t, "user1", `-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
@@ -201,8 +199,7 @@ C0TLXKur6NVYQMn01iyL+FZzRpEWNuYF3f9QeeLJ/+l2DafESNhNTy17+RPmacK6 | |
7XhJ1v6JYuh8kaYaEz8OpZDeh7f6Ho6PzJrsy/TKTKhGgZNINj1iaPFyOkQgKR5M | ||
GrE0MHOxUbc9tbtyk0F1SuzREUBH | ||
=WFf5 | ||
-----END PGP PUBLIC KEY BLOCK----- | ||
`) | ||
-----END PGP PUBLIC KEY BLOCK-----`) | ||
} | ||
|
||
func testExportUserGPGKeys(t *testing.T, user, expected string) { | ||
|