91 #define PUBKEY_CERT_OBJECT ( ST_CERT_CERT | ST_CERT_ATTRCERT | \
92 ST_CERT_CERTCHAIN | ST_CERT_CERTREQ | \
94 #define PUBKEY_KEYSET_OBJECT ( ST_KEYSET_FILE | ST_KEYSET_FILE_PARTIAL | \
95 ST_KEYSET_FILE_RO | ST_KEYSET_DBMS | \
96 ST_KEYSET_DBMS_STORE | ST_KEYSET_HTTP | \
97 ST_KEYSET_LDAP | ST_DEV_P11 | \
98 ST_DEV_CAPI | ST_DEV_HW )
99 #define PRIVKEY_KEYSET_OBJECT ( ST_KEYSET_FILE | ST_KEYSET_FILE_PARTIAL | \
100 ST_KEYSET_FILE_RO | ST_DEV_P11 | \
101 ST_DEV_CAPI | ST_DEV_HW )
152 MESSAGE_CHECK_PKC_SIGCHECK ) },
351 CRYPT_ICERTFORMAT_CERTSET,
358 CRYPT_ICERTFORMAT_CERTSEQUENCE,
365 CRYPT_ICERTFORMAT_SSL_CERTCHAIN,
376 CRYPT_ICERTFORMAT_DATA,
475 {
MKACP_N( CRYPT_ICERTTYPE_CMS_CERTSET,
476 CRYPT_ICERTTYPE_CMS_CERTSET ),
478 CRYPT_IKEYID_ISSUERANDSERIALNUMBER ),
493 { CRYPT_ICERTTYPE_CMS_CERTSET }, &certSpecialACL },
508 static
BOOLEAN checkNumericRange(
const int value,
const int lowRange,
509 const int highRange )
513 REQUIRES_B( ( lowRange < 0 && highRange < 0 ) || \
514 ( lowRange >= 0 && highRange >= 0 && \
515 lowRange <= highRange ) );
523 if( value >= lowRange && value <= highRange )
531 if( value >= highRange && value <= lowRange )
543 const void *rangeInfo,
554 const int *allowedValuesInfo = rangeInfo;
557 for( i = 0; allowedValuesInfo[ i ] !=
CRYPT_ERROR && \
560 if( value == allowedValuesInfo[ i ] )
563 ENSURES( i < FAILSAFE_ITERATIONS_SMALL );
577 if( checkNumericRange( value, allowedValuesInfo[ i ].lowRange,
578 allowedValuesInfo[ i ].highRange ) )
581 ENSURES( i < FAILSAFE_ITERATIONS_SMALL );
594 static
BOOLEAN checkAttributeRangeWidechar(
const void *value,
600 const wchar_t *wcString =
value;
603 assert(
isReadPtr( value, valueLength ) );
605 REQUIRES_B( minLength >= 0 && maxLength >= 0 && \
606 minLength <= maxLength );
611 if( ( valueLength %
WCSIZE ) || ( valueLength < WCSIZE ) )
613 return( ( valueLength < minLength || valueLength > maxLength ) ? \
624 if( WCSIZE > 2 && *wcString < 0xFFFF )
626 return( ( valueLength < ( minLength * WCSIZE ) || \
627 valueLength > ( maxLength * WCSIZE ) ) ? \
634 if( ( valueLength > WCSIZE * 2 ) && \
635 ( wcString[ 0 ] < 0xFF && wcString[ 1 ] < 0xFF ) )
637 return( ( valueLength < ( minLength * WCSIZE ) || \
638 valueLength > ( maxLength * WCSIZE ) ) ? \
645 return( ( valueLength < minLength || valueLength > maxLength ) ? \
652 static
int checkActionPermitted(
const OBJECT_INFO *objectInfoPtr,
656 int requiredLevel, actualLevel;
680 if( requiredLevel < actualLevel )
703 assert( checkACLptr == NULL || \
705 assert( checkAltACLptr == NULL || \
713 if( checkACLptr != NULL )
715 if( checkAltACLptr != NULL )
716 *checkAltACLptr = NULL;
721 checkACL = &checkACLTbl[ messageValue - 1 ];
729 if( ( checkAltACL = checkACL->
altACL ) != NULL )
734 checkAltACL[ i ].object != objectType && \
736 ENSURES( i < FAILSAFE_ITERATIONS_MED );
739 checkAltACL = &checkAltACL[ i ];
742 checkACL = &checkACLTbl[ checkAltACL->
checkType - 1 ];
748 assert( checkACL->
altACL == NULL || \
751 if( checkACLptr != NULL )
752 *checkACLptr = checkACL;
753 if( checkAltACLptr != NULL )
754 *checkAltACLptr = checkAltACL;
776 const COMPARE_ACL *compareACL = &compareACLTbl[ i ];
795 paramInfo( compareACL, 0 ).highRange && \
817 const CHECK_ACL *checkACL = &checkACLTbl[ i ];
836 if( checkACL->altACL == NULL )
839 j < FAILSAFE_ITERATIONS_MED; j++ )
861 ENSURES( j < FAILSAFE_ITERATIONS_MED );
870 const ATTRIBUTE_ACL_ALT *formatACL = &formatPseudoACL[ i ];
878 DEBUG_DIAG((
"Certificate export ACLs inconsistent" ));
881 if( formatACL->
attribute < CRYPT_CERTFORMAT_LAST_EXTERNAL )
903 const CREATE_ACL *createACL = &createObjectACL[ i ];
928 DEBUG_DIAG((
"Create-object ACLs inconsistent" ));
935 DEBUG_DIAG((
"Create-object ACLs inconsistent" ));
946 const CREATE_ACL *createACL = &createObjectIndirectACL[ i ];
955 DEBUG_DIAG((
"Create-object indirect ACLs inconsistent" ));
967 DEBUG_DIAG((
"Create-object ACLs inconsistent" ));
974 DEBUG_DIAG((
"Create-object ACLs inconsistent" ));
981 krnlData = krnlDataPtr;
1046 int preDispatchCheckAttributeAccess(
IN_HANDLE const int objectHandle,
1051 const void *auxInfo )
1053 static const int FAR_BSS accessTypeTbl[ 7 ][ 2 ] = {
1065 const OBJECT_INFO *objectInfo = &objectTable[ objectHandle ];
1067 const int subType = objectInfo->
subType;
1073 assert( attributeACL->
attribute == messageValue );
1082 messageDataPtr != NULL );
1091 if( isInternalMessage )
1101 if( !( attributeACL->
access & accessType ) )
1107 !isInternalMessage )
1121 isInternalMessage );
1128 ENSURES( messageDataPtr == NULL );
1157 assert(
isReadPtr( messageDataPtr,
sizeof(
int ) ) );
1184 assert(
isReadPtr( messageDataPtr,
sizeof(
int ) ) );
1212 if( !checkNumericRange( *valuePtr, attributeACL->
lowRange,
1249 int objectParamHandle, objectParamSubType;
1253 assert(
isReadPtr( messageDataPtr,
sizeof(
int ) ) );
1298 objectParamSubType = objectTable[ objectParamHandle ].
subType;
1312 objectParamSubType ) || \
1314 objectParamSubType ) || \
1316 objectParamSubType ) );
1319 objectParamHandle ) );
1333 assert( !isInternalMessage || \
1335 ( ( msgData->data == NULL && msgData->
length == 0 ) || \
1336 ( msgData->
length >= 1 && \
1341 ( ( msgData->
length > 0 && \
1343 messageValue == CRYPT_IATTRIBUTE_ENTROPY ) ) ) );
1351 ( ( msgData->data == NULL && msgData->
length == 0 ) || \
1352 ( msgData->data != NULL && \
1353 msgData->
length >= 1 && \
1356 msgData->data != NULL && \
1357 ( ( msgData->
length > 0 && \
1359 messageValue == CRYPT_IATTRIBUTE_ENTROPY ) ) ) );
1373 if( !( ( msgData->data == NULL && msgData->
length == 0 ) || \
1374 ( msgData->
length > 0 && \
1387 if( !checkAttributeRangeSpecial( \
1397 if( !checkAttributeRangeWidechar( msgData->data,
1410 if( msgData->
length > 0 && \
1423 assert( !isInternalMessage || \
1427 msgData->
length ==
sizeof( time_t ) ) );
1432 msgData->data != NULL && \
1433 msgData->
length ==
sizeof( time_t ) ) );
1447 if( !( ( msgData->data == NULL && msgData->
length == 0 ) || \
1448 ( msgData->
length > 0 && \
1466 if( msgData->
length !=
sizeof( time_t ) )
1473 int iterationCount = 0;
1487 ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );
1491 return( preDispatchCheckAttributeAccess( objectHandle, message,
1492 messageDataPtr, messageValue, attributeACL ) );
1507 const void *messageDataPtr,
1512 const OBJECT_INFO *objectInfoPtr = &objectTable[ objectHandle ];
1524 compareACL = &compareACLTbl[ messageValue - 1 ];
1525 ENSURES( compareACL != NULL );
1562 msgData->data, msgData->length ) );
1578 messageDataPtr != NULL && \
1596 const OBJECT_INFO *objectInfoPtr = &objectTable[ objectHandle ];
1597 const CHECK_ACL *checkACL = NULL;
1604 messageValue < MESSAGE_CHECK_LAST );
1607 status = findCheckACL( messageValue, objectInfoPtr->
type,
1650 status = checkActionPermitted( objectInfoPtr, isInternalMessage ? \
1706 status = checkActionPermitted( objectInfoPtr, message );
1716 checkActionPermitted( objectInfoPtr, message ) ) );
1747 status = checkActionPermitted( &krnlData->
objectTable[ objectHandle ],
1767 const int messageValue,
1781 REQUIRES( messageACL->
type == ( message & MESSAGE_MASK ) );
1817 const int messageValue,
1819 const void *auxInfo )
1832 REQUIRES( messageACL->
type == ( message & MESSAGE_MASK ) );
1868 const void *messageDataPtr,
1869 IN_ENUM( CRYPT_CERTFORMAT )
const int messageValue,
1878 REQUIRES( messageDataPtr != NULL );
1888 for( i = 0; formatPseudoACL[ i ].attribute != messageValue &&
1898 assert( formatACL->
attribute == messageValue );
1901 return( preDispatchCheckAttributeAccess( objectHandle,
1904 messageDataPtr, messageValue, formatACL ) );
1911 int preDispatchCheckData(
IN_HANDLE const int objectHandle,
1914 const void *messageDataPtr,
1929 if( msgData->data == NULL )
1933 if( msgData->
length != 0 )
1938 if( msgData->
length <= 0 )
1946 msgData->data == NULL && msgData->
length == 0 ) || \
1947 ( msgData->data != NULL && msgData->
length > 0 ) );
1957 int preDispatchCheckCreate(
IN_HANDLE const int objectHandle,
1960 const void *messageDataPtr,
1961 IN_ENUM( OBJECT )
const int messageValue,
1968 createObjectACL : createObjectIndirectACL;
1969 const int createAclSize = \
1972 FAILSAFE_ARRAYSIZE( createObjectIndirectACL,
CREATE_ACL );
1991 for( i = 0; i < createAclSize && \
1992 createACL[ i ].type != messageValue &&
1996 createACL = &createACL[ i ];
2006 if( createInfo->
arg1 != 0 && \
2017 createInfo->
arg2 ) );
2021 createInfo->strArg1, createInfo->
strArgLen1 ) )
2024 createInfo->strArg2, createInfo->
strArgLen2 ) )
2037 const int ownerObject = objectTable[ objectHandle ].
owner;
2064 IN_ENUM( MESSAGE_USERMGMT )
const int messageValue,
2080 switch( messageValue )
2094 const void *messageDataPtr,
2125 return( preDispatchCheckAttributeAccess( objectHandle,
2129 trustMgmtPseudoACL ) );
2145 const void *messageDataPtr,
2146 const int messageValue,
2147 const void *auxInfo )
2162 REQUIRES( messageDataPtr != NULL );
2168 if( isInternalMessage )
2171 switch( localMessage )
2182 assert( attributeACL->
attribute == messageValue );
2190 ENSURES( attributeACL != NULL );
2201 objectHandle = *( (
int * ) messageDataPtr );
2286 CRYPT_IATTRIBUTE_INTERNAL );
2314 krnlData->objectTable[ dependentObject ].type :
CRYPT_ERROR;
2324 messageValue < MESSAGE_CHECK_LAST );
2329 status = findCheckACL( messageValue, objectInfoPtr->
type, NULL,
2336 if( checkAltACL != NULL )
2339 checkAltACL->
depObject != dependentType )
2365 localMessageValue );
2435 const int messageValue,
2447 messageValue == CRYPT_IATTRIBUTE_ENTROPY ) || \
2482 IN_ENUM( MESSAGE_USERMGMT )
const int messageValue,