예제 #1
0
 public void GenerateKeyPair(byte[] seed)
 {
     privateKey = BluemeshEncryptor.GeneratePrivateKey(seed);
     publicKey  = BluemeshEncryptor.GeneratePublicKey(privateKey);
     lock (peerKeys)
         peerKeys[serverEndpoint] = publicKey;
 }
예제 #2
0
 public void ProcessAfterReceive(MessageType messageType, byte[] buffer, int offset, int length)
 {
     if (messageType != MessageType.Data && messageType != MessageType.Redirect)
     {
         return;
     }
     Console.WriteLine("Decoded message of type {0} with key {1}", messageType, privateKey);
     BluemeshEncryptor.EncryptBytes(buffer, offset,
                                    length % 8 == 0 ? length : length + (8 - length % 8), privateKey);
 }
예제 #3
0
        public void ProcessBeforeSend(MessageType messageType, byte[] buffer, int offset, int length)
        {
            if (messageType != MessageType.Data && messageType != MessageType.Redirect)
            {
                return;
            }
            var publicKey = publicKeyProvider();

            Console.WriteLine("Encoded message of type {0} with key {1}", messageType, publicKey);
            BluemeshEncryptor.EncryptBytes(buffer, offset,
                                           length % 8 == 0 ? length : length + (8 - length % 8), publicKey);
        }
예제 #4
0
 public void DecryptData(byte[] data, int offset, int length)
 {
     BluemeshEncryptor.EncryptBytes(data, offset, length % 8 == 0 ? length : length + (8 - length % 8), privateKey);
 }
예제 #5
0
 public void EncryptData(byte[] data, int offset, int length, IAddress peer)
 {
     BluemeshEncryptor.EncryptBytes(data, offset, length % 8 == 0 ? length : length + (8 - length % 8), GetPublicKey(peer));
 }