private static DecryptKeyType ParseType(string value)
 {
     try
     {
         return(DecryptKeyType.ToType(value));
     }
     catch (ArgumentException e)
     {
         throw new ParsingException($"Unknown type {value}", e);
     }
 }
        private void DecodeHeaders(IEnumerable <PemHeader> headers)
        {
            var mandatory = new List <string>
            {
                "SchemeVersion",
                "SchemeKeyVersion",
                "Type",
                "Recipient",
                "RecipientKeySetVersion"
            };


            foreach (var header in headers)
            {
                var name  = header.Name;
                var value = header.Value;

                mandatory.Remove(name);
                switch (name)
                {
                case "SchemeVersion":
                    schemeVersion = ParseVersion(name, value);
                    break;

                case "SchemeKeyVersion":
                    schemeKeyVersion = ParseVersion(name, value);
                    break;

                case "Type":
                    type = ParseType(value);
                    break;

                case "Recipient":
                    recipient = value;
                    break;

                case "RecipientKeySetVersion":
                    recipientKeySetVersion = ParseVersion(name, value);
                    break;
                }
            }

            if (mandatory.Any())
            {
                throw new ParsingException($"Missing headers: {mandatory}");
            }
        }