/** * TODO want to figure out why BouncyCastle does not work. * @return The initialized curve25519 parameter spec */ public static AlgorithmParameterSpec getCurve25519Params() { X9ECParameters ecP = CustomNamedCurves.getByName("curve25519"); return new ECParameterSpec(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed()); } }
/** Decompress a compressed public key (x co-ord and low-bit of y-coord). */ private static ECPoint decompressKey(BigInteger xBN, boolean yBit) { X9IntegerConverter x9 = new X9IntegerConverter(); byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve())); compEnc[0] = (byte)(yBit ? 0x03 : 0x02); return CURVE.getCurve().decodePoint(compEnc); }
private PrivateKey createECDSAPrivateKey(KeyType kt, PlainBuffer buffer, String name) throws GeneralSecurityException, Buffer.BufferException { kt.readPubKeyFromBuffer(buffer); // Public key BigInteger s = new BigInteger(1, buffer.readBytes()); X9ECParameters ecParams = NISTNamedCurves.getByName(name); ECNamedCurveSpec ecCurveSpec = new ECNamedCurveSpec(name, ecParams.getCurve(), ecParams.getG(), ecParams.getN()); ECPrivateKeySpec pks = new ECPrivateKeySpec(s, ecCurveSpec); return SecurityUtils.getKeyFactory("ECDSA").generatePrivate(pks); } }
ECPoint decodePoint(byte[] data) { ECCurve curve = ECNamedCurveTable.getByName(curveName).getCurve(); int compactExportSize = (curve.getFieldSize() + 7) / 8; return data.length == compactExportSize ? ECPointsCompact.decodeFPPoint(curve, data) // Compact keys support, non RFC6636 compliant. : curve.decodePoint(data); }
public synchronized X9ECParameters getParameters() { if (params == null) { params = createParameters(); } return params; }
public X9Curve( ECCurve curve) { this.curve = curve; this.seed = null; setFieldIdentifier(); }
public X9ECParameters( ECCurve curve, ECPoint g, BigInteger n, BigInteger h, byte[] seed) { this(curve, new X9ECPoint(g), n, h, seed); }
public ECPoint getG() { return g.getPoint(); }
/** * Return the ASN.1 entry representing the Curve. * * @return the X9Curve for the curve in these parameters. */ public X9Curve getCurveEntry() { return new X9Curve(curve, seed); }
X9ECParameters params = ECNamedCurveTable.getByName(lcurveName);
public X962Parameters( X9ECParameters ecParameters) { this.params = ecParameters.toASN1Primitive(); }
public static String getCurveName( ASN1ObjectIdentifier oid) { return ECNamedCurveTable.getName(oid); }
/** * return an enumeration of the names of the available curves. * * @return an enumeration of the names of the available curves. */ public static Enumeration getNames() { return org.bouncycastle.asn1.x9.ECNamedCurveTable.getNames(); } }
ecParam = ECNamedCurveTable.getByOID(ecOID); if (ecParam == null) { throw new PEMException("Unable to find EC Parameter for the given curve oid: " + ecOID.getId()); ECParameterSpec ecSpec = new ECParameterSpec(ecParam.getCurve(), ecParam.getG(), ecParam.getN(), ecParam.getH(), ecParam.getSeed()); KeyFactory keyFactory = KeyFactory.getInstance(ECDSA, BouncyCastleProvider.PROVIDER_NAME); ECPrivateKeySpec keySpec = new ECPrivateKeySpec(((BCECPrivateKey) privateKey).getS(), ecSpec);
public X9ECParameters getParameters() { if (params == null) { params = createParameters(); } return params; }
public X9Curve( ECCurve curve, byte[] seed) { this.curve = curve; this.seed = seed; setFieldIdentifier(); }
public X962Parameters( X9ECParameters ecParameters) { this.params = ecParameters.toASN1Primitive(); }
ecParam = ECNamedCurveTable.getByOID(ecOID); if (ecParam == null) { throw new PEMException("Unable to find EC Parameter for the given curve oid: " ECParameterSpec ecSpec = new ECParameterSpec(ecParam.getCurve(), ecParam.getG(), ecParam.getN(), ecParam.getH(), ecParam.getSeed()); KeyFactory keyFactory = KeyFactory.getInstance(ECDSA, BouncyCastleProvider.PROVIDER_NAME); ECPublicKeySpec keySpec = new ECPublicKeySpec(((BCECPublicKey) publicKey).getQ(), ecSpec);