63 assert( ( keyIDinfo == NULL && \
64 keyIDbuffer == NULL && keyIdMaxLength == 0 ) || \
65 (
isWritePtr( keyIDinfo,
sizeof( KEYID_INFO ) ) && \
66 isReadPtr( keyIDbuffer, keyIdMaxLength ) ) );
69 keyIDbuffer == NULL && keyIdMaxLength == 0 ) || \
70 ( keyIDinfo != NULL && \
71 keyIDbuffer != NULL && keyIdMaxLength ==
KEYID_SIZE ) );
74 if( keysetInfoPtr->isBusyFunction != NULL && \
75 keysetInfoPtr->isBusyFunction( keysetInfoPtr ) )
80 if( keyIDinfo != NULL && \
81 keyIDinfo->keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER && \
95 keyIDinfo->keyIDlength );
96 keyIDinfo->keyIDtype = CRYPT_IKEYID_ISSUERID;
97 keyIDinfo->keyID = keyIDbuffer;
131 { NULL, 0 }, { NULL, 0 }
150 status = value = sPeek( stream );
165 status = readLongSequence( stream, &length );
168 if( length !=
CRYPT_UNUSED && ( length < 64 || length > 65535L ) )
189 status = readOID( stream, keyFileOIDinfo,
210 status = pgpReadPacketHeader( stream, &value, &length, 64 );
215 if( length < 64 || length > 1024 )
220 if( length < 200 || length > 4096 )
223 status = value = sgetc( stream );
245 const int nameLength,
254 const int suffixPos = nameLength - 4;
271 memcpy( nameBuffer, name, nameLength );
272 nameBuffer[ nameLength ] =
'\0';
276 if( suffixPos > 0 && nameBuffer[ suffixPos ] ==
'.' )
278 if( !
strCompare( nameBuffer + suffixPos + 1,
"pgp", 3 ) || \
279 !
strCompare( nameBuffer + suffixPos + 1,
"gpg", 3 ) || \
280 !
strCompare( nameBuffer + suffixPos + 1,
"pkr", 3 ) )
282 if( !
strCompare( nameBuffer + suffixPos + 1,
"skr", 3 ) )
284 if( !
strCompare( nameBuffer + suffixPos + 1,
"pfx", 3 ) || \
285 !
strCompare( nameBuffer + suffixPos + 1,
"p12", 3 ) )
290 if( fileReadonly( nameBuffer ) )
318 if( options == CRYPT_IKEYOPT_EXCLUSIVEACCESS )
336 status = sFileOpen( stream, nameBuffer, openMode );
354 status = getKeysetType( stream, &subType );
358 sFileClose( stream );
377 sFileClose( stream );
378 status = sFileOpen( stream, nameBuffer, openMode );
396 sFileClose( stream );
400 *keysetSubType = subType;
411 IN_BUFFER( nameLength )
const char *name,
413 const int nameLength )
415 FILE_INFO *fileInfo = keysetInfoPtr->keysetFile;
430 if( nameLength > MAX_PATH_LENGTH - 1 )
432 keysetInfoPtr->subType = subType;
433 memcpy( fileInfo->
fileName, name, nameLength );
434 fileInfo->
fileName[ nameLength ] =
'\0';
441 memset( stream, 0,
sizeof(
STREAM ) );
444 switch( keysetInfoPtr->subType )
482 ENSURES( keysetInfoPtr->initFunction != NULL && \
483 keysetInfoPtr->shutdownFunction != NULL && \
484 keysetInfoPtr->getItemFunction != NULL );
486 ( keysetInfoPtr->getSpecialItemFunction != NULL && \
487 keysetInfoPtr->setItemFunction != NULL && \
488 keysetInfoPtr->setSpecialItemFunction != NULL && \
489 keysetInfoPtr->deleteItemFunction != NULL && \
490 keysetInfoPtr->getFirstItemFunction != NULL && \
491 keysetInfoPtr->getNextItemFunction != NULL ) );
496 status = keysetInfoPtr->initFunction( keysetInfoPtr, NULL, 0,
497 keysetInfoPtr->options );
509 sFileClose( &fileInfo->
stream );
551 status = keysetInfoPtr->shutdownFunction( keysetInfoPtr );
574 sFileClose( &keysetInfoPtr->keysetFile->stream );
575 fileErase( keysetInfoPtr->keysetFile->fileName );
600 fileClearToEOF( &keysetInfoPtr->keysetFile->stream );
605 status = sFileClose( &keysetInfoPtr->keysetFile->stream );
611 fileErase( keysetInfoPtr->keysetFile->fileName );
620 fileErase( keysetInfoPtr->keysetFile->fileName );
646 status = keysetInfoPtr->setAttributeFunction( keysetInfoPtr,
647 messageDataPtr, messageValue );
660 status = keysetInfoPtr->getAttributeFunction( keysetInfoPtr,
661 messageDataPtr, messageValue );
674 return( getKeysetAttribute( keysetInfoPtr,
675 (
int * ) messageDataPtr,
678 return( getKeysetAttributeS( keysetInfoPtr,
686 if( messageValue == CRYPT_IATTRIBUTE_INITIALISED )
689 return( setKeysetAttribute( keysetInfoPtr,
690 *( (
int * ) messageDataPtr ),
697 return( setKeysetAttributeS( keysetInfoPtr, msgData->data,
698 msgData->
length, messageValue ) );
728 getkeyInfo->
keyIDtype, getkeyInfo->keyID, \
733 keyIDinfo.keyID = getkeyInfo->keyID; \
737 keyIDinfo.keyID != NULL && \
753 resetErrorInfo( keysetInfoPtr );
754 status = initKeysetUpdate( keysetInfoPtr, &keyIDinfo, keyIDbuffer,
758 return( keysetInfoPtr->getItemFunction( keysetInfoPtr,
760 keyIDinfo.keyIDtype, keyIDinfo.keyID,
761 keyIDinfo.keyIDlength, getkeyInfo->auxInfo,
763 getkeyInfo->
flags ) );
803 resetErrorInfo( keysetInfoPtr );
804 status = initKeysetUpdate( keysetInfoPtr, NULL, NULL, 0,
FALSE );
807 status = keysetInfoPtr->setItemFunction( keysetInfoPtr,
826 deletekeyInfo->
keyIDtype, deletekeyInfo->keyID, \
831 keyIDinfo.keyID = deletekeyInfo->keyID; \
835 keyIDinfo.keyID != NULL && \
840 resetErrorInfo( keysetInfoPtr );
841 status = initKeysetUpdate( keysetInfoPtr, &keyIDinfo, keyIDbuffer,
845 status = keysetInfoPtr->deleteItemFunction( keysetInfoPtr,
847 keyIDinfo.keyID, keyIDinfo.keyIDlength );
861 getnextcertInfo->
keyIDtype, getnextcertInfo->keyID, \
866 keyIDinfo.keyID = getnextcertInfo->keyID; \
870 keyIDinfo.keyID != NULL && \
873 REQUIRES( ( getnextcertInfo->auxInfo == NULL && \
875 ( getnextcertInfo->auxInfo != NULL && \
879 resetErrorInfo( keysetInfoPtr );
880 status = initKeysetUpdate( keysetInfoPtr, &keyIDinfo, keyIDbuffer,
884 return( keysetInfoPtr->getFirstItemFunction( keysetInfoPtr,
886 getnextcertInfo->auxInfo, messageValue,
888 keyIDinfo.keyIDlength,
889 getnextcertInfo->
flags ) );
897 getnextcertInfo->keyID == NULL && \
899 REQUIRES( ( getnextcertInfo->auxInfo == NULL && \
901 ( getnextcertInfo->auxInfo != NULL && \
908 return( keysetInfoPtr->getNextItemFunction( keysetInfoPtr,
910 getnextcertInfo->auxInfo,
911 getnextcertInfo->
flags ) );
920 messageValue <= CRYPT_CERTACTION_LAST_USER );
923 resetErrorInfo( keysetInfoPtr );
924 status = initKeysetUpdate( keysetInfoPtr, NULL, NULL, 0,
TRUE );
927 status = keysetInfoPtr->keysetDBMS->certMgmtFunction( keysetInfoPtr,
952 IN_BUFFER( nameLength )
const char *name,
978 *keysetInfoPtrPtr = NULL;
1030 memset( &stream, 0,
sizeof(
STREAM ) );
1039 status = openKeysetStream( &stream, name, nameLength, options,
1040 &isReadOnly, &keysetSubType );
1090 status = krnlCreateObject( iCryptKeyset, (
void ** ) &keysetInfoPtr,
1098 sFileClose( &stream );
1102 *keysetInfoPtrPtr = keysetInfoPtr;
1105 keysetInfoPtr->
options = localOptions;
1106 switch( keysetType )
1110 keysetInfoPtr->keysetFile = (
FILE_INFO * ) keysetInfoPtr->storage;
1116 keysetInfoPtr->keysetHTTP = (
HTTP_INFO * ) keysetInfoPtr->storage;
1123 keysetInfoPtr->keysetLDAP = (
LDAP_INFO * ) keysetInfoPtr->storage;
1130 keysetInfoPtr->keysetDBMS = (
DBMS_INFO * ) keysetInfoPtr->storage;
1134 keysetInfoPtr->storageSize = storageSize;
1140 status = completeKeysetFileOpen( keysetInfoPtr, keysetSubType,
1141 &stream, name, nameLength );
1144 sFileClose( &keysetInfoPtr->keysetFile->stream );
1149 fileErase( keysetInfoPtr->keysetFile->fileName );
1164 DEBUG_DIAG((
"Exiting due to kernel shutdown" ));
1171 switch( keysetType )
1193 ENSURES( keysetInfoPtr->initFunction != NULL && \
1194 keysetInfoPtr->shutdownFunction != NULL && \
1195 keysetInfoPtr->getItemFunction != NULL );
1197 ( keysetInfoPtr->setItemFunction != NULL && \
1198 keysetInfoPtr->deleteItemFunction != NULL && \
1199 keysetInfoPtr->isBusyFunction != NULL ) );
1202 ( keysetInfoPtr->getFirstItemFunction != NULL && \
1203 keysetInfoPtr->getNextItemFunction != NULL ) );
1206 ( keysetInfoPtr->getAttributeFunction != NULL && \
1207 keysetInfoPtr->setAttributeFunction != NULL ) );
1211 status = keysetInfoPtr->initFunction( keysetInfoPtr, name, nameLength,
1235 REQUIRES( auxDataPtr == NULL && auxValue == 0 );
1244 initStatus = openKeyset( &iCryptKeyset, createInfo->cryptOwner,
1245 createInfo->arg1, createInfo->strArg1,
1246 createInfo->strArgLen1, createInfo->arg2,
1251 if( keysetInfoPtr == NULL )
1252 return( initStatus );
1275 static int initLevel = 0;