public void LoadXml_ValidXml(string xml, byte[] expectedModulus, byte[] expectedExponent) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); RsaKeyValue rsa = new RsaKeyValue(); rsa.LoadXml(xmlDocument.DocumentElement); Assert.Equal(expectedModulus, rsa.GetKey().Modulus.ToByteArrayUnsigned()); Assert.Equal(expectedExponent, rsa.GetKey().Exponent.ToByteArrayUnsigned()); }
public void Ctor_Rsa() { var keyGen = GeneratorUtilities.GetKeyPairGenerator("RSA"); keyGen.Init(new KeyGenerationParameters(new SecureRandom(), 1024)); var pair = keyGen.GenerateKeyPair(); RsaKeyValue rsaKeyValue = new RsaKeyValue((RsaKeyParameters)pair.Public); Assert.Equal(pair.Public, rsaKeyValue.GetKey()); }
public void Ctor_Rsa_Null() { RsaKeyValue rsaKeyValue = new RsaKeyValue(null); Assert.Null(rsaKeyValue.GetKey()); }
public void Ctor_Empty() { RsaKeyValue rsaKeyValue = new RsaKeyValue(); Assert.NotNull(rsaKeyValue.GetKey()); }