} else if (param instanceof ECParameterSpec) { final ECParameterSpec ecSpec = (ECParameterSpec) param; return ecSpec.getCofactor() * 31 + Objects.hash(ecSpec.getCurve(), ecSpec.getGenerator(), ecSpec.getOrder()); } else if (param instanceof DHParameterSpec) { final DHParameterSpec dhSpec = (DHParameterSpec) param;
final ECParameterSpec ec1 = (ECParameterSpec) p1; final ECParameterSpec ec2 = (ECParameterSpec) p2; return ec1.getCofactor() == ec2.getCofactor() && Objects.equals(ec1.getCurve(), ec2.getCurve()) && Objects.equals(ec1.getGenerator(), ec2.getGenerator()) && Objects.equals(ec1.getOrder(), ec2.getOrder()); } else if (p1 instanceof DHParameterSpec && p2 instanceof DHParameterSpec) {
public static boolean compareECParams(ECParameterSpec s1, ECParameterSpec s2) { if (Objects.equals(s1, s2)) { return true; } else if (s1 == null || s2 == null) { return false; // both null is covered by Objects#equals } else { return Objects.equals(s1.getOrder(), s2.getOrder()) && (s1.getCofactor() == s2.getCofactor()) && Objects.equals(s1.getGenerator(), s2.getGenerator()) && Objects.equals(s1.getCurve(), s2.getCurve()); } } }
public static boolean compareECParams(ECParameterSpec s1, ECParameterSpec s2) { if (Objects.equals(s1, s2)) { return true; } else if (s1 == null || s2 == null) { return false; // both null is covered by Objects#equals } else { return Objects.equals(s1.getOrder(), s2.getOrder()) && (s1.getCofactor() == s2.getCofactor()) && Objects.equals(s1.getGenerator(), s2.getGenerator()) && Objects.equals(s1.getCurve(), s2.getCurve()); } } }
public static boolean compareECParams(ECParameterSpec s1, ECParameterSpec s2) { if (Objects.equals(s1, s2)) { return true; } else if (s1 == null || s2 == null) { return false; // both null is covered by Objects#equals } else { return Objects.equals(s1.getOrder(), s2.getOrder()) && (s1.getCofactor() == s2.getCofactor()) && Objects.equals(s1.getGenerator(), s2.getGenerator()) && Objects.equals(s1.getCurve(), s2.getCurve()); } } }
private DSTU4145ParameterSpec(ECDomainParameters parameters, ECParameterSpec ecParameterSpec, byte[] dke) { super(ecParameterSpec.getCurve(), ecParameterSpec.getGenerator(), ecParameterSpec.getOrder(), ecParameterSpec.getCofactor()); this.parameters = parameters; this.dke = Arrays.clone(dke); }
private static boolean isP256(ECParameterSpec params) { ECNamedCurveParameterSpec p256 = ECNamedCurveTable.getParameterSpec("P-256"); return (Objects.equals(p256.getN(), params.getOrder()) && Objects.equals(p256.getG().getAffineXCoord().toBigInteger(), params.getGenerator().getAffineX()) && Objects.equals(p256.getG().getAffineYCoord().toBigInteger(), params.getGenerator().getAffineY()) && Objects.equals(p256.getH(), BigInteger.valueOf(params.getCofactor())) ); }
protected ECKeyGenerationParameters createKeyGenParamsJCE(java.security.spec.ECParameterSpec p, SecureRandom r) { ECCurve curve = EC5Util.convertCurve(p.getCurve()); ECPoint g = EC5Util.convertPoint(curve, p.getGenerator(), false); BigInteger n = p.getOrder(); BigInteger h = BigInteger.valueOf(p.getCofactor()); ECDomainParameters dp = new ECDomainParameters(curve, g, n, h); return new ECKeyGenerationParameters(dp, r); }
protected ECKeyGenerationParameters createKeyGenParamsJCE(java.security.spec.ECParameterSpec p, SecureRandom r) { ECCurve curve = EC5Util.convertCurve(p.getCurve()); ECPoint g = EC5Util.convertPoint(curve, p.getGenerator(), false); BigInteger n = p.getOrder(); BigInteger h = BigInteger.valueOf(p.getCofactor()); ECDomainParameters dp = new ECDomainParameters(curve, g, n, h); return new ECKeyGenerationParameters(dp, r); }
protected ECKeyGenerationParameters createKeyGenParamsJCE(java.security.spec.ECParameterSpec p, SecureRandom r) { ECCurve curve = EC5Util.convertCurve(p.getCurve()); ECPoint g = EC5Util.convertPoint(curve, p.getGenerator(), false); BigInteger n = p.getOrder(); BigInteger h = BigInteger.valueOf(p.getCofactor()); ECDomainParameters dp = new ECDomainParameters(curve, g, n, h); return new ECKeyGenerationParameters(dp, r); }
public static org.spongycastle.jce.spec.ECParameterSpec convertSpec( ECParameterSpec ecSpec, boolean withCompression) { ECCurve curve = convertCurve(ecSpec.getCurve()); return new org.spongycastle.jce.spec.ECParameterSpec( curve, convertPoint(curve, ecSpec.getGenerator(), withCompression), ecSpec.getOrder(), BigInteger.valueOf(ecSpec.getCofactor()), ecSpec.getCurve().getSeed()); }
public static com.bugvm.bouncycastle.jce.spec.ECParameterSpec convertSpec( ECParameterSpec ecSpec, boolean withCompression) { ECCurve curve = convertCurve(ecSpec.getCurve()); return new com.bugvm.bouncycastle.jce.spec.ECParameterSpec( curve, convertPoint(curve, ecSpec.getGenerator(), withCompression), ecSpec.getOrder(), BigInteger.valueOf(ecSpec.getCofactor()), ecSpec.getCurve().getSeed()); }
public static org.ripple.bouncycastle.jce.spec.ECParameterSpec convertSpec( ECParameterSpec ecSpec, boolean withCompression) { ECCurve curve = convertCurve(ecSpec.getCurve()); return new org.ripple.bouncycastle.jce.spec.ECParameterSpec( curve, convertPoint(curve, ecSpec.getGenerator(), withCompression), ecSpec.getOrder(), BigInteger.valueOf(ecSpec.getCofactor()), ecSpec.getCurve().getSeed()); }
public static com.bugvm.bouncycastle.jce.spec.ECParameterSpec convertSpec( ECParameterSpec ecSpec, boolean withCompression) { ECCurve curve = convertCurve(ecSpec.getCurve()); return new com.bugvm.bouncycastle.jce.spec.ECParameterSpec( curve, convertPoint(curve, ecSpec.getGenerator(), withCompression), ecSpec.getOrder(), BigInteger.valueOf(ecSpec.getCofactor()), ecSpec.getCurve().getSeed()); }
public static org.spongycastle.jce.spec.ECParameterSpec convertSpec( ECParameterSpec ecSpec, boolean withCompression) { ECCurve curve = convertCurve(ecSpec.getCurve()); return new org.spongycastle.jce.spec.ECParameterSpec( curve, convertPoint(curve, ecSpec.getGenerator(), withCompression), ecSpec.getOrder(), BigInteger.valueOf(ecSpec.getCofactor()), ecSpec.getCurve().getSeed()); }
private static void validateEcCurves(ECPublicKey publicKey, ECPrivateKey privateKey) throws JOSEException { final ECParameterSpec pubParams = publicKey.getParams(); final ECParameterSpec privParams = privateKey.getParams(); if (!pubParams.getCurve().equals(privParams.getCurve())) { throw new JOSEException("Public/private EC key curve mismatch: " + publicKey); } if (pubParams.getCofactor() != privParams.getCofactor()) { throw new JOSEException("Public/private EC key cofactor mismatch: " + publicKey); } if (!pubParams.getGenerator().equals(privParams.getGenerator())) { throw new JOSEException("Public/private EC key generator mismatch: " + publicKey); } if (!pubParams.getOrder().equals(privParams.getOrder())) { throw new JOSEException("Public/private EC key order mismatch: " + publicKey); } }
private static boolean matchCurve(ECParameterSpec params, Curve curve) { int fieldSize = params.getCurve().getField().getFieldSize(); if (curve.getCurve().getField().getFieldSize() == fieldSize && curve.getCurve().equals(params.getCurve()) && curve.getGenerator().equals(params.getGenerator()) && curve.getOrder().equals(params.getOrder()) && curve.getCofactor() == params.getCofactor()) { return true; } else { return false; } }
public static void assertECParameterSpecEquals(String message, ECParameterSpec expected, ECParameterSpec actual) { if (expected == actual) { return; } assertEquals(message + "[order]", expected.getOrder(), actual.getOrder()); assertEquals(message + "[cofactor]", expected.getCofactor(), actual.getCofactor()); assertECPointEquals(message + "[generator]", expected.getGenerator(), actual.getGenerator()); assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve()); }
public static void assertECParameterSpecEquals(String message, ECParameterSpec expected, ECParameterSpec actual) { if (expected == actual) { return; } assertEquals(message + "[order]", expected.getOrder(), actual.getOrder()); assertEquals(message + "[cofactor]", expected.getCofactor(), actual.getCofactor()); assertECPointEquals(message + "[generator]", expected.getGenerator(), actual.getGenerator()); assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve()); }
public static void assertECParameterSpecEquals(String message, ECParameterSpec expected, ECParameterSpec actual) { if (expected == actual) { return; } assertEquals(message + "[order]", expected.getOrder(), actual.getOrder()); assertEquals(message + "[cofactor]", expected.getCofactor(), actual.getCofactor()); assertECPointEquals(message + "[generator]", expected.getGenerator(), actual.getGenerator()); assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve()); }