コード例 #1
0
        public static DsaKey FromPrivateKeyInXml(string xmlPrivateKey)
        {
            using var provider = new DSACryptoServiceProvider();

            provider.FromXmlString(xmlPrivateKey);

            return(DsaKey.CreateFromPrivateKey(provider.ToXmlString(true), provider.KeySize));
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: DSA.cs プロジェクト: cosmos-loops/cosmos-security
 public static IDSA Create(DsaKey key) => Factory.Create(key);