0
$\begingroup$

I am using LibVLC and Unity to playback locally stored encrypted 360 videos. VLC's Unity package has a feature to play content via a C# stream. I am using a FileStream wrapped in a CryptoStream to get this working. This works for medium to small videos however, larger, high bitrate videos don't playback properly with my current implementation. The video plays for about 10 seconds before freezing, due to the cryptostreams decryption speed.

I am using the following code to create a decrypting CryptoStream which is passed to VLC. The path points to a properly encrypted file stored on device.

AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider();
FileStream crpytoFileStream = new FileStream(path, FileMode.Open);
CryptoStream cryptoStream = new CryptoStream(crpytoFileStream, aesCryptoServiceProvider.CreateDecryptor(Key, IV), CryptoStreamMode.Read);
BufferedStream bufferedStream = new BufferedStream(cryptoStream, bufferSize);

I am using AesCyptoServiceProvider because I know it is the faster cryptostream implementation. I have also tried some different padding, block sizes and other options however I haven't seen much improvement over the default options for AesCryptoServiceProvider.

I've done quite a bit of research and I haven't been able to find definite ways of speeding up the CryptoStream. I don't know if there is a better way to wrap my streams or if there is something I am overlooking. Any help is appreciated, thanks.

$\endgroup$
3
  • $\begingroup$ Welcome to Cryptography. The obvious questions are, which are not really related to Cryptography.SE, what is the system, CPU, RAM, Disk speed, is AES-NI exist, etc. $\endgroup$
    – kelalaka
    May 7, 2020 at 15:06
  • $\begingroup$ Thank you @kelalaka. Windows 10, i7 3770k, 16gb ram, Disk speed 520 MB/s, and this is not AES-NI. I've not used AES-NI encryption before. $\endgroup$ May 8, 2020 at 21:42
  • $\begingroup$ As I said, these information are all related to programming practices. If you add your code and performance etc, it might be a good SO question. Here, we are not accepting programming questions. $\endgroup$
    – kelalaka
    May 8, 2020 at 21:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.