I have an aes encrypted mp3 file that I need to play in iOS; I can't decrypt the file to disk for security reasons, and I likely can't decrypt it to memory because of memory constraints.
Is there a way to play an encrypted file directly, or to stream it to the player without loading it all into memory? I am really at a loss with this one, I don't even know where to begin... I'm using AVAudioPlayer to play files, but I'm guessing it's not flexible enough to do what I want.
I don't know how AVAudioPlayer works, but the only way to solve this problem is to provide some sort of abstraction that the player can access. If the player can only access "file" objects, you are out of luck and must use another player. If the player can access an input stream of some sort (which I suspect it can), you can create a stream from the file (call it a "file stream"), and create a decryption stream from the file stream. You will have to understand AES encryption only in so far as you will need to use code that already exists (like crypto++) to create a decryption stream.
in psuedodcode, it would look something like this:
filestream fs = new filestream( path )
decryptionstream ds = decryptionstream( fs, decryptionkeydata )
AVAudioPlayer.open( ds );
AVAudioPlayer.play()
Internally, AVAudioPlayer will read chunks of data from the decryptionstream, which will pull data from the file stream, which will pull data from the file. Th data will be decrypted in the decryptionstream, one chunk at a time.