return result;
  protected PrivateKey engineGeneratePrivate(KeySpec keySpec)      throws InvalidKeySpecException  {    if (keySpec instanceof DHPrivateKeySpec)      {        DHPrivateKeySpec spec = (DHPrivateKeySpec) keySpec;        BigInteger p = spec.getP();        BigInteger g = spec.getG();        BigInteger x = spec.getX();        return new GnuDHPrivateKey(Registry.PKCS8_ENCODING_ID, null, p, g, x);      }    if (keySpec instanceof PKCS8EncodedKeySpec)      {        PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;        byte[] encoded = spec.getEncoded();        PrivateKey result;        try          {            result = new DHKeyPairPKCS8Codec().decodePrivateKey(encoded);          }        catch (RuntimeException x)          {            InvalidKeySpecException y = new InvalidKeySpecException();            y.initCause(x);            throw y;          }      }    throw new InvalidKeySpecException("Unsupported (private) key specification");  }