@Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }

    if (o instanceof OpenSSLECPublicKey) {
      OpenSSLECPublicKey other = (OpenSSLECPublicKey) o;
      return key.equals(other.key);
    }

    if (!(o instanceof ECPublicKey)) {
      return false;
    }

    final ECPublicKey other = (ECPublicKey) o;
    if (!getPublicKey().equals(other.getW())) {
      return false;
    }

    final ECParameterSpec spec = getParams();
    final ECParameterSpec otherSpec = other.getParams();

    return spec.getCurve().equals(otherSpec.getCurve())
        && spec.getGenerator().equals(otherSpec.getGenerator())
        && spec.getOrder().equals(otherSpec.getOrder())
        && spec.getCofactor() == otherSpec.getCofactor();
  }
Exemplo n.º 2
0
  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }

    if (o instanceof OpenSSLRSAPublicKey) {
      OpenSSLRSAPublicKey other = (OpenSSLRSAPublicKey) o;

      /*
       * We can shortcut the true case, but it still may be equivalent but
       * different copies.
       */
      if (key.equals(other.getOpenSSLKey())) {
        return true;
      }
    }

    if (!(o instanceof RSAPublicKey)) {
      return false;
    }

    ensureReadParams();

    RSAPublicKey other = (RSAPublicKey) o;
    return modulus.equals(other.getModulus()) && publicExponent.equals(other.getPublicExponent());
  }