예제 #1
0
파일: drng.c 프로젝트: mitls/hacl-star
int rdrand16_retry (unsigned int retries, uint16_t *rand)
{
	unsigned int count= 0;

	while ( count <= retries ) {
		if ( rdrand16_step(rand) ) {
			return 1;
		}

		++count;
	}

	return 0;
}
예제 #2
0
/** ***************************************************************
 * fill with _step functions
 */
int fill_uint16_step(uint16_t* buf, int size, int retry_limit)
{
	int j,k;
	int rc;

	for (j=0; j<size; ++j)
	{
		k = 0;
		do
		{
			rc = rdrand16_step ( &buf[j] );
			++k;
		}
		while ( rc == RDRAND_FAILURE && k < retry_limit);
	}
	return size;
}
예제 #3
0
파일: rdrand.c 프로젝트: jirka-h/RdRand
int rdrand_get_uint16_retry(uint16_t *dest, int retry_limit) {
  int rc;
  int count;
  uint16_t x;

  if ( retry_limit < 0 ) retry_limit = RETRY_LIMIT;
  count = 0;
  do {
    rc=rdrand16_step( &x );
    ++count;
  } while((rc == 0) || (count < retry_limit));

  if (rc == 1) {
    *dest = x;
    return 1;
  } else {
    return 0;
  }
}