From fea64f7572b810f5d1f32b4b5edb0c02bcf28164 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Mon, 19 Jun 2023 16:29:10 +0200 Subject: [PATCH] Fix panic when parsing empty EdDSA public key --- openpgp/packet/public_key.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openpgp/packet/public_key.go b/openpgp/packet/public_key.go index ec903ee9..3402b8c1 100644 --- a/openpgp/packet/public_key.go +++ b/openpgp/packet/public_key.go @@ -415,6 +415,10 @@ func (pk *PublicKey) parseEdDSA(r io.Reader) (err error) { return } + if len(pk.p.Bytes()) == 0 { + return errors.StructuralError("empty EdDSA public key") + } + pub := eddsa.NewPublicKey(c) switch flag := pk.p.Bytes()[0]; flag {