30 #define PKCS11_FIND_VIA_CRYPTLIB
57 {
type, NULL_PTR, 0 };
61 assert(
isWritePtr( value,
sizeof(
void * ) ) );
62 assert(
isWritePtr( valueLength,
sizeof(
int ) ) );
63 assert(
isWritePtr( valueBuffer, valueBufLength ) );
72 status = C_GetAttributeValue( pkcs11Info->hSession, hObject,
79 if( valueTemplate.
ulValueLen > valueBufLength )
84 (
size_t ) ( valueTemplate.
ulValueLen ) ) ) == NULL )
88 valueTemplate.
pValue = valueBuffer;
91 status = C_GetAttributeValue( pkcs11Info->hSession, hObject,
95 if( valueTemplate.
pValue != valueBuffer )
99 *value = valueTemplate.
pValue;
106 static
void getAttributeValueEnd(
IN void *value,
107 const void *valueBuffer )
112 if( value != valueBuffer )
113 clFree(
"getAttributeValueEnd", value );
123 OUT_BUFFER( maxLabelSize, *labelLength )
char *label,
128 int localLabelLength, cryptStatus;
132 assert(
isWritePtr( labelLength,
sizeof(
int ) ) );
137 memset( label, 0, maxLabelSize );
140 cryptStatus = getAttributeValue( pkcs11Info, hObject,
CKA_LABEL,
141 &localLabel, &localLabelLength,
144 return( cryptStatus );
145 *labelLength =
min( localLabelLength, maxLabelSize );
147 memcpy( label, localLabel, *labelLength );
148 getAttributeValueEnd( localLabel, labelBuffer );
168 return( ( C_GetAttributeValue( pkcs11Info->
hSession, hObject,
169 &flagTemplate, 1 ) ==
CKR_OK && bFlag ) ? \
182 isMacAlgo( cryptAlgo ) ) ? \
185 isConvAlgo( cryptAlgo ) ) ? \
210 if( ( checkCrypt && readFlag( pkcs11Info, hObject,
CKA_ENCRYPT ) ) || \
211 ( checkWrap && readFlag( pkcs11Info, hObject,
CKA_WRAP ) ) )
217 readFlag( pkcs11Info, hObject,
CKA_DECRYPT ) ) || \
219 readFlag( pkcs11Info, hObject,
CKA_UNWRAP ) ) )
225 readFlag( pkcs11Info, hObject,
CKA_SIGN ) )
233 if( checkSign && readFlag( pkcs11Info, hObject,
CKA_VERIFY ) )
246 if( !( cryptAllowed && sigAllowed ) )
259 return( actionFlags );
265 static
int getMechanismInfo(
const PKCS11_INFO *pkcs11Info,
267 const void *capabilityInfoList,
277 const PKCS11_MECHANISM_INFO *mechanismInfoPtr;
278 int mechanismInfoSize, i;
284 REQUIRES( capabilityInfoList != NULL );
287 *capabilityInfoPtrPtr = NULL;
292 status = C_GetAttributeValue( pkcs11Info->
hSession, hObject,
293 &keyTypeTemplate, 1 );
307 capabilityInfoPtr = findCapabilityInfo( capabilityInfoList,
309 if( capabilityInfoPtr == NULL )
319 mechanismInfoPtr = getMechanismInfoPKC( &mechanismInfoSize );
321 mechanismInfoPtr = getMechanismInfoConv( &mechanismInfoSize );
322 for( i = 0; i < mechanismInfoSize && \
323 mechanismInfoPtr[ i ].keyType !=
keyType; i++ );
324 ENSURES( i < mechanismInfoSize );
325 mechanismInfoPtr = &mechanismInfoPtr[ i ];
326 *cryptAlgo = mechanismInfoPtr->cryptAlgo;
327 capabilityInfoPtr = findCapabilityInfo( capabilityInfoList, *cryptAlgo );
328 if( capabilityInfoPtr == NULL )
360 cryptStatus = readSequence( stream, NULL );
362 return( cryptStatus );
365 cryptStatus = getStreamObjectLength( stream, &length );
368 certTemplateI->ulValueLen =
length;
369 cryptStatus = sMemGetDataBlock( stream, &dataPtr, length );
373 certTemplateI->pValue = dataPtr;
374 cryptStatus = sSkip( stream, length );
377 return( cryptStatus );
380 cryptStatus = getStreamObjectLength( stream, &length );
383 certTemplateS->ulValueLen =
length;
384 cryptStatus = sMemGetDataBlock( stream, &dataPtr, length );
388 certTemplateS->pValue = dataPtr;
389 cryptStatus = sSkip( stream, length );
391 return( cryptStatus );
396 IN_BUFFER( iAndSLength )
const void *iAndSPtr,
403 assert(
isReadPtr( iAndSPtr, iAndSLength ) );
411 sMemConnect( &stream, iAndSPtr, iAndSLength );
412 cryptStatus = readIAndS( &stream, &certTemplate[ 0 ],
413 &certTemplate[ 1 ] );
414 sMemDisconnect( &stream );
415 return( cryptStatus );
443 assert(
isReadPtr( keyID, keyIDlength ) );
449 memcpy( iAndSTemplate, initTemplate, 4 *
sizeof(
CK_ATTRIBUTE ) );
450 cryptStatus = addIAndSToTemplate( &iAndSTemplate[ 2 ], keyID,
453 return( cryptStatus );
457 memcpy( iAndSTemplateAlt, iAndSTemplate, 4 *
sizeof(
CK_ATTRIBUTE ) );
458 sMemConnect( &stream, iAndSTemplateAlt[ 3 ].pValue,
459 iAndSTemplateAlt[ 3 ].ulValueLen );
460 cryptStatus = readGenericHole( &stream, &length, 1,
BER_INTEGER );
462 offset = stell( &stream );
463 sMemDisconnect( &stream );
465 return( cryptStatus );
466 iAndSTemplateAlt[ 3 ].
pValue = \
467 (
BYTE * ) iAndSTemplateAlt[ 3 ].pValue + offset;
500 cryptStatus = getAttributeValue( pkcs11Info, hCertificate,
CKA_VALUE,
501 &bufPtr, &length, buffer,
504 return( cryptStatus );
510 CRYPT_ICERTTYPE_DATAONLY );
514 getAttributeValueEnd( bufPtr, buffer );
517 return( cryptStatus );
543 status = C_GetAttributeValue( pkcs11Info->hSession, hCertificate,
548 status = C_GetAttributeValue( pkcs11Info->hSession, hCertificate,
555 return( instantiateCert( pkcs11Info, hCertificate, iCryptCert,
560 return( iCryptImportCertIndirect( iCryptCert, iCertSource,
561 CRYPT_IKEYID_KEYID, keyID, idTemplate.
ulValueLen,
603 REQUIRES( templateCount >= 1 && templateCount <= 64 );
606 *hObject = CK_OBJECT_NONE;
608 status = C_FindObjectsInit( pkcs11Info->hSession,
613 status = C_FindObjects( pkcs11Info->hSession, hObjectArray, 2,
615 if( C_FindObjectsFinal != NULL )
616 C_FindObjectsFinal( pkcs11Info->hSession );
619 if( ulObjectCount <= 0 )
621 if( ulObjectCount > 1 && onlyOne )
623 *hObject = hObjectArray[ 0 ];
640 REQUIRES( templateCount >= 1 && templateCount <= 64 );
642 return( findDeviceObjects( pkcs11Info, hObject,
643 objectTemplate, templateCount,
TRUE ) );
658 REQUIRES( templateCount >= 1 && templateCount <= 64 );
660 return( findDeviceObjects( pkcs11Info, hObject,
661 objectTemplate, templateCount,
FALSE ) );
685 *hObject = CK_OBJECT_NONE;
690 cryptStatus = getAttributeValue( pkcs11Info, hSourceObject,
CKA_ID,
691 &bufPtr, &length, buffer,
694 return( cryptStatus );
697 keyTemplate[ 1 ].
pValue = bufPtr;
699 cryptStatus = findObject( pkcs11Info, hObject, keyTemplate, 2 );
700 getAttributeValueEnd( bufPtr, buffer );
702 return( cryptStatus );
722 } FINDCERT_ACTION_TYPE;
729 IN_RANGE( 1, 64 )
const int templateCount,
742 hCertificate == NULL ) || \
743 ( iCryptCert == NULL && \
747 REQUIRES( templateCount >= 1 && templateCount <= 64 );
748 REQUIRES( ( iCryptCert != NULL && hCertificate == NULL ) || \
749 ( iCryptCert == NULL && hCertificate != NULL ) );
750 REQUIRES( findAction > FINDCERT_NONE && findAction < FINDCERT_LAST );
753 if( iCryptCert != NULL )
755 if( hCertificate != NULL )
756 *hCertificate = CK_OBJECT_NONE;
759 cryptStatus = findObject( pkcs11Info, &hFindCertificate, findTemplate,
762 return( cryptStatus );
763 if( findAction == FINDCERT_P11OBJECT )
765 *hCertificate = hFindCertificate;
769 return( getCertChain( pkcs11Info, iCertSource, hFindCertificate, iCryptCert,
770 ( findAction == FINDCERT_NORMAL ) ?
TRUE :
FALSE ) );
782 const FINDCERT_ACTION_TYPE findAction )
793 assert( ( label == NULL && labelLength == 0 ) || \
796 hCertificate == NULL ) || \
797 ( iCryptCert == NULL && \
801 REQUIRES( ( label == NULL && labelLength == 0 ) || \
804 REQUIRES( ( iCryptCert != NULL && hCertificate == NULL ) || \
805 ( iCryptCert == NULL && hCertificate != NULL ) );
806 REQUIRES( findAction > FINDCERT_NONE && findAction < FINDCERT_LAST );
809 if( iCryptCert != NULL )
811 if( hCertificate != NULL )
812 *hCertificate = CK_OBJECT_NONE;
819 certTemplate[ 2 ].
type = labelType;
823 return( findCertFromTemplate( pkcs11Info, iCertSource, certTemplate,
824 ( label == NULL ) ? 2 : 3, iCryptCert,
825 hCertificate, findAction ) );
836 const FINDCERT_ACTION_TYPE findAction )
847 assert(
isReadPtr( certID, certIDlength ) );
849 hCertificate == NULL ) || \
850 ( iCryptCert == NULL && \
855 REQUIRES( ( iCryptCert != NULL && hCertificate == NULL ) || \
856 ( iCryptCert == NULL && hCertificate != NULL ) );
857 REQUIRES( findAction > FINDCERT_NONE && findAction < FINDCERT_LAST );
860 if( iCryptCert != NULL )
862 if( hCertificate != NULL )
863 *hCertificate = CK_OBJECT_NONE;
866 return( findCertFromTemplate( pkcs11Info, iCertSource, certTemplate, 3,
867 iCryptCert, hCertificate, findAction ) );
876 const FINDCERT_ACTION_TYPE findAction )
887 REQUIRES( findAction > FINDCERT_NONE && findAction < FINDCERT_LAST );
895 cryptStatus = getAttributeValue( pkcs11Info, hObject,
CKA_ID, &bufPtr,
898 return( cryptStatus );
901 cryptStatus = findCertFromID( pkcs11Info, iCertSource, bufPtr, length,
902 iCryptCert, NULL, findAction );
903 getAttributeValueEnd( bufPtr, buffer );
904 return( cryptStatus );
926 #ifdef PKCS11_FIND_VIA_CRYPTLIB
931 IN_BUFFER( keyIDlength )
const void *keyID,
938 assert(
isReadPtr( keyID, keyIDlength ) );
943 keyIDtype == CRYPT_IKEYID_KEYID || \
944 keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER || \
963 CRYPT_IATTRIBUTE_HOLDERNAME );
965 return( cryptStatus );
966 if( msgData.
length != keyIDlength || \
967 strCompare( msgData.data, keyID, keyIDlength ) )
975 CRYPT_IATTRIBUTE_HOLDERURI );
977 return( cryptStatus );
978 if( msgData.
length != keyIDlength || \
979 strCompare( msgData.data, keyID, keyIDlength ) )
983 case CRYPT_IKEYID_KEYID:
988 case CRYPT_IKEYID_ISSUERANDSERIALNUMBER:
1013 IN_BUFFER( keyIDlength )
const void *keyID,
1032 hObject == NULL ) || \
1033 ( iCryptCert == NULL && \
1035 assert(
isReadPtr( keyID, keyIDlength ) );
1037 REQUIRES( ( iCryptCert != NULL && hObject == NULL ) || \
1038 ( iCryptCert == NULL && hObject != NULL ) );
1041 keyIDtype == CRYPT_IKEYID_KEYID || \
1042 keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER || \
1049 if( iCryptCert != NULL )
1051 if( hObject != NULL )
1052 *hObject = CK_OBJECT_NONE;
1054 status = C_FindObjectsInit( pkcs11Info->hSession,
1064 status = C_FindObjects( pkcs11Info->hSession, &hMatchObject, 1,
1071 if( ulObjectCount <= 0 )
1081 cryptStatus = instantiateCert( pkcs11Info, hMatchObject, &iMatchCert,
1082 ( keyIDtype == CRYPT_IKEYID_KEYID ) ? \
1091 cryptStatus = matchID( iMatchCert, keyIDtype, keyID, keyIDlength );
1095 hMatchedObject = hMatchObject;
1096 iMatchedCert = iMatchCert;
1114 hMatchedObject = CK_OBJECT_NONE;
1120 ENSURES( i < FAILSAFE_ITERATIONS_LARGE );
1121 if( C_FindObjectsFinal != NULL )
1122 C_FindObjectsFinal( pkcs11Info->hSession );
1131 if( iCryptCert != NULL )
1132 *iCryptCert = iMatchedCert;
1136 *hObject = hMatchedObject;
1140 return( cryptStatus );
1150 IN_BUFFER( keyIDlength )
const void *keyID,
1155 CK_ATTRIBUTE iAndSTemplate[ 4 + 8 ], iAndSTemplateAlt[ 4 + 8 ];
1156 #ifdef PKCS11_FIND_VIA_CRYPTLIB
1159 const FINDCERT_ACTION_TYPE findAction = \
1160 ( hCertificate != NULL ) ? FINDCERT_P11OBJECT : FINDCERT_NORMAL;
1165 hCertificate == NULL ) || \
1166 ( iCryptCert == NULL && \
1172 keyIDtype == CRYPT_IKEYID_KEYID || \
1173 keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER || \
1178 REQUIRES( ( iCryptCert != NULL && hCertificate == NULL ) || \
1179 ( iCryptCert == NULL && hCertificate != NULL ) );
1182 if( iCryptCert != NULL )
1184 if( hCertificate != NULL )
1185 *hCertificate = CK_OBJECT_NONE;
1189 case CRYPT_IKEYID_ISSUERANDSERIALNUMBER:
1190 cryptStatus = initIAndSTemplate( iAndSTemplate,
1192 keyID, keyIDlength );
1194 return( cryptStatus );
1195 cryptStatus = findCertFromTemplate( pkcs11Info, iCertSource,
1196 iAndSTemplate, 4, iCryptCert,
1199 cryptStatus = findCertFromTemplate( pkcs11Info, iCertSource,
1200 iAndSTemplateAlt, 4, iCryptCert,
1203 return( cryptStatus );
1206 case CRYPT_IKEYID_KEYID:
1207 cryptStatus = findCertFromID( pkcs11Info, iCertSource,
1208 keyID, keyIDlength, iCryptCert,
1209 hCertificate, findAction );
1211 return( cryptStatus );
1216 cryptStatus = findCertFromLabel( pkcs11Info, iCertSource,
1219 keyID, keyIDlength, iCryptCert,
1220 hCertificate, findAction );
1226 cryptStatus = findCertFromID( pkcs11Info, iCertSource,
1227 keyID, keyIDlength, iCryptCert,
1228 hCertificate, findAction );
1231 return( cryptStatus );
1241 #ifdef PKCS11_FIND_VIA_CRYPTLIB
1242 cryptStatus = searchDeviceObjects( pkcs11Info, NULL, &hFindCertificate,
1243 keyIDtype, keyID, keyIDlength,
1247 return( getCertChain( pkcs11Info, iCertSource, hFindCertificate,
1249 ( findAction == FINDCERT_NORMAL ) ? \
1254 return( cryptStatus );
1264 FIND_PUBPRIV_CERTVIAKEY,
1265 FIND_PUBPRIV_KEYVIACERT,
1267 } FIND_PUBPRIV_TYPE;
1274 FIND_PUBPRIV_TYPE *findType,
1284 ( isPublicKey ? &pubkeyClass : &privkeyClass ),
1293 assert(
isWritePtr( findType,
sizeof( FIND_PUBPRIV_TYPE ) ) );
1294 assert(
isReadPtr( keyID, keyIDlength ) );
1298 keyIDtype == CRYPT_IKEYID_KEYID );
1303 *hObject = CK_OBJECT_NONE;
1304 *hCertificate = CK_OBJECT_NONE;
1305 *findType = FIND_PUBPRIV_NONE;
1309 if( keyIDtype == CRYPT_IKEYID_KEYID )
1311 cryptStatus = findObject( pkcs11Info, hObject, keyTemplate, 2 );
1313 return( cryptStatus );
1321 cryptStatus = findObject( pkcs11Info, hObject, keyTemplate, 2 );
1324 return( cryptStatus );
1335 cryptStatus = findObject( pkcs11Info, hObject, keyTemplate, 2 );
1337 return( cryptStatus );
1342 *findType = FIND_PUBPRIV_CERTVIAKEY;
1350 #ifdef PKCS11_FIND_VIA_CRYPTLIB
1351 cryptStatus = searchDeviceObjects( pkcs11Info, NULL, hCertificate,
1352 keyIDtype, keyID, keyIDlength,
TRUE );
1354 return( cryptStatus );
1358 cryptStatus = findObjectFromObject( pkcs11Info, *hCertificate,
1361 return( cryptStatus );
1365 *findType = FIND_PUBPRIV_KEYVIACERT;
1387 const BOOLEAN nativeContext );
1403 int actionFlags, cryptStatus;
1420 actionFlags = getActionFlags( pkcs11Info, hObject, itemType, cryptAlgo );
1421 if( actionFlags <= 0 )
1437 return( cryptStatus );
1442 cryptStatus = rsaSetPublicComponents( pkcs11Info, iLocalContext,
1445 cryptStatus = dsaSetPublicComponents( pkcs11Info, iLocalContext,
1450 CRYPT_IATTRIBUTE_ACTIONPERMS );
1454 return( cryptStatus );
1456 *iCryptContext = iLocalContext;
1478 int actionFlags, labelLength, cryptStatus;
1499 if( readFlag( pkcs11Info, hObject,
CKA_TOKEN ) )
1503 actionFlags = getActionFlags( pkcs11Info, hObject, itemType, cryptAlgo );
1504 if( actionFlags <= 0 )
1513 cryptStatus = getObjectLabel( pkcs11Info, hObject, label,
1516 return( cryptStatus );
1517 if( labelLength <= 0 )
1523 cryptStatus = createContextFromCapability( &iLocalContext,
1524 iOwnerHandle, capabilityInfoPtr,
1527 return( cryptStatus );
1534 CRYPT_IATTRIBUTE_ACTIONPERMS );
1538 return( cryptStatus );
1552 &msgData, CRYPT_IATTRIBUTE_EXISTINGLABEL );
1567 cryptStatus = rsaSetPublicComponents( pkcs11Info, iLocalContext,
1575 CRYPT_IATTRIBUTE_KEYSIZE );
1581 CRYPT_IATTRIBUTE_DEVICEOBJECT );
1585 CRYPT_IATTRIBUTE_INITIALISED );
1599 return( cryptStatus );
1601 *iCryptContext = iLocalContext;
1614 IN_BUFFER( keyIDlength )
const void *keyID,
1634 assert(
isReadPtr( keyID, keyIDlength ) );
1637 keyIDtype == CRYPT_IKEYID_KEYID );
1646 if( keyIDtype == CRYPT_IKEYID_KEYID )
1650 cryptStatus = findObject( pkcs11Info, &hObject, keyTemplate, 2 );
1656 cryptStatus = findObject( pkcs11Info, &hObject, keyTemplate, 2 );
1660 return( cryptStatus );
1668 cryptStatus = getMechanismInfo( pkcs11Info, hObject,
1669 deviceInfo->capabilityInfoList,
1670 FALSE, &capabilityInfoPtr,
1673 return( cryptStatus );
1674 status = C_GetAttributeValue( pkcs11Info->hSession, hObject,
1675 &secKeySizeTemplate, 1 );
1680 return( createDeviceObject( pkcs11Info, iCryptHandle, hObject,
1682 deviceInfo->objectHandle, capabilityInfoPtr,
1693 IN_BUFFER( keyIDlength )
const void *keyID,
1699 static const MAP_TABLE keySizeMapTbl[] = {
1711 PKCS11_INFO *pkcs11Info = deviceInfo->devicePKCS11;
1718 assert(
isReadPtr( keyID, keyIDlength ) );
1719 assert( ( auxInfo == NULL && *auxInfoLength == 0 ) || \
1727 keyIDtype == CRYPT_IKEYID_KEYID || \
1728 keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER );
1731 REQUIRES( ( auxInfo == NULL && *auxInfoLength == 0 ) || \
1732 ( auxInfo != NULL && \
1733 *auxInfoLength > 0 && \
1742 return( getSecretKey( deviceInfo, pkcs11Info, iCryptHandle,
1743 keyIDtype, keyID, keyIDlength, flags ) );
1759 cryptStatus = findCert( pkcs11Info, deviceInfo->objectHandle,
1760 keyIDtype, keyID, keyIDlength, NULL,
1761 &hCertificateLabelObject );
1765 cryptStatus = findCert( pkcs11Info, deviceInfo->objectHandle,
1766 keyIDtype, keyID, keyIDlength,
1767 &iCryptCert, NULL );
1774 if( flags & KEYMGMT_FLAG_CHECK_ONLY )
1778 return( getObjectLabel( pkcs11Info, hCertificateLabelObject,
1779 auxInfo, *auxInfoLength,
1790 if( keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER )
1791 return( cryptStatus );
1800 if( keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER )
1802 CK_ATTRIBUTE iAndSTemplate[ 4 + 8 ], iAndSTemplateAlt[ 4 + 8 ];
1807 cryptStatus = initIAndSTemplate( iAndSTemplate, iAndSTemplateAlt,
1808 keyID, keyIDlength );
1810 return( cryptStatus );
1811 cryptStatus = findObject( pkcs11Info, &hCertificate,
1814 cryptStatus = findObject( pkcs11Info, &hCertificate,
1815 iAndSTemplateAlt, 4 );
1816 #ifdef PKCS11_FIND_VIA_CRYPTLIB
1818 cryptStatus = searchDeviceObjects( pkcs11Info, NULL,
1819 &hCertificate, keyIDtype,
1820 keyID, keyIDlength,
TRUE );
1826 cryptStatus = findObjectFromObject( pkcs11Info, hCertificate,
1829 return( cryptStatus );
1833 privateKeyViaCert =
TRUE;
1842 return( cryptStatus );
1847 FIND_PUBPRIV_TYPE findType;
1849 cryptStatus = findPubPrivKey( pkcs11Info, &hObject, &hCertificate,
1850 &findType, keyIDtype, keyID, keyIDlength,
1854 return( cryptStatus );
1857 case FIND_PUBPRIV_NONE:
1861 case FIND_PUBPRIV_CERTVIAKEY:
1865 certViaPrivateKey =
TRUE;
1868 case FIND_PUBPRIV_KEYVIACERT:
1871 privateKeyViaCert =
TRUE;
1898 ( keyIDtype == CRYPT_IKEYID_ISSUERANDSERIALNUMBER && \
1909 cryptStatus = findObject( pkcs11Info, &hObject,
1910 decryptKeyTemplate, 2 );
1915 cryptStatus = findObject( pkcs11Info, &hObject,
1916 decryptKeyTemplate, 2 );
1920 return( cryptStatus );
1923 ENSURES( hObject != CK_OBJECT_NONE );
1927 if( flags & KEYMGMT_FLAG_CHECK_ONLY )
1929 if( flags & KEYMGMT_FLAG_LABEL_ONLY )
1930 return( getObjectLabel( pkcs11Info, hObject, auxInfo, *auxInfoLength,
1935 cryptStatus = getMechanismInfo( pkcs11Info, hObject,
1936 deviceInfo->capabilityInfoList,
1937 TRUE, &capabilityInfoPtr, &cryptAlgo );
1939 return( cryptStatus );
1940 cryptStatus = mapValue( cryptAlgo, &keySize, keySizeMapTbl,
1944 status = C_GetAttributeValue( pkcs11Info->
hSession, hObject,
1945 &keySizeTemplate, 1 );
1977 if( privateKeyViaCert )
1980 REQUIRES( hCertificate != CK_OBJECT_NONE );
1984 cryptStatus = getCertChain( pkcs11Info, deviceInfo->objectHandle,
1985 hCertificate, &iCryptCert,
FALSE );
1987 return( cryptStatus );
1992 cryptStatus = findCertFromObject( pkcs11Info, deviceInfo->objectHandle,
1993 hObject, &iCryptCert,
1995 FINDCERT_NORMAL : FINDCERT_DATAONLY );
2004 return( cryptStatus );
2025 return( createNativeObject( pkcs11Info, iCryptHandle, hObject,
2028 cryptStatus = createDeviceObject( pkcs11Info, iCryptHandle, hObject,
2030 deviceInfo->ownerHandle,
2031 deviceInfo->objectHandle,
2037 return( cryptStatus );
2047 IN_BUFFER( keyIDlength )
const void *keyID,
2061 PKCS11_INFO *pkcs11Info = deviceInfo->devicePKCS11;
2066 assert(
isReadPtr( keyID, keyIDlength ) );
2067 assert(
isWritePtr( stateInfo,
sizeof(
int ) ) );
2069 REQUIRES( keyIDtype == CRYPT_IKEYID_KEYID );
2086 cryptStatus = findObject( pkcs11Info, &hCertificate, certTemplate, 3 );
2090 cryptStatus = instantiateCert( pkcs11Info, hCertificate, iCertificate,
2094 return( cryptStatus );
2102 INOUT int *stateInfo,
2113 PKCS11_INFO *pkcs11Info = deviceInfo->devicePKCS11;
2119 assert(
isWritePtr( stateInfo,
sizeof(
int ) ) );
2134 cryptStatus = dynCreate( &subjectDB, *stateInfo,
2135 CRYPT_IATTRIBUTE_ISSUER );
2137 return( cryptStatus );
2145 cryptStatus = findObject( pkcs11Info, &hCertificate, certTemplate, 3 );
2148 cryptStatus = instantiateCert( pkcs11Info, hCertificate, iCertificate,
2152 #ifdef PKCS11_FIND_VIA_CRYPTLIB
2155 cryptStatus = searchDeviceObjects( pkcs11Info, iCertificate, NULL,
2161 dynDestroy( &subjectDB );
2165 return( cryptStatus );
2184 deviceInfo->getItemFunction = getItemFunction;
2185 deviceInfo->getFirstItemFunction = getFirstItemFunction;
2186 deviceInfo->getNextItemFunction = getNextItemFunction;