All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.spongycastle.jcajce.provider.asymmetric.util.IESUtil Maven / Gradle / Ivy

Go to download

Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for the Android platform. Android unfortunately ships with a stripped-down version of Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full, up-to-date version of the Bouncy Castle cryptographic libs.

The newest version!
package org.spongycastle.jcajce.provider.asymmetric.util;

import org.spongycastle.crypto.BlockCipher;
import org.spongycastle.crypto.BufferedBlockCipher;
import org.spongycastle.jce.spec.IESParameterSpec;

public class IESUtil
{
    public static IESParameterSpec guessParameterSpec(BufferedBlockCipher iesBlockCipher, byte[] nonce)
    {
        if (iesBlockCipher == null)
        {
            return new IESParameterSpec(null, null, 128);
        }
        else
        {
            BlockCipher underlyingCipher = iesBlockCipher.getUnderlyingCipher();

            if (underlyingCipher.getAlgorithmName().equals("DES") ||
                underlyingCipher.getAlgorithmName().equals("RC2") ||
                underlyingCipher.getAlgorithmName().equals("RC5-32") ||
                underlyingCipher.getAlgorithmName().equals("RC5-64"))
            {
                return new IESParameterSpec(null, null, 64, 64, nonce);
            }
            else if (underlyingCipher.getAlgorithmName().equals("SKIPJACK"))
            {
                return new IESParameterSpec(null, null, 80, 80, nonce);
            }
            else if (underlyingCipher.getAlgorithmName().equals("GOST28147"))
            {
                return new IESParameterSpec(null, null, 256, 256, nonce);
            }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy