I'd like to see the exception stack trace.
What do you declare the byte array b to be? Do you allocate it?
read() returns the number of bytes read, or -1 if EOF.
You should use this value to control the number of bytes you write out or you will be writing garbage if the array isn't full. You should also use this value to control your loop. b[0] isn't going to tell you anything.
See the javadoc for
CypherInputStream for more info.