protected void decrypt(ByteBuffer buf,int offset,int len) throws IOException {
  final int pos=buf.position();
  final int limit=buf.limit();
  int n=0;
  while (n < len) {
    buf.position(offset + n);
    buf.limit(offset + n + Math.min(len - n,inBuffer.remaining()));
    inBuffer.put(buf);
    try {
      decrypt();
      buf.position(offset + n);
      buf.limit(limit);
      n+=outBuffer.remaining();
      buf.put(outBuffer);
    }
  finally {
      padding=postDecryption(streamOffset - (len - n));
    }
  }
  buf.position(pos);
}

protected void decrypt ( ByteBuffer buf , int offset , int len ) throws IOException { final int pos = buf . position ( ) ; final int limit = buf . limit ( ) ; int n = 0 ; while ( n < len ) { buf . position ( offset + n ) ; buf . limit ( offset + n + Math . min ( len - n , inBuffer . remaining ( ) ) ) ; inBuffer . put ( buf ) ; try { decrypt ( ) ; buf . position ( offset + n ) ; buf . limit ( limit ) ; n += outBuffer . remaining ( ) ; buf . put ( outBuffer ) ; } finally { padding = postDecryption ( streamOffset - ( len - n ) ) ; } } buf . position ( pos ) ; }
decrypts all data in buf : total n bytes from given start position . output is also buf and same start position . buf . position ( ) and buf . limit ( ) should be unchanged after decryption .
