internal async Task SendInviteAsync(string name, byte[] preSharedKey, UserIdentity receiver) { if (_disposed) { throw new ObjectDisposedException(null); } try { var invite = new Invite { Name = name, PreSharedKey = preSharedKey, Sender = _publicIdentity }; var signedData = await CreateSignAndEncodeDataAsync(invite); var publicKey = PemUtils.GetKeyFromPem(receiver.PublicKey); var aesKey = CryptUtils.GenrateAesKey(); var encryptedAesKey = CryptUtils.RsaEncryptWithPublic(aesKey, publicKey); var encryptedData = CryptUtils.AesEncryptByteArray(signedData, aesKey); var packet = new InvitePacket(encryptedData, encryptedAesKey); await _networkHandler.SendPacketAsync(packet); } catch (Exception) when(_disposed) { } }