} 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 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) { final DHParameterSpec dh1 = (DHParameterSpec) p1;
ECParameterSpec spec = (ECParameterSpec) type.getParams(); EllipticCurve curve = spec.getCurve(); ECPoint g = spec.getGenerator(); ECPoint w = ECUtil.scalarMult(g, s, curve); ECPublicKeySpec ecks = new ECPublicKeySpec(w, ecpriv.getParams());
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 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())) ); }
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); }
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()); }
protected void assertsEcdsaKey(ECPublicKey pubKey) { final String x = "48439561293906451759052585252797914202762949526041747995844080717082404635286"; final String y = "36134250956749795798585127919587881956611106672985015071877198253568414405109"; Assert.assertEquals(new BigInteger(x), pubKey.getParams().getGenerator().getAffineX()); Assert.assertEquals(new BigInteger(y), pubKey.getParams().getGenerator().getAffineY()); }
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()); }
protected void assertsEcdsaKey521(ECPublicKey pubKey) { final String x = "2661740802050217063228768716723360960729859168756973147706671368418802944" + "996427808491545080627771902352094241225065558662157113545570916814161637315895999846"; final String y = "3757180025770020463545507224491183603594455134769762486694567779615544477" + "440556316691234405012945539562144444537289428522585666729196580810124344277578376784"; Assert.assertEquals(new BigInteger(x), pubKey.getParams().getGenerator().getAffineX()); Assert.assertEquals(new BigInteger(y), pubKey.getParams().getGenerator().getAffineY()); }
protected void assertsEcdsaKey384(ECPublicKey pubKey) { final String x = "26247035095799689268623156744566981891852923491109213387815615900925" + "518854738050089022388053975719786650872476732087"; final String y = "83257109614890299855467512895201081792878530488613155947092059024805" + "03199884419224438643760392947333078086511627871"; Assert.assertEquals(new BigInteger(x), pubKey.getParams().getGenerator().getAffineX()); Assert.assertEquals(new BigInteger(y), pubKey.getParams().getGenerator().getAffineY()); }
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()); }