This implementation is not really spec compliant as rand() does not guarantee TMP_MAX different outputs + seeding