public void TestCreateFromPublicRsaParameters() { var parametersEx = new RSAParametersEx(_publicRsaParameters); Assert.Equal(_rsaParameters.Modulus, parametersEx.Modulus); Assert.Equal(_rsaParameters.Exponent, parametersEx.Exponent); }
public void TestJsonSerializeDeserialize() { RSAParametersEx rsaParametersEx = _rsaParameters; var jsonString = JsonConvert.SerializeObject(rsaParametersEx); var deserialized = JsonConvert.DeserializeObject <RSAParametersEx>(jsonString); AssertRsaKeysEqual(rsaParametersEx, deserialized); }
public void TestPrivateKeyToStringAndParse() { RSAParametersEx rsaParametersEx = _rsaParameters; var s = rsaParametersEx.ToString(); Assert.NotNull(s); var rsaParameters = RSAParametersEx.Parse(s); AssertRsaKeysEqual(rsaParametersEx, rsaParameters); }
private static void AssertRsaKeysEqual(RSAParametersEx expected, RSAParametersEx actual) { Assert.Equal(expected.D, actual.D); Assert.Equal(expected.DP, actual.DP); Assert.Equal(expected.DQ, actual.DQ); Assert.Equal(expected.Exponent, actual.Exponent); Assert.Equal(expected.InverseQ, actual.InverseQ); Assert.Equal(expected.Modulus, actual.Modulus); Assert.Equal(expected.P, actual.P); Assert.Equal(expected.Q, actual.Q); }
public void TestCreateFromRsaParamaters() { var parametersEx = new RSAParametersEx(_rsaParameters); Assert.Equal(_rsaParameters.D, parametersEx.D); Assert.Equal(_rsaParameters.DP, parametersEx.DP); Assert.Equal(_rsaParameters.DQ, parametersEx.DQ); Assert.Equal(_rsaParameters.Exponent, parametersEx.Exponent); Assert.Equal(_rsaParameters.InverseQ, parametersEx.InverseQ); Assert.Equal(_rsaParameters.Modulus, parametersEx.Modulus); Assert.Equal(_rsaParameters.P, parametersEx.P); Assert.Equal(_rsaParameters.Q, parametersEx.Q); }
public void TestConvertToRSAParameters() { RSAParametersEx rsaParametersEx = _rsaParameters; var rsaParameters = rsaParametersEx.ToRSAParameters(); Assert.Equal(rsaParametersEx.D, rsaParameters.D); Assert.Equal(rsaParametersEx.DP, rsaParameters.DP); Assert.Equal(rsaParametersEx.DQ, rsaParameters.DQ); Assert.Equal(rsaParametersEx.Exponent, rsaParameters.Exponent); Assert.Equal(rsaParametersEx.InverseQ, rsaParameters.InverseQ); Assert.Equal(rsaParametersEx.Modulus, rsaParameters.Modulus); Assert.Equal(rsaParametersEx.P, rsaParameters.P); Assert.Equal(rsaParametersEx.Q, rsaParameters.Q); }
public void TestCreatePublicKey() { RSAParametersEx rsaParameters = _rsaParameters; var publicKey = rsaParameters.ToPublicKey(); Assert.Null(publicKey.D); Assert.Null(publicKey.DP); Assert.Null(publicKey.DQ); Assert.Null(publicKey.InverseQ); Assert.Null(publicKey.P); Assert.Null(publicKey.Q); Assert.NotNull(publicKey.Modulus); Assert.NotNull(publicKey.Exponent); }