This is both a performance and security question that I'm looking for efficient and long term security with large file pushing over the internet.

My scenario is as follows. - Server receives a large amount of data (20mb+) from a growing number of clients. This is over a TLS API service publicly exposed. - Im worried about a MITM attack which could obtain said files.

Q: How would one encrypt and decrypt large files/sections without breaking performance on both ends? Is there an efficient method or Better practice in transmitting the data without increasing their size to heavily?

Note: My grandpa said homing pigeons worked well in the past

  • Are you concerned about a MiTM attack while using TLS? Jan 26 '16 at 17:05
  • There is always chances where a client will accept an invalid certificate and cause the data to be breached. I was more focussed on encryption performance for large files in this case :)
    – Matosha
    Jan 27 '16 at 8:03

TLS provides various ciphers, some are more optimized for hardware (like AES based ciphers) and some for software (like ChaCha20-Poly1305). Thus proper choice of the cipher can reduce the overhead needed for encryption. And use of these ciphers only marginally increases the size of the transferred data.

The other part of performance problem is the initial TLS handshake. But since your API is already TLS anyway you could just reuse the TLS session and thus save both time (less handshakes) and power (less heavy computations).

Another way would be to shift the performance problem by transferring pre-encrypted files. In this case you don't need to securely transmit the full data but only the small encryption key. The bulk of the data could then be transferred using an insecure transport protocol, like pigeons. If this is a better idea in your case highly depends on the unknown details of your actual use case.


If you want to prevent MITM attacks, you have to check the server certificate on the client! Include the certificate or a CA certificate issuing your server certificate(s) with the client and check it when establishing the TLS connection.

TLS with sensible configuration (see BetterCrypto.org) is secure. You just have to get the authentication right.

edit: After clarification that OP is more concerned about performance: I answered something similar at crypto.stackexchange.com (where this also would be a better fit) and that is still valid. If your hardware has AES support, use that. If not, look what people with bigger budgets for research and a similar problem do. Google uses the ChaCha20 stream cipher with Poly1305 MAC in Chrome if there is no hardware AES support and AES if there is hardware support.

On almost any halfway modern hardware, encryption speed will be a lot faster than a typical internet connection and so is of no concern. File size increase is neglectable.

  • I don't think that the OP is concerned about finding a secure means of communicating the data. I think the question is about understanding the performance/security trade offs for various encryption strategies. Jan 26 '16 at 17:03
  • I don't know how else one could understand "Im worried about a MITM attack which could obtain said files." Jan 27 '16 at 6:50
  • Sorry for bit being clear. They are worried about secure and performant communication, not just secure. Jan 27 '16 at 14:37
  • Ahh. I asked the OP a question and they clarified their intent. Jan 27 '16 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.