/// <summary>The public key contained in the object.</summary> /// <returns>A lightweight public key.</returns> /// <exception cref="PgpException">If the key algorithm is not recognised.</exception> private IAsymmetricPublicKey GetKey() { if (key != null) { return(key); } switch (keyPacket.Algorithm) { case PgpPublicKeyAlgorithm.RsaEncrypt: case PgpPublicKeyAlgorithm.RsaGeneral: case PgpPublicKeyAlgorithm.RsaSign: return(key = RsaKey.CreatePublic(keyPacket.KeyBytes, out var _)); case PgpPublicKeyAlgorithm.Dsa: return(key = DsaKey.CreatePublic(keyPacket.KeyBytes, out var _)); case PgpPublicKeyAlgorithm.ElGamalEncrypt: case PgpPublicKeyAlgorithm.ElGamalGeneral: return(key = ElGamalKey.CreatePublic(keyPacket.KeyBytes, out var _)); case PgpPublicKeyAlgorithm.ECDsa: return(key = ECDsaKey.CreatePublic(keyPacket.KeyBytes, out var _)); case PgpPublicKeyAlgorithm.ECDH: return(key = ECDiffieHellmanKey.CreatePublic(fingerprint, keyPacket.KeyBytes, out var _)); case PgpPublicKeyAlgorithm.EdDsa: return(key = EdDsaKey.CreatePublic(keyPacket.KeyBytes, out var _)); default: throw new PgpException("unknown public key algorithm encountered"); } }