code: byte[] convert(byte[] indefData) throws IOException {
          data = indefData;
          dataPos=0; index=0;
          dataSize = data.length;
          int len=0;
          int unused = 0;
  
          // parse and set up the vectors of all the indefinite-lengths
          while (dataPos < dataSize) {
              parseTag();
              len = parseLength();
              parseValue(len);
              if (unresolved == 0) {
                  unused = dataSize - dataPos;
                  dataSize = dataPos;
                  break;
              }
          }
  
          if (unresolved != 0) {
              throw new IOException("not all indef len BER resolved");
          }
  
          newData = new byte[dataSize + numOfTotalLenBytes + unused];
          dataPos=0; newDataPos=0; index=0;
  
          // write out the new byte array replacing all the indefinite-lengths
          // and EOCs
          while (dataPos < dataSize) {
             writeTag();
             writeLengthAndValue();
          }
          System.arraycopy(indefData, dataSize,
                           newData, dataSize + numOfTotalLenBytes, unused);
  
          return newData;
      }
docs: Converts a indefinite length DER encoded byte array to
  a definte length DER encoding.
  
  @param indefData the byte array holding the indefinite
  length encoding.
  @return the byte array containing the definite length
  DER encoding.
  @exception IOException on parsing or re-writing errors.