public void SetKeyPair(Keypair kp, string password = null) { Exponent = kp.Exponent; Modulus = kp.Modulus; if (kp.IsPrivate && password == null) { throw new ArgumentException("Je potřeba heslo"); } if (kp.IsPrivate) { PrivateExponent = new BigInteger(kp.GetPrivateExponentAsync(password).Result); } }
public void SetKeyPair(Keypair kp, string password = null) { if (kp.IsPrivate && password == null) { throw new ArgumentException("Missing password"); } _rsa.ImportParameters(new RSAParameters { D = password == null ? null : kp.GetPrivateExponentAsync(password).Result, Exponent = kp.Exponent.ToByteArray(), Modulus = kp.Modulus.ToByteArray(), // TODO: find a better way, see Keypair#SystemAsymmetricEncryptionParameters P = kp.P, Q = kp.Q, DP = kp.DP, DQ = kp.DQ, InverseQ = kp.InverseQ }); }