29 static
const VALIDITY_INFO *findValidityEntry(
const VALIDITY_INFO *listPtr,
35 const int vCheck = checksumData( value, valueLength );
38 assert(
isReadPtr( listPtr,
sizeof( VALIDITY_INFO ) ) );
39 assert(
isReadPtr( value, valueLength ) );
44 for( iterationCount = 0;
46 listPtr = listPtr->next, iterationCount++ )
48 if( listPtr->dCheck == vCheck && \
49 !memcmp( listPtr->data, value, valueLength ) )
52 ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_LARGE );
64 CERT_VAL_INFO *certValInfo = validityInfoPtr->cCertVal;
65 VALIDITY_INFO *validityEntry;
67 int certHashLength,
status;
76 if( certValInfo->validityInfo == NULL )
83 status = getCertComponent( (
CERT_INFO * ) certInfoPtr,
89 validityEntry = findValidityEntry( certValInfo->validityInfo,
90 certHash, certHashLength );
91 if( validityEntry == NULL )
96 certValInfo->currentValidity = validityEntry;
97 return( ( validityEntry->status ==
TRUE ) ? \
105 int addValidityEntry(
INOUT_PTR VALIDITY_INFO **listHeadPtrPtr,
107 IN_BUFFER( valueLength )
const void *value,
110 VALIDITY_INFO *newElement;
112 assert(
isWritePtr( listHeadPtrPtr,
sizeof( VALIDITY_INFO * ) ) );
113 assert( newEntryPosition == NULL || \
114 isWritePtr( newEntryPosition,
sizeof( VALIDITY_INFO * ) ) );
115 assert(
isReadPtr( value, valueLength ) );
120 if( newEntryPosition != NULL )
121 *newEntryPosition = NULL;
124 if( *listHeadPtrPtr != NULL && \
125 findValidityEntry( *listHeadPtrPtr, value, valueLength ) != NULL )
133 if( ( newElement = ( VALIDITY_INFO * ) \
134 clAlloc(
"addValidityEntry",
sizeof( VALIDITY_INFO ) ) ) == NULL )
136 memset( newElement, 0,
sizeof( VALIDITY_INFO ) );
137 memcpy( newElement->data, value, valueLength );
138 newElement->dCheck = checksumData( value, valueLength );
142 if( newEntryPosition != NULL )
143 *newEntryPosition = newElement;
150 void deleteValidityEntries(
INOUT_PTR VALIDITY_INFO **listHeadPtrPtr )
152 VALIDITY_INFO *entryListPtr = *listHeadPtrPtr;
155 assert(
isWritePtr( listHeadPtrPtr,
sizeof( VALIDITY_INFO * ) ) );
157 *listHeadPtrPtr = NULL;
160 for( iterationCount = 0;
164 VALIDITY_INFO *itemToFree = entryListPtr;
166 entryListPtr = entryListPtr->next;
167 if( itemToFree->attributes != NULL )
168 deleteAttributes( &itemToFree->attributes );
169 zeroise( itemToFree,
sizeof( VALIDITY_INFO ) );
170 clFree(
"deleteValidityEntries", itemToFree );
172 ENSURES_V( iterationCount < FAILSAFE_ITERATIONS_LARGE );
178 int copyValidityEntries(
INOUT_PTR VALIDITY_INFO **destListHeadPtrPtr,
181 const VALIDITY_INFO *srcListCursor;
185 assert(
isWritePtr( destListHeadPtrPtr,
sizeof( VALIDITY_INFO * ) ) );
186 assert( *destListHeadPtrPtr == NULL );
187 assert(
isReadPtr( srcListPtr,
sizeof( VALIDITY_INFO ) ) );
191 REQUIRES( *destListHeadPtrPtr == NULL );
194 for( srcListCursor = srcListPtr, iterationCount = 0;
196 srcListCursor = srcListCursor->next, iterationCount++ )
198 VALIDITY_INFO *newElement;
203 if( ( newElement = ( VALIDITY_INFO * ) \
204 clAlloc(
"copyValidityEntries", \
205 sizeof( VALIDITY_INFO ) ) ) == NULL )
207 memcpy( newElement, srcListCursor,
sizeof( VALIDITY_INFO ) );
208 newElement->attributes = NULL;
209 newElement->next = NULL;
214 newElement->status =
FALSE;
220 destListCursor = newElement;
222 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
231 int prepareValidityEntries(
IN_OPT const VALIDITY_INFO *listPtr,
238 const VALIDITY_INFO *validityEntry;
241 assert( listPtr == NULL || \
242 isReadPtr( listPtr,
sizeof( VALIDITY_INFO ) ) );
243 assert(
isWritePtr( errorEntry,
sizeof( VALIDITY_INFO * ) ) );
251 if( listPtr == NULL )
255 for( validityEntry = listPtr, iterationCount = 0;
257 validityEntry = validityEntry->next, iterationCount++ )
262 if( validityEntry->attributes == NULL )
266 validityEntry->attributes,
267 errorLocus, errorType );
271 *errorEntry = ( VALIDITY_INFO * ) validityEntry;
275 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
291 VALIDITY_INFO *validityInfo;
301 for( validityInfo = certInfoPtr->cCertVal->validityInfo,
303 validityInfo != NULL && iterationCount < FAILSAFE_ITERATIONS_LARGE;
304 validityInfo = validityInfo->next, iterationCount++ )
318 validityInfo->status =
TRUE;
325 validityInfo->status =
FALSE;
330 ENSURES( iterationCount < FAILSAFE_ITERATIONS_LARGE );
353 int sizeofRtcsRequestEntry(
INOUT VALIDITY_INFO *rtcsEntry )
355 assert(
isWritePtr( rtcsEntry,
sizeof( VALIDITY_INFO ) ) );
357 return( (
int ) sizeofObject( sizeofObject(
KEYID_SIZE ) ) );
362 INOUT_PTR VALIDITY_INFO **listHeadPtrPtr,
369 assert(
isWritePtr( listHeadPtrPtr,
sizeof( VALIDITY_INFO * ) ) );
373 status = readSequence( stream, &length );
376 endPos = stell( stream ) +
length;
385 status = readUniversal( stream );
388 status = addValidityEntry( listHeadPtrPtr, NULL,
395 const VALIDITY_INFO *rtcsEntry )
398 assert(
isReadPtr( rtcsEntry,
sizeof( VALIDITY_INFO ) ) );
401 writeSequence( stream, sizeofObject(
KEYID_SIZE ) );
402 return( writeOctetString( stream, rtcsEntry->data,
KEYID_SIZE,
421 int sizeofRtcsResponseEntry(
INOUT VALIDITY_INFO *rtcsEntry,
426 assert(
isWritePtr( rtcsEntry,
sizeof( VALIDITY_INFO ) ) );
429 if( !isFullResponse )
431 return( (
int ) sizeofObject( sizeofObject(
KEYID_SIZE ) + \
444 ( ( rtcsEntry->attributeSize ) ? \
445 (
int ) sizeofObject( rtcsEntry->attributeSize ) : 0 ) ) );
450 INOUT_PTR VALIDITY_INFO **listHeadPtrPtr,
454 VALIDITY_INFO *newEntry;
459 assert(
isWritePtr( listHeadPtrPtr,
sizeof( VALIDITY_INFO * ) ) );
463 status = readSequence( stream, &length );
466 endPos = stell( stream ) +
length;
475 status = addValidityEntry( listHeadPtrPtr, &newEntry,
496 newEntry->extStatus = newEntry->status ? \
508 status = readConstructed( stream, &length, 0 );
511 return( readAttributes( stream, &newEntry->attributes,
513 &certInfoPtr->errorLocus,
514 &certInfoPtr->errorType ) );
519 const VALIDITY_INFO *rtcsEntry,
525 assert(
isReadPtr( rtcsEntry,
sizeof( VALIDITY_INFO ) ) );
532 if( !isFullResponse )
534 writeSequence( stream, sizeofObject(
KEYID_SIZE ) +
537 return( writeBoolean( stream, rtcsEntry->status,
DEFAULT_TAG ) );
543 status = writeEnumerated( stream, rtcsEntry->extStatus,
DEFAULT_TAG );
550 return( writeAttributes( stream, rtcsEntry->attributes,