73 status = mapValue( keyCryptAlgo, &value, tagMapTbl,
131 REQUIRES( dataType == CRYPT_IATTRIBUTE_CONFIGDATA || \
132 dataType == CRYPT_IATTRIBUTE_USERINDEX || \
133 dataType == CRYPT_IATTRIBUTE_USERID || \
134 dataType == CRYPT_IATTRIBUTE_USERINFO );
142 if( dataType == CRYPT_IATTRIBUTE_USERID )
150 memcpy( pkcs15info[ i ].iD, data, length );
151 pkcs15info[ i ].iDlength =
length;
153 ENSURES( i < FAILSAFE_ITERATIONS_MED );
163 pkcs15info[ i ].dataType == dataType )
165 pkcs15infoPtr = &pkcs15info[ i ];
169 ENSURES( i < FAILSAFE_ITERATIONS_MED );
170 if( pkcs15infoPtr == NULL )
177 pkcs15infoPtr = findFreeEntry( pkcs15info, noPkcs15objects, NULL );
179 if( pkcs15infoPtr == NULL )
191 pkcs15freeEntry( pkcs15infoPtr );
197 if( pkcs15infoPtr->dataData == NULL || \
200 newData =
clAlloc(
"addConfigData", dataLength );
201 if( newData == NULL )
205 if( pkcs15infoPtr->dataData != NULL )
208 clFree(
"addConfigData", pkcs15infoPtr->dataData );
215 newData = pkcs15infoPtr->dataData;
219 pkcs15infoPtr->dataData = newData;
220 memcpy( pkcs15infoPtr->dataData, data, dataLength );
264 msgData.data, msgData.
length,
269 pkcs15infoPtr = findFreeEntry( pkcs15info, noPkcs15objects, NULL );
270 if( pkcs15infoPtr == NULL )
315 assert( ( privkeyPresent &&
isReadPtr( password, passwordLength ) ) || \
316 ( ( !privkeyPresent || isStorageObject ) && \
317 password == NULL && passwordLength == 0 ) );
319 REQUIRES( ( privkeyPresent && password != NULL && \
322 ( ( !privkeyPresent || isStorageObject ) && \
323 password == NULL && passwordLength == 0 ) );
342 if( ( certPresent && pkcs15keyPresent ) ||
343 ( privkeyPresent && !pkcs15keyPresent ) )
348 &pubKeyAttributeSize, pkcs15infoPtr,
354 "Couldn't write PKCS #15 key attributes" ) );
360 if( certPresent && doAddCert )
373 if( pkcs15keyPresent )
375 status = pkcs15AddCert( pkcs15infoPtr, iCryptHandle,
381 status = pkcs15AddCert( pkcs15infoPtr, iCryptHandle, NULL, 0,
382 ( privkeyPresent || isStorageObject ) ? \
390 if( !privkeyPresent || pkcs15keyPresent )
398 ENSURES( privkeyPresent && !pkcs15keyPresent );
400 status = pkcs15AddPublicKey( pkcs15infoPtr, iCryptHandle,
401 pubKeyAttributes, pubKeyAttributeSize,
402 pkcCryptAlgo, modulusSize, isStorageObject,
409 return( pkcs15AddPrivateKey( pkcs15infoPtr, iCryptHandle, iOwnerHandle,
410 password, passwordLength, privKeyAttributes,
412 modulusSize, isStorageObject, errorInfo ) );