public static DsaKey FromPrivateKeyInXml(string xmlPrivateKey) { using var provider = new DSACryptoServiceProvider(); provider.FromXmlString(xmlPrivateKey); return(DsaKey.CreateFromPrivateKey(provider.ToXmlString(true), provider.KeySize)); }
public static DsaKey CreateKey(AsymmetricKeyMode mode, int keySize = 1024) { using var provider = new DSACryptoServiceProvider(keySize); switch (mode) { case AsymmetricKeyMode.PublicKey: return(DsaKey.CreateFromPublicKey(provider.ToXmlString(false), provider.KeySize)); case AsymmetricKeyMode.PrivateKey: return(DsaKey.CreateFromPrivateKey(provider.ToXmlString(true), provider.KeySize)); case AsymmetricKeyMode.Both: return(DsaKey.Create( provider.ToXmlString(true), provider.ToXmlString(false), provider.KeySize)); default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } }
public static IDSA Create(DsaKey key) => Factory.Create(key);