44 ( pkcs15infoPtr->iDlength != pkcs15objectInfo->
keyIDlength || \
45 memcmp( pkcs15infoPtr->iD, pkcs15objectInfo->keyID,
48 memcpy( pkcs15infoPtr->keyID, pkcs15objectInfo->keyID,
50 pkcs15infoPtr->keyIDlength = pkcs15objectInfo->
keyIDlength;
54 memcpy( pkcs15infoPtr->iAndSID, pkcs15objectInfo->iAndSID,
56 pkcs15infoPtr->iAndSIDlength = pkcs15objectInfo->
iAndSIDlength;
60 memcpy( pkcs15infoPtr->subjectNameID, pkcs15objectInfo->subjectNameID,
66 memcpy( pkcs15infoPtr->issuerNameID, pkcs15objectInfo->issuerNameID,
72 memcpy( pkcs15infoPtr->pgp2KeyID, pkcs15objectInfo->pgp2KeyID,
78 memcpy( pkcs15infoPtr->openPGPKeyID, pkcs15objectInfo->openPGPKeyID,
97 assert(
isReadPtr(
object, objectLength ) );
106 pkcs15infoPtr->pubKeyData = (
void * )
object;
108 pkcs15infoPtr->pubKeyOffset = pkcs15objectInfo->
pubKeyOffset;
109 pkcs15infoPtr->pubKeyUsage = pkcs15objectInfo->
pubKeyUsage;
114 pkcs15infoPtr->privKeyData = (
void * )
object;
116 pkcs15infoPtr->privKeyOffset = pkcs15objectInfo->
privKeyOffset;
117 pkcs15infoPtr->privKeyUsage = pkcs15objectInfo->
privKeyUsage;
123 pkcs15infoPtr->certData = (
void * )
object;
125 pkcs15infoPtr->certOffset = pkcs15objectInfo->
certOffset;
126 pkcs15infoPtr->trustedUsage = pkcs15objectInfo->
trustedUsage;
127 pkcs15infoPtr->implicitTrust = pkcs15objectInfo->
implicitTrust;
140 pkcs15infoPtr->dataType = pkcs15objectInfo->
dataType;
141 pkcs15infoPtr->dataData = (
void * )
object;
143 pkcs15infoPtr->dataOffset = pkcs15objectInfo->
dataOffset;
150 DEBUG_DIAG((
"Found unknown object type %d", type ));
180 assert(
isWritePtr( objectPtrPtr,
sizeof(
void * ) ) );
181 assert(
isWritePtr( objectLengthPtr,
sizeof(
int ) ) );
187 memset( pkcs15objectInfo, 0,
sizeof(
PKCS15_INFO ) );
188 *objectPtrPtr = NULL;
189 *objectLengthPtr = 0;
192 status = readRawObjectAlloc( stream, &objectData, &objectLength,
198 "Couldn't read PKCS #15 object data" ) );
202 sMemConnect( &objectStream, objectData, objectLength );
203 status = readObjectAttributes( &objectStream, pkcs15objectInfo, type,
205 sMemDisconnect( &objectStream );
208 clFree(
"readObject", objectData );
213 *objectPtrPtr = objectData;
228 int iterationCount,
status;
232 maxNoPkcs15objects ) );
235 REQUIRES( maxNoPkcs15objects >= 1 && \
237 REQUIRES( endPos > 0 && endPos > stell( stream ) && \
241 memset( pkcs15info, 0,
sizeof(
PKCS15_INFO ) * maxNoPkcs15objects );
244 for( status =
CRYPT_OK, iterationCount = 0;
248 static const MAP_TABLE tagToTypeTbl[] = {
260 int tag,
value, innerEndPos, innerIterationCount;
263 tag = peekTag( stream );
267 status = mapValue( tag, &value, tagToTypeTbl,
273 "Invalid PKCS #15 object type %02X", tag ) );
282 readConstructed( stream, NULL, tag );
286 if( innerEndPos < MIN_OBJECT_SIZE || innerEndPos >=
MAX_INTLENGTH )
290 "Invalid PKCS #15 object data size %d",
293 innerEndPos += stell( stream );
296 for( innerIterationCount = 0;
297 stell( stream ) < innerEndPos && \
299 innerIterationCount++ )
301 PKCS15_INFO pkcs15objectInfo, *pkcs15infoPtr = NULL;
306 status = readObject( stream, &pkcs15objectInfo, &
object,
307 &objectLength, type, errorInfo );
315 pkcs15infoPtr = findEntry( pkcs15info, maxNoPkcs15objects,
321 if( pkcs15infoPtr == NULL )
328 pkcs15infoPtr = findFreeEntry( pkcs15info,
329 maxNoPkcs15objects, &index );
330 if( pkcs15infoPtr == NULL )
332 clFree(
"readKeyset",
object );
335 "No more room in keyset to add further items" ) );
337 memcpy( pkcs15infoPtr, &pkcs15objectInfo,
343 copyObjectIdInfo( pkcs15infoPtr, &pkcs15objectInfo );
356 copyObjectPayloadInfo( pkcs15infoPtr, &pkcs15objectInfo,
357 object, objectLength, type );
359 ENSURES( innerIterationCount < FAILSAFE_ITERATIONS_LARGE );
361 ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );