Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream Decryption of Media files a chunk at a time #196

Closed
yawar-ali opened this issue May 4, 2016 · 11 comments
Closed

Stream Decryption of Media files a chunk at a time #196

yawar-ali opened this issue May 4, 2016 · 11 comments

Comments

@yawar-ali
Copy link

I have a mp4 video file which i am encrypting to save and decrypting to play via AVPlayer. Its working fine when i am decrypting whole file at once but my file is quite big and taking 100% CPU usage and lot of memory. So, I need to decrypt encrypted file in chunks.
I tried to decrypt file in chunks but its not playing video as AVPlayer is not recognizing decrypted chunk data maybe data is not stored sequentially while encrypting file. I have tried chacha20, AES, AES.CTR & AES.CBC protocols to encrypt and decrypt files but to no avail.

I need help regarding this issue, Kindly guide me to the right way to achieve this.

@rnapier
Copy link
Member

rnapier commented Sep 16, 2016

Sorry for the long lag responding. RNCryptor is not very well suited to encrypting video. See the FAQ "Does RNCryptor support random access decryption?". See also #161.

@rnapier rnapier closed this as completed Sep 16, 2016
@nishabe
Copy link

nishabe commented Jan 17, 2017

@SweetEvil , did you succeed in decrypting the file in chunks?

@yawar-ali
Copy link
Author

@nishabe Yes, I ended up using RabbitMQ encryption and decryption instead.

@walshahed
Copy link

@SweetEvil I'm trying to do the same thing, can you please provide an example on how to play encrypted video in chunks?

@yawar-ali
Copy link
Author

@walshahed Actually, I had to drop RNCryptor and did it by writing my own encryption with Rabbit Algorithm.
Provide me details what are you exactly want to achieve maybe I can point you to right direction ?

@walshahed
Copy link

@SweetEvil I have local encrypted mp4 file, I need to decrypt the file and play it using AVplayer but it takes long time to decrypt the whole file before playing

@dunhamsteve
Copy link

Just FYI - you can random-access decrypt with CBC (the readme seems to imply this is not possible). You just can't encrypt random access. And, of course, you miss out on the HMAC check.

Just read on a block boundary, and use the previous block as an "IV". (Or read a block ahead and throw out the first block.) In the past I've written a CGDataProvider that does this.

@rnapier
Copy link
Member

rnapier commented Nov 10, 2017

@dunhamsteve Thanks for adding the comment. There's already been some work down this road for RNCryptor (as a new format, not the existing RNCryptor format). Yes, the readme is misleading; it creates restrictions and breaks various other things, but it is possible.

@Platypus2
Copy link

Platypus2 commented Mar 10, 2018

I haven't looked at this in great detail yet, is it worth exploring or should I look into something else?

I think I understand the concept but the readme is misleading. Would this process not involve setting the IV manually (which the readme essentially says don't/can't)? If that is the case I take it, it would require modification to the code to allow this?

@rnapier
Copy link
Member

rnapier commented Mar 10, 2018

This absolutely would require large code changes. It won’t be made part of RNCryptor; it would be a new format.

@Platypus2
Copy link

Thanks for the response, I’ll see if I can find some other way of doing it then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants