code: public static byte[] checkLength(byte[] data, int size) {
          if (data == null) {
              throw new IllegalArgumentException("Data to check the length of are null.");
          }
          if (data.length < size) {
              throw new IllegalArgumentException("Invalid length: " + data.length);
          }
          return data;
      }
docs: Validate the length of the data provided
  
  @param data
  @param size
  @return data provided if valid