Cipher: Throw early on getMaxAllowedKeyLength / getMaxAllowedParameterSpec
NPE on null transforms and NoSuchAlgorithmException if the specified
transform is invalid.
Change-Id: I368b96f98d01a1209ee467ddfcc6a05bc78723ec
diff --git a/ojluni/src/main/java/javax/crypto/Cipher.java b/ojluni/src/main/java/javax/crypto/Cipher.java
index 8a66345..fcea1f2 100755
--- a/ojluni/src/main/java/javax/crypto/Cipher.java
+++ b/ojluni/src/main/java/javax/crypto/Cipher.java
@@ -2494,12 +2494,17 @@
*/
public static final int getMaxAllowedKeyLength(String transformation)
throws NoSuchAlgorithmException {
- /* ----- BEGIN android -----
- CryptoPermission cp = getConfiguredPermission(transformation);
- return cp.getMaxKeySize();
- */
+ // Android-changed: Remove references to CryptoPermission and throw early
+ // if transformation == null or isn't valid.
+ //
+ // CryptoPermission cp = getConfiguredPermission(transformation);
+ // return cp.getMaxAllowedKeyLength();
+ if (transformation == null) {
+ throw new NullPointerException("transformation == null");
+ }
+ // Throws NoSuchAlgorithmException if necessary.
+ tokenizeTransformation(transformation);
return Integer.MAX_VALUE;
- // ----- END android -----
}
/**
@@ -2522,12 +2527,17 @@
*/
public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(
String transformation) throws NoSuchAlgorithmException {
- /* ----- BEGIN android -----
- CryptoPermission cp = getConfiguredPermission(transformation);
- return cp.getAlgorithmParameterSpec();
- */
+ // Android-changed: Remove references to CryptoPermission and throw early
+ // if transformation == null or isn't valid.
+ //
+ // CryptoPermission cp = getConfiguredPermission(transformation);
+ // return cp.getAlgorithmParameterSpec();
+ if (transformation == null) {
+ throw new NullPointerException("transformation == null");
+ }
+ // Throws NoSuchAlgorithmException if necessary.
+ tokenizeTransformation(transformation);
return null;
- // ----- END android -----
}
/**