code: public final int generateSecret(byte[] sharedSecret, int offset)
          throws IllegalStateException, ShortBufferException
      {
          chooseFirstProvider();
          return spi.engineGenerateSecret(sharedSecret, offset);
      }
docs: Generates the shared secret, and places it into the buffer
  <code>sharedSecret</code>, beginning at <code>offset</code> inclusive.
  
  <p>If the <code>sharedSecret</code> buffer is too small to hold the
  result, a <code>ShortBufferException</code> is thrown.
  In this case, this call should be repeated with a larger output buffer.
  
  <p>This method resets this <code>KeyAgreement</code> object, so that it
  can be reused for further key agreements. Unless this key agreement is
  reinitialized with one of the <code>init</code> methods, the same
  private information and algorithm parameters will be used for
  subsequent key agreements.
  
  @param sharedSecret the buffer for the shared secret
  @param offset the offset in <code>sharedSecret</code> where the
  shared secret will be stored
  
  @return the number of bytes placed into <code>sharedSecret</code>
  
  @exception IllegalStateException if this key agreement has not been
  completed yet
  @exception ShortBufferException if the given output buffer is too small
  to hold the secret