18 #ifdef USE_CERTIFICATES
27 #define FAILSAFE_ITERATIONS_LARGE_SPECIAL ( FAILSAFE_ITERATIONS_LARGE * 10 )
48 assert( attributeListPtr == NULL || \
53 REQUIRES( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
56 ( subFieldID >= CRYPT_CERTINFO_FIRST_NAME && \
57 subFieldID <= CRYPT_CERTINFO_LAST_GENERALNAME ) );
64 if( attributeInfoPtr == NULL )
66 if( attributeListPtr != NULL && \
135 assert( attributeListPtr == NULL || \
139 assert(
isWritePtr( newDataLength,
sizeof(
int ) ) );
142 REQUIRES( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
145 ( subFieldID >= CRYPT_CERTINFO_FIRST_NAME && \
146 subFieldID <= CRYPT_CERTINFO_LAST_GENERALNAME ) );
157 if( attributeInfoPtr == NULL )
159 if( attributeListPtr != NULL && \
164 ( flags & ATTR_FLAG_MULTIVALUED ) ) )
203 status = textToOID( data, dataLength, binaryOID,
MAX_OID_SIZE,
221 if( dataLength < attributeInfoPtr->lowRange || \
222 dataLength > attributeInfoPtr->
highRange )
240 status = checkObjectEncoding( data, dataLength );
251 const int firstByte = ( (
BYTE * ) data )[ 0 ];
273 status = checkObjectEncoding( data, dataLength );
284 const char *dataPtr =
data;
303 if( !checkTextStringData( data, dataLength,
330 assert( attributeListPtr == NULL || \
334 REQUIRES( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
337 ( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
341 *insertPointPtrPtr = NULL;
345 for( insertPoint = attributeListPtr, iterationCount = 0;
346 insertPoint != NULL && \
348 insertPoint->fieldID <= fieldID && \
349 iterationCount < FAILSAFE_ITERATIONS_LARGE_SPECIAL;
363 insertPoint->
fieldID == fieldID && \
367 prevElement = insertPoint;
368 insertPoint = insertPoint->
next;
370 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE_SPECIAL );
390 IN_BUFFER( dataLength )
const void *data,
418 if( !( flags & ATTR_FLAG_BLOB ) && \
419 oidToAttribute( attributeType, oid, oidLength ) != NULL )
423 if( *listHeadPtr != NULL )
428 for( insertPoint = *listHeadPtr, iterationCount = 0;
430 insertPoint = insertPoint->
next, iterationCount++ )
433 if( checkAttributeProperty( insertPoint,
436 !memcmp( insertPoint->
oid, oid, oidLength ) )
439 prevElement = insertPoint;
441 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
442 insertPoint = prevElement;
450 dataLength + oidLength ) ) == NULL )
454 memcpy( newElement->
oid, oid, oidLength );
457 memcpy( newElement->value, data, dataLength );
460 insertPoint, newElement, newElement );
481 ( fieldID >= CRYPT_CERTINFO_FIRST_CMS ) ? \
485 fieldID, subFieldID, &attributeID );
495 REQUIRES( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
498 ( subFieldID >= CRYPT_CERTINFO_FIRST_NAME && \
499 subFieldID <= CRYPT_CERTINFO_LAST_GENERALNAME ) );
500 assert( ( flags & ~(
ATTR_FLAG_CRITICAL | ATTR_FLAG_MULTIVALUED | ATTR_FLAG_BLOB_PAYLOAD ) ) == 0 );
504 ENSURES( attributeInfoPtr != NULL );
507 status = checkAttributeField( *attributeListPtr, attributeInfoPtr,
508 fieldID, subFieldID, value, flags,
522 status = findFieldInsertLocation( *attributeListPtr, &insertPoint,
523 fieldID, subFieldID );
528 clAlloc(
"addAttributeField", \
535 newElement->
flags = flags;
584 IN_BUFFER( dataLength )
const void *data,
593 ( fieldID >= CRYPT_CERTINFO_FIRST_CMS ) ? \
597 fieldID, subFieldID, &attributeID );
600 int storageSize = 0, newDataLength,
status;
608 REQUIRES( fieldID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
611 ( subFieldID >= CRYPT_CERTINFO_FIRST_NAME && \
612 subFieldID <= CRYPT_CERTINFO_LAST_GENERALNAME ) );
614 assert( ( flags & ~( ATTR_FLAG_BLOB_PAYLOAD |
ATTR_FLAG_CRITICAL | ATTR_FLAG_MULTIVALUED | ATTR_FLAG_BLOB_PAYLOAD ) ) == 0 );
618 ENSURES( attributeInfoPtr != NULL );
621 status = checkAttributeFieldString( *attributeListPtr, attributeInfoPtr,
622 fieldID, subFieldID, data,
623 dataLength, flags, &newDataLength,
637 status = findFieldInsertLocation( *attributeListPtr, &insertPoint,
638 fieldID, subFieldID );
642 if( newDataLength != 0 )
648 storageSize = newDataLength;
658 storageSize ) ) == NULL )
664 newElement->
flags = flags;
673 memcpy( newElement->value, data, dataLength );
678 status = textToOID( data, dataLength, newElement->value,
691 newElement->value = (
void * ) data;
695 memcpy( newElement->value, data, dataLength );
728 assert( listCursorPtr == NULL || \
731 assert( dnCursor == NULL || \
739 if( listCursorPtr != NULL && *listCursorPtr == listItem )
740 *listCursorPtr = ( listNextPtr != NULL ) ? listNextPtr : listPrevPtr;
750 if( dnCursor != NULL && dnCursor == &listItem->value )
752 deleteDN( (
DN_PTR ** ) &listItem->value );
755 clFree(
"deleteAttributeField", listItem );
778 assert( dnCursor == NULL || \
785 for( attributeListCursor = listItem, \
787 attributeListCursor != NULL && \
788 attributeListCursor->
attributeID == attributeID && \
789 attributeListCursor->fieldID == fieldID && \
795 attributeListCursor = attributeListCursor->
next;
796 if( deleteAttributeField( attributePtr, listCursorPtr,
804 ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );
820 int iterationCount, status =
CRYPT_OK;
824 assert( listCursorPtr == NULL || \
827 assert( dnCursor == NULL || \
832 if( checkAttributeProperty( listItem,
835 return( deleteAttributeField( attributeListPtr, listCursorPtr,
840 assert( !checkAttributeProperty( listItem,
845 ENSURES( attributeListCursor != NULL );
849 for( iterationCount = 0;
850 attributeListCursor != NULL && \
851 attributeListCursor->
attributeID == attributeID && \
858 attributeListCursor = attributeListCursor->
next;
859 localStatus = deleteAttributeField( attributeListPtr, listCursorPtr,
860 itemToFree, dnCursor );
865 status = localStatus;
868 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
885 assert( dnCursor == NULL || \
888 REQUIRES( attributeID >= CRYPT_CERTINFO_FIRST_EXTENSION && \
894 for( attributeListCursor = *attributeListPtr, iterationCount = 0;
895 attributeListCursor != NULL && \
896 attributeListCursor->
attributeID != attributeID && \
898 attributeListCursor = attributeListCursor->
next, iterationCount++ );
899 ENSURES( attributeListCursor != NULL );
903 return( deleteAttributeField( attributeListPtr, listCursorPtr,
904 attributeListCursor, dnCursor ) );
918 if( attributeListCursor == NULL )
922 for( iterationCount = 0;
923 attributeListCursor != NULL && \
924 iterationCount < FAILSAFE_ITERATIONS_LARGE_SPECIAL;
929 attributeListCursor = attributeListCursor->
next;
930 deleteAttributeField( attributeListPtr, NULL, itemToFree, NULL );
932 ENSURES_V( iterationCount < FAILSAFE_ITERATIONS_LARGE_SPECIAL );