33 IN_FLAGS_Z( ACTION_PERM )
const int actionFlags )
48 if( actionFlags != 0 )
52 CRYPT_IATTRIBUTE_ACTIONPERMS );
56 if( pkcs15infoPtr->openPGPKeyIDlength > 0 )
61 pkcs15infoPtr->openPGPKeyIDlength );
63 &msgData, CRYPT_IATTRIBUTE_KEYID_OPENPGP );
77 &msgData, CRYPT_IATTRIBUTE_PGPVALIDITY );
96 static int trustedCertIndex;
98 int certStartOffset, certDataTotalSize;
103 assert(
isWritePtr( dataLength,
sizeof(
int ) ) );
109 memset( data, 0,
min( 16, dataMaxLength ) );
119 trustedCertIndex = 0;
123 if( trustedCertIndex >= noPkcs15objects - 1 )
129 for( pkcs15infoPtr = NULL;
130 trustedCertIndex < noPkcs15objects && \
133 if( pkcs15info[ trustedCertIndex ].implicitTrust )
135 pkcs15infoPtr = &pkcs15info[ trustedCertIndex ];
139 ENSURES( trustedCertIndex < FAILSAFE_ITERATIONS_MED );
140 if( pkcs15infoPtr == NULL )
147 certDataTotalSize - certStartOffset,
148 certDataTotalSize ) );
149 return( attributeCopyParams( data, dataMaxLength, dataLength,
150 (
BYTE * ) pkcs15infoPtr->certData + certStartOffset,
151 certDataTotalSize - certStartOffset ) );
157 static
int getConfigItem(
IN_ARRAY( noPkcs15objects ) \
166 int dataStartOffset, dataTotalSize, i;
170 assert( ( data == NULL && dataMaxLength == 0 ) || \
172 assert(
isWritePtr( dataLength,
sizeof(
int ) ) );
175 REQUIRES( dataType == CRYPT_IATTRIBUTE_CONFIGDATA || \
176 dataType == CRYPT_IATTRIBUTE_USERINDEX || \
177 dataType == CRYPT_IATTRIBUTE_USERINFO );
178 REQUIRES( ( data == NULL && dataMaxLength == 0 ) || \
180 dataMaxLength >= 16 && \
186 memset( data, 0,
min( 16, dataMaxLength ) );
189 for( pkcs15infoPtr = NULL, i = 0;
193 pkcs15info[ i ].dataType == dataType ) )
195 pkcs15infoPtr = &pkcs15info[ i ];
199 ENSURES( i < FAILSAFE_ITERATIONS_MED );
200 if( pkcs15infoPtr == NULL )
208 *dataLength = dataTotalSize - dataStartOffset;
214 dataTotalSize - dataStartOffset,
216 return( attributeCopyParams( data, dataMaxLength, dataLength,
217 (
BYTE * ) pkcs15infoPtr->dataData + dataStartOffset,
218 dataTotalSize - dataStartOffset ) );
248 ( keysetInfoPtr->keysetFile->iHardwareDevice !=
CRYPT_UNUSED ) ? \
251 int pubkeyActionFlags = 0, privkeyActionFlags = 0,
status;
255 assert(
isReadPtr( keyID, keyIDlength ) );
256 assert( ( auxInfo == NULL && auxInfoMaxLength == 0 ) || \
257 isReadPtr( auxInfo, auxInfoMaxLength ) );
265 keyIDtype == CRYPT_IKEYID_KEYID || \
266 keyIDtype == CRYPT_IKEYID_PGPKEYID || \
267 keyIDtype == CRYPT_IKEYID_ISSUERID );
270 REQUIRES( ( auxInfo == NULL && *auxInfoLength == 0 ) || \
271 ( auxInfo != NULL && \
272 *auxInfoLength > 0 && \
283 pkcs15infoPtr = findEntry( keysetInfoPtr->keyData,
284 keysetInfoPtr->keyDataNoObjects, keyIDtype,
285 keyID, keyIDlength, flags );
286 if( pkcs15infoPtr == NULL )
290 "No information present for this ID" ) );
292 if( pkcs15infoPtr->pubKeyData == NULL && \
293 pkcs15infoPtr->certData == NULL )
299 "No public key or certificate data present for this ID" ) );
301 if( !publicComponentsOnly && pkcs15infoPtr->privKeyData == NULL )
306 "No private key data present for this ID" ) );
315 return( attributeCopyParams( auxInfo, auxInfoMaxLength,
316 auxInfoLength, pkcs15infoPtr->label,
324 if( !publicComponentsOnly && !isStorageObject && auxInfo == NULL )
328 status = readPublicKeyComponents( pkcs15infoPtr, keysetInfoPtr->objectHandle,
329 keyIDtype, keyID, keyIDlength,
330 publicComponentsOnly,
332 keysetInfoPtr->keysetFile->iHardwareDevice : \
334 &iCryptContext, &iDataCert,
342 if( publicComponentsOnly )
344 status = setKeyAttributes( iCryptContext, pkcs15infoPtr,
345 ( pkcs15infoPtr->pubKeyData != NULL ) ? \
346 pubkeyActionFlags : 0 );
352 "Couldn't set PKCS #15 permitted action flags for "
360 REQUIRES( ( pkcs15infoPtr->pubKeyData != NULL || \
361 pkcs15infoPtr->certData != NULL ) && \
362 pkcs15infoPtr->privKeyData != NULL );
377 &msgData, isStorageObject ? \
378 CRYPT_IATTRIBUTE_EXISTINGLABEL : \
382 status = readPrivateKeyComponents( pkcs15infoPtr, iCryptContext,
383 auxInfo, *auxInfoLength, isStorageObject,
407 "Couldn't attach certificate to key" ) );
412 status = setKeyAttributes( iCryptContext, pkcs15infoPtr,
413 privkeyActionFlags );
419 "Couldn't set PKCS #15 permitted action flags for the "
438 assert( ( data == NULL && dataMaxLength == 0 ) || \
440 assert(
isWritePtr( dataLength,
sizeof(
int ) ) );
442 REQUIRES( dataType == CRYPT_IATTRIBUTE_CONFIGDATA || \
443 dataType == CRYPT_IATTRIBUTE_USERINDEX || \
444 dataType == CRYPT_IATTRIBUTE_USERINFO || \
445 dataType == CRYPT_IATTRIBUTE_TRUSTEDCERT || \
446 dataType == CRYPT_IATTRIBUTE_TRUSTEDCERT_NEXT );
447 REQUIRES( ( data == NULL && dataMaxLength == 0 ) || \
450 REQUIRES( ( dataType != CRYPT_IATTRIBUTE_TRUSTEDCERT && \
451 dataType != CRYPT_IATTRIBUTE_TRUSTEDCERT_NEXT ) || \
456 memset( data, 0,
min( 16, dataMaxLength ) );
461 if( dataType == CRYPT_IATTRIBUTE_TRUSTEDCERT || \
462 dataType == CRYPT_IATTRIBUTE_TRUSTEDCERT_NEXT )
465 keysetInfoPtr->keyDataNoObjects,
466 data, dataMaxLength, dataLength,
467 ( dataType == CRYPT_IATTRIBUTE_TRUSTEDCERT ) ? \
472 return( getConfigItem( keysetInfoPtr->keyData,
473 keysetInfoPtr->keyDataNoObjects, dataType,
474 data, dataMaxLength, dataLength ) );
490 IN_BUFFER( keyIDlength )
const void *keyID,
499 int certStartOffset, certDataTotalSize,
tag,
status;
504 assert(
isReadPtr( stateInfo,
sizeof(
int ) ) );
505 assert(
isReadPtr( keyID, keyIDlength ) );
510 keyIDtype == CRYPT_IKEYID_KEYID || \
511 keyIDtype == CRYPT_IKEYID_PGPKEYID || \
512 keyIDtype == CRYPT_IKEYID_ISSUERID || \
520 KEYMGMT_MASK_USAGEOPTIONS );
528 pkcs15infoPtr = findEntry( pkcs15info, noPkcs15objects, keyIDtype,
529 keyID, keyIDlength, options );
530 if( pkcs15infoPtr == NULL )
532 *stateInfo = pkcs15infoPtr->
index;
542 certDataPtr = (
BYTE * ) pkcs15infoPtr->certData + \
549 certDataTotalSize - certStartOffset,
550 certDataTotalSize ) );
552 certDataTotalSize - certStartOffset,
554 CRYPT_ICERTTYPE_DATAONLY : \
564 "Couldn't create certificate from stored certificate "
573 ( void ) getValidityInfo( pkcs15info, createInfo.
cryptHandle );
585 IN_BUFFER( keyIDlength )
const void *keyID,
590 const int noPkcs15objects = keysetInfoPtr->keyDataNoObjects;
596 assert(
isReadPtr( stateInfo,
sizeof(
int ) ) );
597 assert(
isReadPtr( keyID, keyIDlength ) );
603 keyIDtype == CRYPT_IKEYID_KEYID || \
604 keyIDtype == CRYPT_IKEYID_PGPKEYID || \
605 keyIDtype == CRYPT_IKEYID_ISSUERID );
612 KEYMGMT_MASK_USAGEOPTIONS );
618 return( getItem( pkcs15info, noPkcs15objects, iCertificate, stateInfo,
619 keyIDtype, keyID, keyIDlength, itemType, options,
626 INOUT int *stateInfo,
630 const int noPkcs15objects = keysetInfoPtr->keyDataNoObjects;
636 assert(
isWritePtr( stateInfo,
sizeof(
int ) ) );
644 REQUIRES( ( lastEntry >= 0 && lastEntry < noPkcs15objects ) || \
657 "No more items present" ) );
659 ENSURES( lastEntry >= 0 && lastEntry < noPkcs15objects );
663 if( pkcs15info[ lastEntry ].issuerNameIDlength <= 0 )
667 "No index information available to locate other "
673 status = getItem( pkcs15info, noPkcs15objects, iCertificate, stateInfo,
675 pkcs15info[ lastEntry ].issuerNameID,
676 pkcs15info[ lastEntry ].issuerNameIDlength,
680 ENSURES( lastEntry != *stateInfo );
700 keysetInfoPtr->getItemFunction = getItemFunction;
701 keysetInfoPtr->getSpecialItemFunction = getSpecialItemFunction;
702 keysetInfoPtr->getFirstItemFunction = getFirstItemFunction;
703 keysetInfoPtr->getNextItemFunction = getNextItemFunction;