Class UnsupportedSpecException

All Implemented Interfaces:
Serializable

public class UnsupportedSpecException extends RuntimeException
Exception indicating that a provided key/spec combination is not supported by the algorithm for the requested role.

This is thrown by CryptoAlgorithm.createContext(zeroecho.core.KeyUsage, java.security.Key, zeroecho.core.spec.ContextSpec) when:

  • The algorithm supports the requested KeyUsage role, but none of its bindings accept the given Key and ContextSpec type.
  • The provided spec is incompatible with the key type or context expected by the binding.

Unlike UnsupportedRoleException, which signals that a role is completely unavailable for an algorithm, this exception means that the role exists but cannot be realized with the supplied parameters.

Example

CryptoAlgorithm aes = CryptoAlgorithms.require("AES/GCM");
SecretKey wrongKey = ... // an RSA key by mistake
try {
    aes.createContext(KeyUsage.ENCRYPT, wrongKey, null);
} catch (UnsupportedSpecException e) {
    // no binding accepted the RSA key for ENCRYPT role
}
Since:
1.0
See Also:
  • Constructor Details

    • UnsupportedSpecException

      public UnsupportedSpecException(String m)
      Creates a new exception with the given message.
      Parameters:
      m - detail message describing the rejected key/spec combination