code: public static int writeSecurityBufferAndUpdatePointer(
              ByteArrayOutputStream baos, short len, int pointer)
              throws IOException {
          baos.write(writeSecurityBuffer(len, pointer));
          return pointer + len;
      }
docs: Writes a security buffer and returns the pointer of the position
  where to write the next security buffer.
  
  @param baos the stream where the security buffer is written
  @param len the length of the security buffer
  @param pointer the position where the security buffer can be written
  @return the position where the next security buffer will be written
  @throws IOException if writing to the ByteArrayOutputStream fails