code: private boolean checkConstraints(Set<CryptoPrimitive> primitives,
              String algorithm, Key key, AlgorithmParameters parameters) {
  
          // check the key parameter, it cannot be null.
          if (key == null) {
              throw new IllegalArgumentException("The key cannot be null");
          }
  
          // check the target algorithm
          if (algorithm != null && algorithm.length() != 0) {
              if (!permits(primitives, algorithm, parameters)) {
                  return false;
              }
          }
  
          // check the key algorithm
          if (!permits(primitives, key.getAlgorithm(), null)) {
              return false;
          }
  
          // check the key constraints
          if (keySizeConstraints.disables(key)) {
              return false;
          }
  
          return true;
      }
docs: Check algorithm constraints