Skip to content

Instantly share code, notes, and snippets.

@bringhurst
Created August 20, 2013 16:23
Show Gist options
  • Save bringhurst/6283751 to your computer and use it in GitHub Desktop.
Save bringhurst/6283751 to your computer and use it in GitHub Desktop.
A basic sanity test of the local AES key length.
import javax.crypto.Cipher;
class CipherTest {
public static void main(String args[]) {
try {
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
if(maxKeyLen < 256) {
System.out.println("FAILED: Max key length too small! (" + maxKeyLen + ").");
} else {
System.out.println("PASSED: Max key length OK! (" + maxKeyLen + ").");
}
} catch(Exception e) {
System.out.println("FAILED: No AES found!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment