33 CRYPT_DEVICE localCryptDevice = deviceInfoPtr->objectHandle;
34 MECHANISM_FUNCTION mechanismFunction = NULL;
45 if( deviceInfoPtr->mechanismFunctions != NULL )
48 i < deviceInfoPtr->mechanismFunctionCount && \
49 deviceInfoPtr->mechanismFunctions[ i ].action !=
MESSAGE_NONE && \
53 if( deviceInfoPtr->mechanismFunctions[ i ].action == action && \
54 deviceInfoPtr->mechanismFunctions[ i ].mechanism == mechanism )
57 deviceInfoPtr->mechanismFunctions[ i ].function;
61 ENSURES( i < FAILSAFE_ITERATIONS_LARGE );
62 ENSURES( i < deviceInfoPtr->mechanismFunctionCount );
64 if( mechanismFunction == NULL && \
81 status = krnlSuspendObject( deviceInfoPtr->objectHandle, &refCount );
86 (
void ** ) &deviceInfoPtr,
90 REQUIRES( deviceInfoPtr->mechanismFunctions != NULL );
92 i < deviceInfoPtr->mechanismFunctionCount && \
93 deviceInfoPtr->mechanismFunctions[ i ].action !=
MESSAGE_NONE && \
97 if( deviceInfoPtr->mechanismFunctions[ i ].action == action && \
98 deviceInfoPtr->mechanismFunctions[ i ].mechanism == mechanism )
100 mechanismFunction = \
101 deviceInfoPtr->mechanismFunctions[ i ].function;
105 ENSURES( i < FAILSAFE_ITERATIONS_LARGE );
106 ENSURES( i < deviceInfoPtr->mechanismFunctionCount );
108 if( mechanismFunction == NULL )
125 return( mechanismFunction( NULL, mechanismInfo ) );
129 return( mechanismFunction( deviceInfoPtr, mechanismInfo ) );
172 deviceInfoPtr->shutdownFunction != NULL )
173 deviceInfoPtr->shutdownFunction( deviceInfoPtr );
189 return( getDeviceAttribute( deviceInfoPtr,
190 (
int * ) messageDataPtr,
191 messageValue, messageExtInfo ) );
193 return( getDeviceAttributeS( deviceInfoPtr,
195 messageValue, messageExtInfo ) );
201 if( messageValue == CRYPT_IATTRIBUTE_INITIALISED )
204 return( setDeviceAttribute( deviceInfoPtr,
205 *( (
int * ) messageDataPtr ),
206 messageValue, messageExtInfo ) );
212 return( setDeviceAttributeS( deviceInfoPtr, msgData->data,
213 msgData->
length, messageValue,
223 return( processMechanismMessage( deviceInfoPtr, message,
224 messageValue, messageDataPtr,
250 if( deviceInfoPtr->selftestFunction == NULL )
253 return( deviceInfoPtr->selftestFunction( deviceInfoPtr,
266 getkeyInfo->
keyIDtype, getkeyInfo->keyID,
269 getkeyInfo->
flags ) );
292 deletekeyInfo->keyID, deletekeyInfo->
keyIDlength ) );
305 &getnextcertInfo->
cryptHandle, getnextcertInfo->auxInfo,
306 getnextcertInfo->
keyIDtype, getnextcertInfo->keyID,
308 getnextcertInfo->
flags ) );
320 &getnextcertInfo->
cryptHandle, getnextcertInfo->auxInfo,
321 getnextcertInfo->
flags ) );
332 if( capabilityInfoPtr == NULL )
334 getCapabilityInfo( queryInfo, capabilityInfoPtr );
341 CREATEOBJECT_FUNCTION createObjectFunction = NULL;
342 const void *auxInfo = NULL;
363 createObjectFunction = \
364 deviceInfoPtr->createObjectFunctions[ i ].function;
368 ENSURES( i < FAILSAFE_ITERATIONS_MED );
369 ENSURES( i < deviceInfoPtr->createObjectFunctionCount );
371 if( createObjectFunction == NULL )
390 assert( refCount == 1 );
391 status = createObjectFunction( messageDataPtr, auxInfo,
402 status = createObjectFunction( messageDataPtr, auxInfo,
430 assert( refCount == 1 );
478 static const MAP_TABLE subtypeMapTbl[] = {
488 assert( ( name == NULL && nameLength == 0 ) || \
498 REQUIRES( ( name == NULL && nameLength == 0 ) || \
505 *deviceInfoPtrPtr = NULL;
513 status = mapValue( deviceType, &value, subtypeMapTbl,
540 status = krnlCreateObject( iCryptDevice, (
void ** ) &deviceInfoPtr,
548 *deviceInfoPtrPtr = deviceInfoPtr;
555 deviceInfoPtr->deviceSystem = \
560 deviceInfoPtr->devicePKCS11 = \
565 deviceInfoPtr->deviceCryptoAPI = \
570 deviceInfoPtr->deviceHardware = \
577 deviceInfoPtr->storageSize = storageSize;
583 status = setDeviceSystem( deviceInfoPtr );
602 status = deviceInfoPtr->initFunction( deviceInfoPtr, name,
630 REQUIRES( auxDataPtr == NULL && auxValue == 0 );
642 DEBUG_DIAG((
"Exiting due to kernel shutdown" ));
648 initStatus = openDevice( &iCryptDevice, createInfo->cryptOwner,
649 createInfo->arg1, createInfo->strArg1,
650 createInfo->strArgLen1, &deviceInfoPtr );
654 if( deviceInfoPtr == NULL )
655 return( initStatus );
673 CRYPT_IATTRIBUTE_INITIALISED );
679 createInfo->cryptHandle = iCryptDevice;
692 static
int createSystemDeviceObject(
void )
735 NULL, 0, &deviceInfoPtr );
736 if( deviceInfoPtr == NULL )
737 return( initStatus );
750 CRYPT_IATTRIBUTE_INITIALISED ) );
767 #define DEV_NONE_INITED 0x00
768 #define DEV_PKCS11_INITED 0x01
769 #define DEV_CRYPTOAPI_INITED 0x02
770 #define DEV_HARDWARE_INITED 0x04
786 { NULL, 0 }, { NULL, 0 }
799 status = createSystemDeviceObject();
802 DEBUG_DIAG((
"System object creation failed" ));
819 initFlags |= deviceInitTbl[ i ].
initFlag;
843 if( initFlags & deviceInitTbl[ i ].initFlag )