public void EncryptData01() { RSA rSA; string s; rSA = new RSA(); s = rSA.EncryptData("data", ""); }
public void ExtractExponent05() { string s; MLifter.Generics.RSA rsa = new MLifter.Generics.RSA(); string key = rsa.GetPublicKey(); s = Methods.ExtractExponent(key); Regex regex = new Regex(@"<Exponent>(?<exponent>.+)</Exponent>", RegexOptions.Multiline); Match m = regex.Match(key); string mod = String.Empty; if (!m.Success) { Assert.Fail("Could not match exponent!"); } else { mod = Methods.Base64ToHex(m.Groups["exponent"].Value); } Assert.AreEqual <string>(mod, s); }
public void ExtractPublicKey05() { string s; MLifter.Generics.RSA rsa = new MLifter.Generics.RSA(); string key = rsa.GetPublicKey(); s = Methods.ExtractPublicKey(key); Regex regex = new Regex(@"<Modulus>(?<modulus>.+)</Modulus>", RegexOptions.Multiline); Match m = regex.Match(key); string mod = String.Empty; if (!m.Success) { Assert.Fail("Could not match modulus!"); } else { mod = Methods.Base64ToHex(m.Groups["modulus"].Value); } Assert.AreEqual<string>(mod, s); }
public void EncryptData03() { RSA rSA; string s; rSA = new RSA(); s = rSA.EncryptData("data", (string)null); }
public void EncryptData02() { RSA rSA; string s; rSA = new RSA(); s = rSA.EncryptData("data", "<invalidxml>"); }
public void VerifyData05() { RSA rSA; rSA = new RSA(); byte[] bs = new byte[0]; byte[] bs1 = new byte[0]; byte[] bs2 = new byte[0]; rSA.VerifyData(bs, bs1, (byte[])null, bs2); }
public void TestSignAndVerify() { for (int i = 0; i < 100; i++) { RSA rSA; rSA = new RSA(); string data = TestInfrastructure.GetRandomString(TestInfrastructure.RandomGen.Next(1, 1000)); Encoding enc = Encoding.Unicode; byte[] signature = rSA.SignData(enc.GetBytes(data), rSA.GetPrivateKey()); byte[] mod = Methods.HexStringToByteArray(Methods.ExtractPublicKey(rSA.GetPublicKey())); byte[] exp = Methods.HexStringToByteArray(Methods.ExtractExponent(rSA.GetPublicKey())); rSA.VerifyData(enc.GetBytes(data), signature, mod, exp); } }
public void SignData04() { RSA rSA; byte[] bs; rSA = new RSA(); bs = rSA.SignData(null, rSA.GetPrivateKey()); }
public void SignData03() { RSA rSA; byte[] bs; rSA = new RSA(); byte[] bs1 = new byte[0]; bs = rSA.SignData(bs1, (string)null); }
public void SignData02() { RSA rSA; byte[] bs; rSA = new RSA(); byte[] bs1 = new byte[0]; bs = rSA.SignData(bs1, ""); }
public void SignData01() { RSA rSA; byte[] bs; rSA = new RSA(); byte[] bs1 = new byte[0]; bs = rSA.SignData(bs1, "<invalidxml>"); }
public void EncryptData04() { RSA rSA; string s; rSA = new RSA(); s = rSA.EncryptData(null, rSA.GetPrivateKey()); }