예제 #1
0
  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }

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

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

    final ECPrivateKey other = (ECPrivateKey) o;
    if (!getPrivateKey().equals(other.getS())) {
      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();
  }
예제 #2
0
 public static OpenSSLKey getInstance(ECPrivateKey ecPrivateKey) throws InvalidKeyException {
   try {
     OpenSSLECGroupContext group = OpenSSLECGroupContext.getInstance(ecPrivateKey.getParams());
     final BigInteger privKey = ecPrivateKey.getS();
     return new OpenSSLKey(
         NativeCrypto.EVP_PKEY_new_EC_KEY(group.getContext(), 0, privKey.toByteArray()));
   } catch (Exception e) {
     throw new InvalidKeyException(e);
   }
 }
예제 #3
0
 public JCEECPrivateKey(ECPrivateKey key) {
   this.d = key.getS();
   this.algorithm = key.getAlgorithm();
   this.ecSpec = key.getParams();
 }