Refine search
private static int fieldSizeFromKey(ECKey ecPublicKey) { return ecPublicKey.getParams().getCurve().getField().getFieldSize(); } }
private static int getElementSize(EllipticCurve curve) { int fieldSize = curve.getField().getFieldSize(); return (fieldSize + 7) / 8; }
if (spec.getCurve().getField().getFieldSize() == P_256_SPEC.getCurve().getField().getFieldSize() && spec.getCurve().getA().equals(P_256_SPEC.getCurve().getA()) && spec.getCurve().getB().equals(P_256_SPEC.getCurve().getB()) && spec.getGenerator().getAffineX().equals(P_256_SPEC.getGenerator().getAffineX()) && } else if (spec.getCurve().getField().getFieldSize() == P_256K_SPEC.getCurve().getField().getFieldSize() && spec.getCurve().getA().equals(P_256K_SPEC.getCurve().getA()) && spec.getCurve().getB().equals(P_256K_SPEC.getCurve().getB()) && } else if (spec.getCurve().getField().getFieldSize() == P_384_SPEC.getCurve().getField().getFieldSize() && spec.getCurve().getA().equals(P_384_SPEC.getCurve().getA()) && spec.getCurve().getB().equals(P_384_SPEC.getCurve().getB()) && } else if (spec.getCurve().getField().getFieldSize() == P_521_SPEC.getCurve().getField().getFieldSize() && spec.getCurve().getA().equals(P_521_SPEC.getCurve().getA()) && spec.getCurve().getB().equals(P_521_SPEC.getCurve().getB()) &&
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; } }
int fieldSizeInBits = this.field.getFieldSize(); if (!(this.a.bitLength() <= fieldSizeInBits)) { throw new IllegalArgumentException("the a is not in the field");
private static int getElementSize(EllipticCurve curve) { int fieldSize = curve.getField().getFieldSize(); return (fieldSize + 7) / 8; }
public static void assertECFieldEquals(String message, ECField expected, ECField actual) { if (expected == actual) { return; } assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize()); }
static JsonObject getJwk(PublicKey publicKey, String algHeader) { if (publicKey instanceof RSAPublicKey) { RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey; return Json.createObjectBuilder() .add(EXPONENT, base64UrlEncode(rsaPublicKey.getPublicExponent().toByteArray())) .add(KEY_TYPE, "RSA") .add(MODULUS, base64UrlEncode(modulusToByteArray(rsaPublicKey.getModulus()))) .build(); } else if (publicKey instanceof ECPublicKey) { ECPublicKey ecPublicKey = (ECPublicKey) publicKey; int fieldSize = ecPublicKey.getParams().getCurve().getField().getFieldSize(); return Json.createObjectBuilder() .add(CURVE, getCurveParameterFromAlgHeader(algHeader)) .add(KEY_TYPE, "EC") .add(X_COORDINATE, base64UrlEncode(coordinateToByteArray(fieldSize, ecPublicKey.getW().getAffineX()))) .add(Y_COORDINATE, base64UrlEncode(coordinateToByteArray(fieldSize, ecPublicKey.getW().getAffineY()))) .build(); } else { throw acme.unsupportedAcmeAccountPublicKeyType(publicKey.getAlgorithm()); } }
private static ECPoint decodePoint(byte[] encodedPoint, EllipticCurve curve) { int elementSize = (curve.getField().getFieldSize() + 7) / 8; if (encodedPoint.length != 2 * elementSize + 1 || encodedPoint[0] != 0x04 || encodedPoint.length == 0) { return null; } byte[] xPoint = new byte[elementSize]; System.arraycopy(encodedPoint, 1, xPoint, 0, elementSize); byte[] yPoint = new byte[elementSize]; System.arraycopy(encodedPoint, 1 + elementSize, yPoint, 0, elementSize); return new ECPoint(new BigInteger(1, xPoint), new BigInteger(1, yPoint)); }
public static void assertECFieldEquals(String message, ECField expected, ECField actual) { if (expected == actual) { return; } assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize()); }
private static int getCurveSize(ECParameterSpec params) { return params.getCurve().getField().getFieldSize(); }
public static ECPoint fromByteArray(byte[] b, EllipticCurve curve) { int len = (curve.getField().getFieldSize() + 7) / 8; if (b.length != 2 * len + 1 || b[0] != 4) return null; byte[] x = new byte[len]; byte[] y = new byte[len]; System.arraycopy(b, 1, x, 0, len); System.arraycopy(b, len + 1, y, 0, len); return new ECPoint(new BigInteger(1,x), new BigInteger(1,y)); }
public static void assertECFieldEquals(String message, ECField expected, ECField actual) { if (expected == actual) { return; } assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize()); }
private static int getCurveSize(ECParameterSpec params) { return params.getCurve().getField().getFieldSize(); }
public static ECPoint decodePoint(byte[] encodedBytes, EllipticCurve elliptiCcurve) { if (encodedBytes[0] != 0x04) { throw new IllegalArgumentException("Only uncompressed format is supported"); } int size = (elliptiCcurve.getField().getFieldSize() + 7) / 8; byte affineXBytes[] = new byte[size]; byte affineYBytes[] = new byte[size]; System.arraycopy(encodedBytes, 1, affineXBytes, 0, size); System.arraycopy(encodedBytes, size + 1, affineYBytes, 0, size); return new ECPoint(new BigInteger(1, affineXBytes), new BigInteger(1, affineYBytes)); }
int fieldSizeInBits = this.field.getFieldSize(); if (!(this.a.bitLength() <= fieldSizeInBits)) { throw new IllegalArgumentException("the a is not in the field");
private static int getCurveSize(ECParameterSpec params) { return params.getCurve().getField().getFieldSize(); }
private static ECPoint decodePoint(byte[] data, EllipticCurve curve) throws IOException { if (data.length == 0 || data[0] != 4) { throw new IOException("Only uncompressed point format " + "supported"); } // Per ANSI X9.62, an encoded point is a 1 byte type followed by // ceiling(LOG base 2 field-size / 8) bytes of x and the same of y. int n = (data.length - 1) / 2; if (n != (curve.getField().getFieldSize() + 7) >> 3) { throw new IOException("Point does not match field size"); } byte[] xb = Arrays.copyOfRange(data, 1, 1 + n); byte[] yb = Arrays.copyOfRange(data, n + 1, n + 1 + n); return new ECPoint(new BigInteger(1, xb), new BigInteger(1, yb)); }
int fieldSizeInBits = this.field.getFieldSize(); if (!(this.a.bitLength() <= fieldSizeInBits)) { throw new IllegalArgumentException("the a is not in the field");
/** * @param params The curve's {@link ECParameterSpec} * @return The curve's key size in bits * @throws IllegalArgumentException if invalid parameters provided */ public static int getCurveSize(ECParameterSpec params) { EllipticCurve curve = Objects.requireNonNull(params, "No EC params").getCurve(); ECField field = Objects.requireNonNull(curve, "No EC curve").getField(); return Objects.requireNonNull(field, "No EC field").getFieldSize(); }