-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows Key Flags override, fixes #205
Added InsecureAllowAllKeyFlagsWhenMissing to packet.Config. Allows usage of keys without key flags.
- Loading branch information
Showing
3 changed files
with
105 additions
and
22 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -585,7 +585,6 @@ func TestKeyWithRevokedSubKey(t *testing.T) { | |
if len(subKey.Bindings) == 0 { | ||
t.Fatalf("no binding subkey signature") | ||
} | ||
|
||
} | ||
|
||
func TestSubkeyRevocation(t *testing.T) { | ||
|
@@ -683,7 +682,6 @@ func TestKeyWithSubKeyAndBadSelfSigOrder(t *testing.T) { | |
if lifetime := selfSig.KeyLifetimeSecs; lifetime != nil { | ||
t.Errorf("The signature has a key lifetime (%d), but it should be nil", *lifetime) | ||
} | ||
|
||
} | ||
|
||
func TestIdVerification(t *testing.T) { | ||
|
@@ -1063,6 +1061,7 @@ func TestAddUserId(t *testing.T) { | |
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestAddSubkey(t *testing.T) { | ||
entity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil) | ||
if err != nil { | ||
|
@@ -2022,3 +2021,57 @@ NciH07RTRuMS/aRhRg4OB8PQROmTnZ+iZS0= | |
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestAllowAllKeyFlagsWhenMissing(t *testing.T) { | ||
// Make a master key. | ||
entity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
config := &packet.Config{} | ||
|
||
primarySelfSignature, err := entity.VerifyPrimaryKey(time.Now(), config) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if !entity.PrimaryKey.PubKeyAlgo.CanEncrypt() || | ||
!entity.PrimaryKey.PubKeyAlgo.CanSign() { | ||
t.Fatal("PubKeyAlgo must be valid for signature and encryption") | ||
} | ||
|
||
/// Flags valid, but not set. | ||
primarySelfSignature.FlagsValid = true | ||
primarySelfSignature.FlagSign = false | ||
primarySelfSignature.FlagCertify = false | ||
primarySelfSignature.FlagEncryptCommunications = false | ||
|
||
if isValidSigningKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidSigningKey must be false") | ||
} | ||
|
||
if isValidEncryptionKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidEncryptionKey must be false") | ||
} | ||
|
||
if isValidCertificationKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidCertificationKey must be false") | ||
} | ||
|
||
/// Flags not valid, but InsecureAllowAllKeyFlagsWhenMissing set. | ||
primarySelfSignature.FlagsValid = false | ||
config = &packet.Config{InsecureAllowAllKeyFlagsWhenMissing: true} | ||
|
||
if !isValidSigningKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidSigningKey must be true when InsecureAllowAllKeyFlagsWhenMissing is true") | ||
} | ||
|
||
if !isValidEncryptionKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidEncryptionKey must be true when InsecureAllowAllKeyFlagsWhenMissing is true") | ||
} | ||
|
||
if !isValidCertificationKey(primarySelfSignature, entity.PrimaryKey.PubKeyAlgo, config) { | ||
t.Error("isValidCertificationKey must be true when InsecureAllowAllKeyFlagsWhenMissing is true") | ||
} | ||
} |