Skip to content

provide parametrized types for generics #2042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected X9ECParameters createParameters()
};


static final Hashtable objIds = new Hashtable();
static final Hashtable curves = new Hashtable();
static final Hashtable names = new Hashtable();
static final Hashtable<String, ASN1ObjectIdentifier> objIds = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, X9ECParametersHolder> curves = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, String> names = new Hashtable<>();

static void defineCurve(String name, ASN1ObjectIdentifier oid, X9ECParametersHolder holder)
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public static X9ECParameters getByOID(ASN1ObjectIdentifier oid)

public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
{
return (X9ECParametersHolder)curves.get(oid);
return curves.get(oid);
}

/**
Expand All @@ -115,10 +115,9 @@ public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
*
* @return the object identifier associated with name, if present.
*/
public static ASN1ObjectIdentifier getOID(
String name)
public static ASN1ObjectIdentifier getOID(String name)
{
return (ASN1ObjectIdentifier)objIds.get(Strings.toLowerCase(name));
return objIds.get(Strings.toLowerCase(name));
}

/**
Expand All @@ -127,7 +126,7 @@ public static ASN1ObjectIdentifier getOID(
public static String getName(
ASN1ObjectIdentifier oid)
{
return (String)names.get(oid);
return names.get(oid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private static BigInteger fromHex(String hex)
*/
static X9ECParametersHolder gostR3410_2001_CryptoPro_A = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97");
Expand Down Expand Up @@ -72,6 +73,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder gostR3410_2001_CryptoPro_B = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("8000000000000000000000000000000000000000000000000000000000000C99");
Expand Down Expand Up @@ -102,6 +104,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder gostR3410_2001_CryptoPro_C = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B");
Expand Down Expand Up @@ -132,6 +135,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder id_tc26_gost_3410_12_256_paramSetA = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97");
Expand Down Expand Up @@ -162,6 +166,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder id_tc26_gost_3410_12_512_paramSetA = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7");
Expand Down Expand Up @@ -192,6 +197,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder id_tc26_gost_3410_12_512_paramSetB = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006F");
Expand Down Expand Up @@ -222,6 +228,7 @@ protected X9ECParameters createParameters()
*/
static X9ECParametersHolder id_tc26_gost_3410_12_512_paramSetC = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger mod_p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7");
Expand All @@ -248,9 +255,9 @@ protected X9ECParameters createParameters()
};


static final Hashtable objIds = new Hashtable();
static final Hashtable curves = new Hashtable();
static final Hashtable names = new Hashtable();
static final Hashtable<String, ASN1ObjectIdentifier> objIds = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, X9ECParametersHolder> curves = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, String> names = new Hashtable<>();

static void defineCurve(String name, ASN1ObjectIdentifier oid, X9ECParametersHolder holder)
{
Expand Down Expand Up @@ -295,12 +302,12 @@ public static X9ECParameters getByOIDX9(ASN1ObjectIdentifier oid)

public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
{
return (X9ECParametersHolder)curves.get(oid);
return curves.get(oid);
}

public static ASN1ObjectIdentifier getOID(String name)
{
return (ASN1ObjectIdentifier)objIds.get(name);
return objIds.get(name);
}

/**
Expand All @@ -309,7 +316,7 @@ public static ASN1ObjectIdentifier getOID(String name)
public static String getName(
ASN1ObjectIdentifier oid)
{
return (String)names.get(oid);
return names.get(oid);
}

/**
Expand Down
13 changes: 7 additions & 6 deletions core/src/main/java/org/bouncycastle/asn1/gm/GMNamedCurves.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected X9ECParameters createParameters()

static X9ECParametersHolder wapip192v1 = new X9ECParametersHolder()
{
@Override
protected ECCurve createCurve()
{
BigInteger p = fromHex("BDB6F4FE3E8B1D9E0DA8C0D46F4C318CEFE4AFE3B6B8551F");
Expand All @@ -89,9 +90,9 @@ protected X9ECParameters createParameters()
};


static final Hashtable objIds = new Hashtable();
static final Hashtable curves = new Hashtable();
static final Hashtable names = new Hashtable();
static final Hashtable<String, ASN1ObjectIdentifier> objIds = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, X9ECParametersHolder> curves = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, String> names = new Hashtable<>();

static void defineCurve(String name, ASN1ObjectIdentifier oid, X9ECParametersHolder holder)
{
Expand Down Expand Up @@ -133,7 +134,7 @@ public static X9ECParameters getByOID(ASN1ObjectIdentifier oid)

public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
{
return (X9ECParametersHolder)curves.get(oid);
return curves.get(oid);
}

/**
Expand All @@ -145,7 +146,7 @@ public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
public static ASN1ObjectIdentifier getOID(
String name)
{
return (ASN1ObjectIdentifier)objIds.get(Strings.toLowerCase(name));
return objIds.get(Strings.toLowerCase(name));
}

/**
Expand All @@ -154,7 +155,7 @@ public static ASN1ObjectIdentifier getOID(
public static String getName(
ASN1ObjectIdentifier oid)
{
return (String)names.get(oid);
return names.get(oid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
public class NISTNamedCurves
{
static final Hashtable objIds = new Hashtable();
static final Hashtable names = new Hashtable();
static final Hashtable<String, ASN1ObjectIdentifier> objIds = new Hashtable<>();
static final Hashtable<ASN1ObjectIdentifier, String> names = new Hashtable<>();

static void defineCurve(String name, ASN1ObjectIdentifier oid)
{
Expand Down Expand Up @@ -79,15 +79,15 @@ public static X9ECParametersHolder getByOIDLazy(ASN1ObjectIdentifier oid)
*/
public static ASN1ObjectIdentifier getOID(String name)
{
return (ASN1ObjectIdentifier)objIds.get(Strings.toUpperCase(name));
return objIds.get(Strings.toUpperCase(name));
}

/**
* return the named curve name represented by the given object identifier.
*/
public static String getName(ASN1ObjectIdentifier oid)
{
return (String)names.get(oid);
return names.get(oid);
}

/**
Expand Down
Loading