use of org.bouncycastle.pqc.jcajce.spec.LMSHSSKeyGenParameterSpec in project jmulticard by ctt-gob-es.
the class LMSKeyPairGeneratorSpi method initialize.
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
if (params instanceof LMSKeyGenParameterSpec) {
LMSKeyGenParameterSpec lmsParams = (LMSKeyGenParameterSpec) params;
param = new LMSKeyGenerationParameters(new LMSParameters(lmsParams.getSigParams(), lmsParams.getOtsParams()), random);
engine = new LMSKeyPairGenerator();
engine.init(param);
} else if (params instanceof LMSHSSKeyGenParameterSpec) {
LMSKeyGenParameterSpec[] lmsParams = ((LMSHSSKeyGenParameterSpec) params).getLMSSpecs();
LMSParameters[] hssParams = new LMSParameters[lmsParams.length];
for (int i = 0; i != lmsParams.length; i++) {
hssParams[i] = new LMSParameters(lmsParams[i].getSigParams(), lmsParams[i].getOtsParams());
}
param = new HSSKeyGenerationParameters(hssParams, random);
engine = new HSSKeyPairGenerator();
engine.init(param);
} else if (params instanceof LMSParameterSpec) {
LMSParameterSpec lmsParams = (LMSParameterSpec) params;
param = new LMSKeyGenerationParameters(new LMSParameters(lmsParams.getSigParams(), lmsParams.getOtsParams()), random);
engine = new LMSKeyPairGenerator();
engine.init(param);
} else if (params instanceof LMSHSSParameterSpec) {
LMSParameterSpec[] lmsParams = ((LMSHSSParameterSpec) params).getLMSSpecs();
LMSParameters[] hssParams = new LMSParameters[lmsParams.length];
for (int i = 0; i != lmsParams.length; i++) {
hssParams[i] = new LMSParameters(lmsParams[i].getSigParams(), lmsParams[i].getOtsParams());
}
param = new HSSKeyGenerationParameters(hssParams, random);
engine = new HSSKeyPairGenerator();
engine.init(param);
} else {
throw new InvalidAlgorithmParameterException("parameter object not a LMSParameterSpec/LMSHSSParameterSpec");
}
initialised = true;
}
Aggregations