It most definitely is not illegal. Many colleges have race and gender based quota systems. Governments have race and gender quota systems. Many federal, state and local governments set aside X percentage of their contracts solely for minority or female owned businesses.
Whether this is right or wrong is another debate. But race, gender or "diversity" hiring or recruiting certainly isn't illegal. It happens all the time.