Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# AlgorithmConstraints


`
public


interface
AlgorithmConstraints
`


`


`

|---|
| java.security.AlgorithmConstraints |

<br />

*** ** * ** ***

This interface specifies constraints for cryptographic algorithms,
keys (key sizes), and other algorithm parameters.


`AlgorithmConstraints` objects are immutable. An implementation
of this interface should not provide methods that can change the state
of an instance once it has been created.


Note that `AlgorithmConstraints` can be used to represent the
restrictions described by the security properties
`jdk.certpath.disabledAlgorithms` and
`jdk.tls.disabledAlgorithms`, or could be used by a
concrete `PKIXCertPathChecker` to check whether a specified
certificate in the certification path contains the required algorithm
constraints.
**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLParameters#getAlgorithmConstraints()`
- `https://developer.android.com/reference/javax/net/ssl/SSLParameters#setAlgorithmConstraints(java.security.AlgorithmConstraints)`

## Summary

| ### Public methods ||
|---|---|
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/AlgorithmConstraints#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.lang.String,%20java.security.AlgorithmParameters)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/security/CryptoPrimitive> primitives, https://developer.android.com/reference/java/lang/String algorithm, https://developer.android.com/reference/java/security/AlgorithmParameters parameters) ` Determines whether an algorithm is granted permission for the specified cryptographic primitives. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/AlgorithmConstraints#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.lang.String,%20java.security.Key,%20java.security.AlgorithmParameters)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/security/CryptoPrimitive> primitives, https://developer.android.com/reference/java/lang/String algorithm, https://developer.android.com/reference/java/security/Key key, https://developer.android.com/reference/java/security/AlgorithmParameters parameters) ` Determines whether an algorithm and the corresponding key are granted permission for the specified cryptographic primitives. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/AlgorithmConstraints#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.security.Key)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/security/CryptoPrimitive> primitives, https://developer.android.com/reference/java/security/Key key) ` Determines whether a key is granted permission for the specified cryptographic primitives. |

## Public methods

### permits

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean permits (Set<CryptoPrimitive> primitives, 
                String algorithm, 
                AlgorithmParameters parameters)
```

Determines whether an algorithm is granted permission for the
specified cryptographic primitives.

<br />

| Parameters ||
|---|---|
| `primitives` | `Set`: a set of cryptographic primitives <br /> |
| `algorithm` | `String`: the algorithm name <br /> |
| `parameters` | `AlgorithmParameters`: the algorithm parameters, or null if no additional parameters <br /> |

| Returns ||
|---|---|
| `boolean` | true if the algorithm is permitted and can be used for all of the specified cryptographic primitives <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if primitives or algorithm is null or empty |

### permits

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean permits (Set<CryptoPrimitive> primitives, 
                String algorithm, 
                Key key, 
                AlgorithmParameters parameters)
```

Determines whether an algorithm and the corresponding key are granted
permission for the specified cryptographic primitives.

<br />

| Parameters ||
|---|---|
| `primitives` | `Set`: a set of cryptographic primitives <br /> |
| `algorithm` | `String`: the algorithm name <br /> |
| `key` | `Key`: the key <br /> |
| `parameters` | `AlgorithmParameters`: the algorithm parameters, or null if no additional parameters <br /> |

| Returns ||
|---|---|
| `boolean` | true if the key and the algorithm can be used for all of the specified cryptographic primitives <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if primitives or algorithm is null or empty, or the key is null |

### permits

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean permits (Set<CryptoPrimitive> primitives, 
                Key key)
```

Determines whether a key is granted permission for the specified
cryptographic primitives.


This method is usually used to check key size and key usage.

<br />

| Parameters ||
|---|---|
| `primitives` | `Set`: a set of cryptographic primitives <br /> |
| `key` | `Key`: the key <br /> |

| Returns ||
|---|---|
| `boolean` | true if the key can be used for all of the specified cryptographic primitives <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if primitives is null or empty, or the key is null |