Esempio n. 1
0
        public void RSATest()
        {
            const string KEYBLOB_PATH = @"..\..\..\..\resources\.keyblob";

            const string RSA_PASSWORD = "******";
            const string MESSAGE      = "TestMessage";


            var rsaPassword = Encoding.Unicode.GetBytes(RSA_PASSWORD);

            RSA.GenerateAndStoreNewEncryptedKeyPair(KEYBLOB_PATH, rsaPassword);

            var rsa = RSA.GetStoredEncryptedKeyPair(KEYBLOB_PATH, rsaPassword);

            var message   = Encoding.Unicode.GetBytes(MESSAGE);
            var signature = RSA.CreateSignature(rsa.ExportRSAPrivateKey(), message);


            Assert.True(RSA.Verify(rsa.ExportRSAPublicKey(), message, signature));
        }
Esempio n. 2
0
 public Transmission(Message message, byte[] privKey, byte[] pubKey)
 {
     Message   = message;
     Signature = ByteString.CopyFrom(RSA.CreateSignature(privKey, Message.ToByteArray()));
     SenderID  = ByteString.CopyFrom(pubKey);
 }
Esempio n. 3
0
 public Transmission(Response response, byte[] privKey, byte[] pubKey)
 {
     Response  = response;
     Signature = ByteString.CopyFrom(RSA.CreateSignature(privKey, Response.ToByteArray()));
     SenderID  = ByteString.CopyFrom(pubKey);
 }
Esempio n. 4
0
 public Transmission(Request request, byte[] privKey, byte[] pubKey)
 {
     Request   = request;
     Signature = ByteString.CopyFrom(RSA.CreateSignature(privKey, Request.ToByteArray()));
     SenderID  = ByteString.CopyFrom(pubKey);
 }