break for cycle in getEncryptionKeyIDs (#74)
break cycle on literal/aead/encrypted/compressed packets
This commit is contained in:
parent
475db8b1cb
commit
af371097e0
1 changed files with 11 additions and 3 deletions
|
|
@ -228,14 +228,22 @@ func (msg *PGPMessage) getEncryptionKeyIDs() ([]uint64, bool) {
|
||||||
packets := packet.NewReader(bytes.NewReader(msg.Data))
|
packets := packet.NewReader(bytes.NewReader(msg.Data))
|
||||||
var err error
|
var err error
|
||||||
var ids []uint64
|
var ids []uint64
|
||||||
|
var encryptedKey *packet.EncryptedKey
|
||||||
|
Loop:
|
||||||
for {
|
for {
|
||||||
var p packet.Packet
|
var p packet.Packet
|
||||||
if p, err = packets.Next(); err == io.EOF {
|
if p, err = packets.Next(); err == io.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
enc, ok := p.(*packet.EncryptedKey)
|
switch p := p.(type) {
|
||||||
if ok {
|
case *packet.EncryptedKey:
|
||||||
ids = append(ids, enc.KeyId)
|
encryptedKey = p
|
||||||
|
ids = append(ids, encryptedKey.KeyId)
|
||||||
|
case *packet.SymmetricallyEncrypted,
|
||||||
|
*packet.AEADEncrypted,
|
||||||
|
*packet.Compressed,
|
||||||
|
*packet.LiteralData:
|
||||||
|
break Loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(ids) > 0 {
|
if len(ids) > 0 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue