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

org.bouncycastle.bcpg.SymmetricKeyUtils Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java API for handling the OpenPGP protocol. This jar contains the OpenPGP API for JDK 1.5 to JDK 1.8. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.

There is a newer version: 1.79
Show newest version
package org.bouncycastle.bcpg;

public class SymmetricKeyUtils
    implements SymmetricKeyAlgorithmTags
{
    public static int getKeyLengthInBits(int algorithm)
    {
        switch (algorithm)
        {
        case NULL:
            throw new IllegalArgumentException("NULL is no encryption algorithm.");
        case DES:
            return 64;
        case IDEA:
        case CAST5:
        case BLOWFISH:
        case SAFER:
        case AES_128:
        case CAMELLIA_128:
            return 128;

        case TRIPLE_DES:
        case AES_192:
        case CAMELLIA_192:
            return 192;

        case AES_256:
        case TWOFISH:
        case CAMELLIA_256:
            return 256;
        default:
            throw new IllegalArgumentException("unknown symmetric algorithm: " + algorithm);
        }
    }

    public static int getKeyLengthInOctets(int algorithm)
    {
        return (getKeyLengthInBits(algorithm) + 7) / 8;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy