From f97aa17bb284562bd5dfeec9bfd3c09e887fb501 Mon Sep 17 00:00:00 2001
From: Shibly Meeran <shibme@shib.me>
Date: Tue, 23 Jan 2024 00:20:43 +0530
Subject: [PATCH] fixing issue with key parsing

---
 keys.go | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/keys.go b/keys.go
index 4eb5a59..b76a8c3 100644
--- a/keys.go
+++ b/keys.go
@@ -117,31 +117,29 @@ func ParsePublicKey(pubKeyBytes []byte) (*PublicKey, error) {
 		return nil, errInvalidPublicKey
 	}
 	keyType := pubKeyBytes[0]
-	switch keyType {
-	case keyTypeEccDirect | keyTypeEccPwd:
-		keyBytes := pubKeyBytes[1:]
-		var spec *kdfSpec
-		if keyType == keyTypeEccPwd {
-			specBytes := keyBytes[keyLength:]
-			var err error
-			if spec, err = parseKdfSpec(specBytes); err != nil {
-				return nil, err
-			}
-			keyBytes = keyBytes[:keyLength]
-		}
-		eccPubKey, err := ecc.GetPublicKey(keyBytes)
-		if err != nil {
+	if keyType != keyTypeEccDirect && keyType != keyTypeEccPwd {
+		return nil, errInvalidPublicKey
+	}
+	keyBytes := pubKeyBytes[1:]
+	var spec *kdfSpec
+	if keyType == keyTypeEccPwd {
+		specBytes := keyBytes[keyLength:]
+		var err error
+		if spec, err = parseKdfSpec(specBytes); err != nil {
 			return nil, err
 		}
-		publicKey := &PublicKey{
-			keyType:   keyType,
-			publicKey: eccPubKey,
-			spec:      spec,
-		}
-		return publicKey, nil
-	default:
-		return nil, errInvalidPublicKey
+		keyBytes = keyBytes[:keyLength]
+	}
+	eccPubKey, err := ecc.GetPublicKey(keyBytes)
+	if err != nil {
+		return nil, err
+	}
+	publicKey := &PublicKey{
+		keyType:   keyType,
+		publicKey: eccPubKey,
+		spec:      spec,
 	}
+	return publicKey, nil
 }
 
 func (publicKey *PublicKey) isPwdBased() bool {