aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/prov/src/main/java/org/spongycastle/jcajce/provider/asymmetric/util/IESUtil.java
blob: fb93838e6991bfa3f7b1dbe2722919c96bbee214 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package org.spongycastle.jcajce.provider.asymmetric.util;

import org.spongycastle.crypto.engines.IESEngine;
import org.spongycastle.jce.spec.IESParameterSpec;

public class IESUtil
{
    public static IESParameterSpec guessParameterSpec(IESEngine engine)
    {
        if (engine.getCipher() == null)
        {
            return new IESParameterSpec(null, null, 128);
        }
        else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("DES") ||
                engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC2") ||
                engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC5-32") ||
                engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC5-64"))
        {
            return new IESParameterSpec(null, null, 64, 64);
        }
        else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("SKIPJACK"))
        {
            return new IESParameterSpec(null, null, 80, 80);
        }
        else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("GOST28147"))
        {
            return new IESParameterSpec(null, null, 256, 256);
        }

        return new IESParameterSpec(null, null, 128, 128);
    }
}