public static byte[] ToCapiKeyBlob(AsymmetricAlgorithm keypair, bool includePrivateKey) { if (keypair == null) { throw new ArgumentNullException("keypair"); } if (keypair is RSA) { return(CryptoConvert.ToCapiKeyBlob((RSA)keypair, includePrivateKey)); } if (keypair is DSA) { return(CryptoConvert.ToCapiKeyBlob((DSA)keypair, includePrivateKey)); } return(null); }
public static byte[] ToCapiKeyBlob(AsymmetricAlgorithm keypair, bool includePrivateKey) { switch (keypair) { case null: throw new ArgumentNullException(nameof(keypair)); case RSA _: return(CryptoConvert.ToCapiKeyBlob((RSA)keypair, includePrivateKey)); case DSA _: return(CryptoConvert.ToCapiKeyBlob((DSA)keypair, includePrivateKey)); default: return((byte[])null); } }