1package org.bouncycastle.asn1.x9; 2 3import java.util.Enumeration; 4import java.util.Vector; 5 6import org.bouncycastle.asn1.ASN1ObjectIdentifier; 7import org.bouncycastle.asn1.nist.NISTNamedCurves; 8import org.bouncycastle.asn1.sec.SECNamedCurves; 9// BEGIN android-removed 10// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; 11// END android-removed 12 13/** 14 * A general class that reads all X9.62 style EC curve tables. 15 */ 16public class ECNamedCurveTable 17{ 18 /** 19 * return a X9ECParameters object representing the passed in named 20 * curve. The routine returns null if the curve is not present. 21 * 22 * @param name the name of the curve requested 23 * @return an X9ECParameters object or null if the curve is not available. 24 */ 25 public static X9ECParameters getByName( 26 String name) 27 { 28 X9ECParameters ecP = X962NamedCurves.getByName(name); 29 30 if (ecP == null) 31 { 32 ecP = SECNamedCurves.getByName(name); 33 } 34 35 // BEGIN android-removed 36 // if (ecP == null) 37 // { 38 // ecP = TeleTrusTNamedCurves.getByName(name); 39 // } 40 // END android-removed 41 42 if (ecP == null) 43 { 44 ecP = NISTNamedCurves.getByName(name); 45 } 46 47 return ecP; 48 } 49 50 /** 51 * return a X9ECParameters object representing the passed in named 52 * curve. 53 * 54 * @param oid the object id of the curve requested 55 * @return an X9ECParameters object or null if the curve is not available. 56 */ 57 public static X9ECParameters getByOID( 58 ASN1ObjectIdentifier oid) 59 { 60 X9ECParameters ecP = X962NamedCurves.getByOID(oid); 61 62 if (ecP == null) 63 { 64 ecP = SECNamedCurves.getByOID(oid); 65 } 66 67 // BEGIN android-removed 68 // if (ecP == null) 69 // { 70 // ecP = TeleTrusTNamedCurves.getByOID(oid); 71 // } 72 // END android-removed 73 74 // NOTE: All the NIST curves are currently from SEC, so no point in redundant OID lookup 75 76 return ecP; 77 } 78 79 /** 80 * return an enumeration of the names of the available curves. 81 * 82 * @return an enumeration of the names of the available curves. 83 */ 84 public static Enumeration getNames() 85 { 86 Vector v = new Vector(); 87 88 addEnumeration(v, X962NamedCurves.getNames()); 89 addEnumeration(v, SECNamedCurves.getNames()); 90 addEnumeration(v, NISTNamedCurves.getNames()); 91 // BEGIN android-removed 92 // addEnumeration(v, TeleTrusTNamedCurves.getNames()); 93 // END android-removed 94 95 return v.elements(); 96 } 97 98 private static void addEnumeration( 99 Vector v, 100 Enumeration e) 101 { 102 while (e.hasMoreElements()) 103 { 104 v.addElement(e.nextElement()); 105 } 106 } 107} 108