ECParameterSpec getECParameterSpec() { final String curveName = NativeCrypto.EC_GROUP_get_curve_name(groupCtx); final byte[][] curveParams = NativeCrypto.EC_GROUP_get_curve(groupCtx); final BigInteger p = new BigInteger(curveParams[0]); final BigInteger a = new BigInteger(curveParams[1]); final BigInteger b = new BigInteger(curveParams[2]); final ECField field = new ECFieldFp(p); final EllipticCurve curve = new EllipticCurve(field, a, b); final OpenSSLECPointContext generatorCtx = new OpenSSLECPointContext(this, new NativeRef.EC_POINT(NativeCrypto.EC_GROUP_get_generator(groupCtx))); final ECPoint generator = generatorCtx.getECPoint(); final BigInteger order = new BigInteger(NativeCrypto.EC_GROUP_get_order(groupCtx)); final BigInteger cofactor = new BigInteger(NativeCrypto.EC_GROUP_get_cofactor(groupCtx)); ECParameterSpec spec = new ECParameterSpec(curve, generator, order, cofactor.intValue()); Platform.setCurveName(spec, curveName); return spec; } }
ECParameterSpec getECParameterSpec() { final String curveName = NativeCrypto.EC_GROUP_get_curve_name(groupCtx); final byte[][] curveParams = NativeCrypto.EC_GROUP_get_curve(groupCtx); final BigInteger p = new BigInteger(curveParams[0]); final BigInteger a = new BigInteger(curveParams[1]); final BigInteger b = new BigInteger(curveParams[2]); final ECField field = new ECFieldFp(p); final EllipticCurve curve = new EllipticCurve(field, a, b); final OpenSSLECPointContext generatorCtx = new OpenSSLECPointContext(this, new NativeRef.EC_POINT(NativeCrypto.EC_GROUP_get_generator(groupCtx))); final ECPoint generator = generatorCtx.getECPoint(); final BigInteger order = new BigInteger(NativeCrypto.EC_GROUP_get_order(groupCtx)); final BigInteger cofactor = new BigInteger(NativeCrypto.EC_GROUP_get_cofactor(groupCtx)); ECParameterSpec spec = new ECParameterSpec(curve, generator, order, cofactor.intValue()); Platform.setCurveName(spec, curveName); return spec; } }
static OpenSSLECPointContext getInstance(OpenSSLECGroupContext group, ECPoint javaPoint) { OpenSSLECPointContext point = new OpenSSLECPointContext(group, new NativeRef.EC_POINT( NativeCrypto.EC_POINT_new(group.getNativeRef()))); NativeCrypto.EC_POINT_set_affine_coordinates(group.getNativeRef(), point.getNativeRef(), javaPoint.getAffineX().toByteArray(), javaPoint.getAffineY().toByteArray()); return point; } }
static OpenSSLECPointContext getInstance(OpenSSLECGroupContext group, ECPoint javaPoint) { OpenSSLECPointContext point = new OpenSSLECPointContext(group, new NativeRef.EC_POINT( NativeCrypto.EC_POINT_new(group.getNativeRef()))); NativeCrypto.EC_POINT_set_affine_coordinates(group.getNativeRef(), point.getNativeRef(), javaPoint.getAffineX().toByteArray(), javaPoint.getAffineY().toByteArray()); return point; } }
private ECPoint getPublicKey() { final OpenSSLECPointContext pubKey = new OpenSSLECPointContext(group, new NativeRef.EC_POINT(NativeCrypto.EC_KEY_get_public_key(key.getNativeRef()))); return pubKey.getECPoint(); }
private ECPoint getPublicKey() { final OpenSSLECPointContext pubKey = new OpenSSLECPointContext(group, new NativeRef.EC_POINT(NativeCrypto.EC_KEY_get_public_key(key.getNativeRef()))); return pubKey.getECPoint(); }