Add getEntity and getEcryptionKeyIDs functions to key and message types respectively (#55)
* add getEntity function to key struct * add getEncryptionKeyIDs * add chengelog + bool return in getEncryptionKeyIDs * fix description
This commit is contained in:
parent
d1f6f7d718
commit
8d42a53775
5 changed files with 64 additions and 0 deletions
|
|
@ -223,6 +223,27 @@ func (msg *PGPMessage) GetArmoredWithCustomHeaders(comment, version string) (str
|
|||
return armor.ArmorWithTypeAndCustomHeaders(msg.Data, constants.PGPMessageHeader, version, comment)
|
||||
}
|
||||
|
||||
// getEncryptionKeyIds Returns the key IDs of the keys to which the session key is encrypted.
|
||||
func (msg *PGPMessage) getEncryptionKeyIDs() ([]uint64, bool) {
|
||||
packets := packet.NewReader(bytes.NewReader(msg.Data))
|
||||
var err error
|
||||
var ids []uint64
|
||||
for {
|
||||
var p packet.Packet
|
||||
if p, err = packets.Next(); err == io.EOF {
|
||||
break
|
||||
}
|
||||
enc, ok := p.(*packet.EncryptedKey)
|
||||
if ok {
|
||||
ids = append(ids, enc.KeyId)
|
||||
}
|
||||
}
|
||||
if len(ids) > 0 {
|
||||
return ids, true
|
||||
}
|
||||
return ids, false
|
||||
}
|
||||
|
||||
// GetBinaryDataPacket returns the unarmored binary datapacket as a []byte.
|
||||
func (msg *PGPSplitMessage) GetBinaryDataPacket() []byte {
|
||||
return msg.DataPacket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue