Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 public void SignData04()
 {
     RSA rSA;
     byte[] bs;
     rSA = new RSA();
     bs = rSA.SignData(null, rSA.GetPrivateKey());
 }
Exemplo n.º 3
0
 public void SignData02()
 {
     RSA rSA;
     byte[] bs;
     rSA = new RSA();
     byte[] bs1 = new byte[0];
     bs = rSA.SignData(bs1, "");
 }
Exemplo n.º 4
0
 public void SignData03()
 {
     RSA rSA;
     byte[] bs;
     rSA = new RSA();
     byte[] bs1 = new byte[0];
     bs = rSA.SignData(bs1, (string)null);
 }
Exemplo n.º 5
0
 public void SignData01()
 {
     RSA rSA;
     byte[] bs;
     rSA = new RSA();
     byte[] bs1 = new byte[0];
     bs = rSA.SignData(bs1, "<invalidxml>");
 }