List of usage examples for org.bouncycastle.crypto.ec CustomNamedCurves getByOID
public static X9ECParameters getByOID(ASN1ObjectIdentifier oid)
From source file:dorkbox.util.serialization.EccPrivateKeySerializer.java
License:Apache License
static ECCurve deserializeCurve(Input input) throws KryoException { byte[] bytes; int length;//from ww w . jav a 2 s .c o m ECCurve curve; int serializationType = input.readInt(true); // lookup via name if (serializationType == usesName) { String curveName = input.readString(); X9ECParameters x9Curve = CustomNamedCurves.getByName(curveName); curve = x9Curve.getCurve(); } // this means we just lookup the curve via the OID else if (serializationType == usesOid) { String oid = input.readString(); X9ECParameters x9Curve = CustomNamedCurves.getByOID(new ASN1ObjectIdentifier(oid)); curve = x9Curve.getCurve(); } // we have to read in the entire curve information. else { ///////////// length = input.readInt(true); bytes = new byte[length]; input.readBytes(bytes, 0, length); BigInteger a = new BigInteger(bytes); ///////////// length = input.readInt(true); bytes = new byte[length]; input.readBytes(bytes, 0, length); BigInteger b = new BigInteger(bytes); ///////////// length = input.readInt(true); bytes = new byte[length]; input.readBytes(bytes, 0, length); BigInteger order = new BigInteger(bytes); ///////////// length = input.readInt(true); bytes = new byte[length]; input.readBytes(bytes, 0, length); BigInteger cofactor = new BigInteger(bytes); ///////////// length = input.readInt(true); bytes = new byte[length]; input.readBytes(bytes, 0, length); BigInteger q = new BigInteger(bytes); // coord system int coordinateSystem = input.readInt(true); curve = new ECCurve.Fp(q, a, b, order, cofactor); ecCurveAccess.setInt(curve, ecCoordIndex, coordinateSystem); } return curve; }