I am quite new and unexperienced in the field of Elliptic Curve cryptography. After some research I have determined unlike traditional DHE, ECDHE parameters should not be generated but rather chosen from a list of pre-defined curves (examples include 'P-521', 'prime192v3').
Whilst creating an network based security-sensitive application is it better (or even logical) to choose different curves randomly at runtime vs using a single hard-coded curve?
Also, is there such a concept of a stronger and weaker curves amongst all the curves to choose from?
So far, this is my code to initiating a ECDH exchange:
//For readability purposes exception checking code not shown, all code is properly exception-handled
SecureRandom rnd = SecureRandom.getInstance("SHA1PRNG", "SUN");
X9ECParameters curve = ECNamedCurveTable.getByName("prime192v3");
ECDomainParameters domain = new ECDomainParameters(curve.getCurve(), curve.getG(), curve.getN(), curve.getH(), curve.getSeed());
ECKeyGenerationParameters ecgen = new ECKeyGenerationParameters(domain, rnd);
ECKeyPairGenerator kpgen = new ECKeyPairGenerator();
kpgen.init(ecgen);
AsymmetricCipherKeyPair kp = kpgen.generateKeyPair();
Is there anything wrong with this code so far?