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 APIs for the OpenPGP Protocol. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.

There is a newer version: 2.0.9
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