public void GenerateKeyPair(byte[] seed) { privateKey = BluemeshEncryptor.GeneratePrivateKey(seed); publicKey = BluemeshEncryptor.GeneratePublicKey(privateKey); lock (peerKeys) peerKeys[serverEndpoint] = publicKey; }
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); }
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); }
public void DecryptData(byte[] data, int offset, int length) { BluemeshEncryptor.EncryptBytes(data, offset, length % 8 == 0 ? length : length + (8 - length % 8), privateKey); }
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)); }