Created
June 5, 2012 01:20
-
-
Save djangofan/2871851 to your computer and use it in GitHub Desktop.
Groovy script to determine max strength of all your JDK ciphers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.crypto.Cipher | |
import java.security.* | |
import javax.crypto.* | |
// Groovy script | |
class SecurityTests { | |
static void main(String[] args) { | |
for (Provider provider : Security.getProviders()) | |
{ | |
System.out.println("Provider: " + provider.getName()) | |
for (Provider.Service service : provider.getServices() ) | |
{ | |
int maximum = 0; | |
String alg = service.getAlgorithm() | |
if ( getKeyStrength( alg ) == 2147483647 ) { | |
System.out.println(" Algorithm: " + alg + | |
", max" ) | |
} else { | |
System.out.println(" Algorithm: " + alg + | |
", " + getKeyStrength( alg ) ) | |
} | |
} | |
} | |
} | |
static int getKeyStrength( cipher ) { | |
int max | |
try { | |
max = Cipher.getMaxAllowedKeyLength( cipher) | |
} catch (NoSuchAlgorithmException e) { | |
e.getLocalizedMessage() | |
return 0 | |
} | |
return max | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment