views:

37

answers:

0

Hello,

I am currently attempting to implement a solution to show encrypted video on Android (v1.6). The mp4 video is encrypted using AES/ECB/PKCS5Padding and then copied to the SD card. Since the decryption process is slow I have installed i-Jetty on the device and am setting my VideoView URI to be the localhost address of the servlet that implements the decryption - the theory being that the decryption process can be ongoing whilst the file is gradually streamed to, and played by, my application. Unfortunately the specification requires that decryption must happen local to the device - there cannot be a remote server.

The servlet implements a modified version of this Streamer class; at line 164 buf is simply replaced with cipher.doFinal(buf) where cipher is the cipher used to encrypt with but in Cipher.DECRYPT_MODE. Unfortunately the VideoView simply shows "Sorry, this video cannot be played" and the MediaPlayer onError handler returns Error(1, -1) where 1 is MEDIA_ERROR_UNKNOWN and -1 is undocumented.

Experimentation has so far revealed:

  • Using CipherInputStream in place of the BufferedInputStream does not work either
  • The unmodified Streamer class works correctly on an unencrypted file
  • An unencrypted file streams and plays correctly in the VideoView from a local URI i.e. localhost:8080/my_file.mp4
  • The file plays when I decrypt the file in my Android app (which takes way too long) and pass the VideoView the URI of the decrypted file
  • The file plays when the encrypted data is streamed from the servlet to my Android app where it is then decrypted, written to a file and the URI of the decrypted file is passed to the VideoView

Any help or clues would be greatly appreciated!

Cheers,

Gareth.