code: public final SecretKey generateSecret(String algorithm)
          throws IllegalStateException, NoSuchAlgorithmException,
              InvalidKeyException
      {
          chooseFirstProvider();
          return spi.engineGenerateSecret(algorithm);
      }
docs: Creates the shared secret and returns it as a <code>SecretKey</code>
  object of the specified algorithm.
  
  <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 algorithm the requested secret-key algorithm
  
  @return the shared secret key
  
  @exception IllegalStateException if this key agreement has not been
  completed yet
  @exception NoSuchAlgorithmException if the specified secret-key
  algorithm is not available
  @exception InvalidKeyException if the shared secret-key material cannot
  be used to generate a secret key of the specified algorithm (e.g.,
  the key material is too short)