Search in sources :

Example 1 with ModeParameterSpec

use of de.flexiprovider.common.mode.ModeParameterSpec in project core by jcryptool.

the class BlockCipherWizard method getDefaultModeParamSpecs.

private ModeParameterSpec getDefaultModeParamSpecs() {
    ModeParameterGenerator generator = new ModeParameterGenerator();
    generator.init(algorithm.getDefaultBlockLength() / 8, FlexiProviderAlgorithmsPlugin.getSecureRandom());
    return (ModeParameterSpec) generator.generateParameters();
}
Also used : ModeParameterGenerator(de.flexiprovider.common.mode.ModeParameterGenerator) ModeParameterSpec(de.flexiprovider.common.mode.ModeParameterSpec)

Example 2 with ModeParameterSpec

use of de.flexiprovider.common.mode.ModeParameterSpec in project core by jcryptool.

the class ModeParameterSpecElement method getModeParameterSpec.

private ModeParameterSpec getModeParameterSpec(String encoded) {
    if (encoded != null) {
        // $NON-NLS-1$
        LogUtil.logInfo("getModeParameterSpec");
        try {
            byte[] encodedParams = Base64Coder.decode(encoded);
            // $NON-NLS-1$
            AlgorithmParameters params = Registry.getAlgParams("Mode");
            params.init(encodedParams);
            return (ModeParameterSpec) params.getParameterSpec(ModeParameterSpec.class);
        } catch (IOException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while decoding ModeParameters", e, false);
        } catch (NoSuchAlgorithmException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "NoSuchAlgorithmException while decoding ModeParameters", e, true);
        } catch (InvalidParameterSpecException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "InvalidParameterSpecException while decoding ModeParameters", e, true);
        }
    }
    return null;
}
Also used : IOException(java.io.IOException) NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) InvalidParameterSpecException(de.flexiprovider.api.exceptions.InvalidParameterSpecException) AlgorithmParameters(de.flexiprovider.api.parameters.AlgorithmParameters) ModeParameterSpec(de.flexiprovider.common.mode.ModeParameterSpec)

Aggregations

ModeParameterSpec (de.flexiprovider.common.mode.ModeParameterSpec)2 InvalidParameterSpecException (de.flexiprovider.api.exceptions.InvalidParameterSpecException)1 NoSuchAlgorithmException (de.flexiprovider.api.exceptions.NoSuchAlgorithmException)1 AlgorithmParameters (de.flexiprovider.api.parameters.AlgorithmParameters)1 ModeParameterGenerator (de.flexiprovider.common.mode.ModeParameterGenerator)1 IOException (java.io.IOException)1