I am trying to generate the ECDSA Keys using brain pool curve at the Safenet HSM. I enabled the user-defined domain parameters at the Safenet HSM and we are facing exception
java.security.InvalidAlgorithmParameterException: params must be either a subtype of java.security.spec.ECParameterSpec or of type ECGenParameterSpec!
at iaik.security.ec.common.ECKeyPairGenerator.initialize(Unknown Source) ~[iaik_eccelerate.jar:5.0]
I am using following code
ECDSAPrivateKey obj_privateKeyTemplate = new ECDSAPrivateKey();
ECDSAPublicKey obj_publicKeyTemplate = new ECDSAPublicKey();
obj_privateKeyTemplate.getSign().setBooleanValue(Boolean.TRUE);
obj_privateKeyTemplate.getToken().setBooleanValue(Boolean.FALSE); // temporary session key ?
obj_publicKeyTemplate.getVerify().setBooleanValue(Boolean.TRUE);
obj_publicKeyTemplate.getToken().setBooleanValue(Boolean.FALSE); // temporary session key ?
ObjectID eccCurveObjectID = new ObjectID("1.3.36.3.3.2.8.1.1.1");
obj_publicKeyTemplate.getEcdsaParams().setByteArrayValue(DerCoder.encode(eccCurveObjectID));
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "IAIK ECCelerate");
AlgorithmParameterSpec keyPairGenerationSpec = (AlgorithmParameterSpec) new PKCS11KeyPairGenerationSpec(
null, obj_publicKeyTemplate, obj_privateKeyTemplate).setUseUserRole(true)
.setTokenManager(this.m_objTokenManager);
keyPairGenerator.initialize(keyPairGenerationSpec, new SecureRandom());
obj_keypair = keyPairGenerator.generateKeyPair();
Please help me to fix this issue.