25 #define NO_ENTROPY_FAILURES 5
97 assert( messageExtInfo == NULL || \
114 status = deviceInfoPtr->getRandomFunction( deviceInfoPtr,
115 data, length, messageExtInfo );
117 ( length < 8 || checkEntropy( data, length ) ) )
124 DEBUG_DIAG((
"Random data didn't pass FIPS 140 tests after %d "
125 "iterations", NO_ENTROPY_FAILURES ));
143 assert( messageExtInfo == NULL || \
155 for( count = 0, iterationCount = 0;
164 status = getRandomChecked( deviceInfoPtr, randomBuffer, 128, NULL );
167 for( i = 0; count < length && i < 128; i++ )
169 if( randomBuffer[ i ] != 0 )
170 outBuffer[ count++ ] = randomBuffer[ i ];
173 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
175 ( (
BYTE * ) data )[ i ] != 0 );
197 assert(
isWritePtr( valuePtr,
sizeof(
int ) ) );
207 *valuePtr = deviceInfoPtr->errorType;
211 *valuePtr = deviceInfoPtr->errorLocus;
222 status = deviceInfoPtr->controlFunction( deviceInfoPtr,
259 switch( deviceInfoPtr->type )
262 errorInfo = &deviceInfoPtr->devicePKCS11->errorInfo;
266 errorInfo = &deviceInfoPtr->deviceCryptoAPI->errorInfo;
270 return( exitErrorNotFound( deviceInfoPtr,
274 if( errorInfo->errorStringLength > 0 )
276 return( attributeCopy( msgData, errorInfo->errorString,
277 errorInfo->errorStringLength ) );
280 return( exitErrorNotFound( deviceInfoPtr,
285 if( deviceInfoPtr->label == NULL )
286 return( exitErrorNotFound( deviceInfoPtr,
288 return( attributeCopy( msgData, deviceInfoPtr->label,
289 strlen( deviceInfoPtr->label ) ) );
291 case CRYPT_IATTRIBUTE_RANDOM:
292 if( deviceInfoPtr->getRandomFunction == NULL )
294 return( getRandomChecked( deviceInfoPtr, msgData->data,
295 msgData->length, messageExtInfo ) );
297 case CRYPT_IATTRIBUTE_RANDOM_NZ:
298 if( deviceInfoPtr->getRandomFunction == NULL )
300 return( getRandomNonzero( deviceInfoPtr, msgData->data,
301 msgData->length, messageExtInfo ) );
303 case CRYPT_IATTRIBUTE_RANDOM_NONCE:
304 if( deviceInfoPtr->getRandomFunction == NULL )
307 return( deviceInfoPtr->controlFunction( deviceInfoPtr,
308 CRYPT_IATTRIBUTE_RANDOM_NONCE,
313 case CRYPT_IATTRIBUTE_TIME:
315 time_t *timePtr = msgData->data;
324 status = deviceInfoPtr->controlFunction( deviceInfoPtr,
325 CRYPT_IATTRIBUTE_TIME,
327 msgData->length, NULL );
369 return( deviceInfoPtr->controlFunction( deviceInfoPtr, attribute, NULL,
370 value, messageExtInfo ) );
400 return( exitErrorInited( deviceInfoPtr, attribute ) );
403 status = deviceInfoPtr->controlFunction( deviceInfoPtr, attribute,
404 (
void * ) data, dataLength,
415 if( deviceInfoPtr->getRandomFunction != NULL )
419 status = deviceInfoPtr->getRandomFunction( deviceInfoPtr,
428 CRYPT_IATTRIBUTE_ENTROPY );
437 return( deviceInfoPtr->controlFunction( deviceInfoPtr, attribute,
438 (
void * ) data, dataLength,