diff options
author | Michael Muré <batolettre@gmail.com> | 2023-08-12 14:05:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 14:05:02 +0200 |
commit | 20e62977a0509e2c79ef5d8d9173103a278b78ff (patch) | |
tree | 9a39ab11d0373caeaf34f2d06188c481d27f67d7 /entity/dag/operation_pack.go | |
parent | a0d225ce23af9f5dbe31521f19485c66d409e573 (diff) | |
parent | 429b913dc5519babfab47bf65222e32415a6c1bd (diff) | |
download | git-bug-20e62977a0509e2c79ef5d8d9173103a278b78ff.tar.gz |
Merge pull request #1088 from MichaelMure/dependabot/go_modules/github.com/99designs/gqlgen-0.17.36
build(deps): bump github.com/99designs/gqlgen from 0.17.20 to 0.17.36
Diffstat (limited to 'entity/dag/operation_pack.go')
-rw-r--r-- | entity/dag/operation_pack.go | 55 |
1 files changed, 7 insertions, 48 deletions
diff --git a/entity/dag/operation_pack.go b/entity/dag/operation_pack.go index c999ff23..3a871c12 100644 --- a/entity/dag/operation_pack.go +++ b/entity/dag/operation_pack.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/ProtonMail/go-crypto/openpgp" - "github.com/ProtonMail/go-crypto/openpgp/packet" "github.com/pkg/errors" "github.com/MichaelMure/git-bug/entities/identity" @@ -23,7 +22,7 @@ const createClockEntryPrefix = "create-clock-" const editClockEntryPrefix = "edit-clock-" // operationPack is a wrapper structure to store multiple operations in a single git blob. -// Additionally, it holds and store the metadata for those operations. +// Additionally, it holds and stores the metadata for those operations. type operationPack struct { // An identifier, taken from a hash of the serialized Operations. id entity.Id @@ -272,7 +271,12 @@ func readOperationPack(def Definition, repo repository.RepoData, resolvers entit // Verify signature if we expect one keys := author.ValidKeysAtTime(fmt.Sprintf(editClockPattern, def.Namespace), editTime) if len(keys) > 0 { - keyring := PGPKeyring(keys) + // this is a *very* convoluted and inefficient way to make OpenPGP accept to check a signature, but anything + // else goes against the grain and make it very unhappy. + keyring := openpgp.EntityList{} + for _, key := range keys { + keyring = append(keyring, key.PGPEntity()) + } _, err = openpgp.CheckDetachedSignature(keyring, commit.SignedData, commit.Signature, nil) if err != nil { return nil, fmt.Errorf("signature failure: %v", err) @@ -360,48 +364,3 @@ func unmarshallPack(def Definition, resolvers entity.Resolvers, data []byte) ([] return ops, author, nil } - -var _ openpgp.KeyRing = &PGPKeyring{} - -// PGPKeyring implement a openpgp.KeyRing from an slice of Key -type PGPKeyring []*identity.Key - -func (pk PGPKeyring) KeysById(id uint64) []openpgp.Key { - var result []openpgp.Key - for _, key := range pk { - if key.Public().KeyId == id { - result = append(result, openpgp.Key{ - PublicKey: key.Public(), - PrivateKey: key.Private(), - Entity: &openpgp.Entity{ - PrimaryKey: key.Public(), - PrivateKey: key.Private(), - Identities: map[string]*openpgp.Identity{ - "": {}, - }, - }, - SelfSignature: &packet.Signature{ - IsPrimaryId: func() *bool { b := true; return &b }(), - }, - }) - } - } - return result -} - -func (pk PGPKeyring) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key { - // the only usage we care about is the ability to sign, which all keys should already be capable of - return pk.KeysById(id) -} - -func (pk PGPKeyring) DecryptionKeys() []openpgp.Key { - // result := make([]openpgp.Key, len(pk)) - // for i, key := range pk { - // result[i] = openpgp.Key{ - // PublicKey: key.Public(), - // PrivateKey: key.Private(), - // } - // } - // return result - panic("not implemented") -} |