Search in sources :

Example 1 with LMSKeyGenParameterSpec

use of com.github.zhenwei.provider.jcajce.spec.LMSKeyGenParameterSpec in project LinLong-Java by zhenwei1108.

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;
}
Also used : HSSKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.lms.HSSKeyGenerationParameters) LMSKeyGenParameterSpec(com.github.zhenwei.provider.jcajce.spec.LMSKeyGenParameterSpec) LMSHSSParameterSpec(com.github.zhenwei.provider.jcajce.spec.LMSHSSParameterSpec) LMSKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.lms.LMSKeyGenerationParameters) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) LMSParameterSpec(com.github.zhenwei.provider.jcajce.spec.LMSParameterSpec) LMSKeyPairGenerator(com.github.zhenwei.core.pqc.crypto.lms.LMSKeyPairGenerator) LMSParameters(com.github.zhenwei.core.pqc.crypto.lms.LMSParameters) LMSHSSKeyGenParameterSpec(com.github.zhenwei.provider.jcajce.spec.LMSHSSKeyGenParameterSpec) HSSKeyPairGenerator(com.github.zhenwei.core.pqc.crypto.lms.HSSKeyPairGenerator)

Aggregations

HSSKeyGenerationParameters (com.github.zhenwei.core.pqc.crypto.lms.HSSKeyGenerationParameters)1 HSSKeyPairGenerator (com.github.zhenwei.core.pqc.crypto.lms.HSSKeyPairGenerator)1 LMSKeyGenerationParameters (com.github.zhenwei.core.pqc.crypto.lms.LMSKeyGenerationParameters)1 LMSKeyPairGenerator (com.github.zhenwei.core.pqc.crypto.lms.LMSKeyPairGenerator)1 LMSParameters (com.github.zhenwei.core.pqc.crypto.lms.LMSParameters)1 LMSHSSKeyGenParameterSpec (com.github.zhenwei.provider.jcajce.spec.LMSHSSKeyGenParameterSpec)1 LMSHSSParameterSpec (com.github.zhenwei.provider.jcajce.spec.LMSHSSParameterSpec)1 LMSKeyGenParameterSpec (com.github.zhenwei.provider.jcajce.spec.LMSKeyGenParameterSpec)1 LMSParameterSpec (com.github.zhenwei.provider.jcajce.spec.LMSParameterSpec)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1