1 package org.bouncycastle.jce; 2 3 import java.util.Enumeration; 4 5 import org.bouncycastle.asn1.ASN1ObjectIdentifier; 6 import org.bouncycastle.asn1.x9.X9ECParameters; 7 import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec; 8 9 /** 10 * a table of locally supported named curves. 11 */ 12 public class ECNamedCurveTable 13 { 14 /** 15 * return a parameter spec representing the passed in named 16 * curve. The routine returns null if the curve is not present. 17 * 18 * @param name the name of the curve requested 19 * @return a parameter spec for the curve, null if it is not available. 20 */ getParameterSpec( String name)21 public static ECNamedCurveParameterSpec getParameterSpec( 22 String name) 23 { 24 X9ECParameters ecP = org.bouncycastle.crypto.ec.CustomNamedCurves.getByName(name); 25 if (ecP == null) 26 { 27 try 28 { 29 ecP = org.bouncycastle.crypto.ec.CustomNamedCurves.getByOID(new ASN1ObjectIdentifier(name)); 30 } 31 catch (IllegalArgumentException e) 32 { 33 // ignore - not an oid 34 } 35 36 if (ecP == null) 37 { 38 ecP = org.bouncycastle.asn1.x9.ECNamedCurveTable.getByName(name); 39 if (ecP == null) 40 { 41 try 42 { 43 ecP = org.bouncycastle.asn1.x9.ECNamedCurveTable.getByOID(new ASN1ObjectIdentifier(name)); 44 } 45 catch (IllegalArgumentException e) 46 { 47 // ignore - not an oid 48 } 49 } 50 } 51 } 52 53 if (ecP == null) 54 { 55 return null; 56 } 57 58 return new ECNamedCurveParameterSpec( 59 name, 60 ecP.getCurve(), 61 ecP.getG(), 62 ecP.getN(), 63 ecP.getH(), 64 ecP.getSeed()); 65 } 66 67 /** 68 * return an enumeration of the names of the available curves. 69 * 70 * @return an enumeration of the names of the available curves. 71 */ getNames()72 public static Enumeration getNames() 73 { 74 return org.bouncycastle.asn1.x9.ECNamedCurveTable.getNames(); 75 } 76 } 77