org.bouncycastle.bcpg.SymmetricKeyUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpg-debug-jdk18on Show documentation
Show all versions of bcpg-debug-jdk18on Show documentation
The Bouncy Castle Java API for handling the OpenPGP protocol. This jar contains the OpenPGP API for JDK 1.8 and up. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
The 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