DbUniqueRecord &uniqueId,
const CSSM_ACCESS_CREDENTIALS *cred)
{
- if (!data)
- return DbDbCursorImpl::next(attributes, data, uniqueId);
+ if (!data) {
+ return DbDbCursorImpl::next(attributes, data, uniqueId);
+ }
DbAttributes noAttrs, *attrs;
attrs = attributes ? attributes : &noAttrs;
+ // To comply with previous behavior, this method will not find symmetric or public/private keys
+ // if you ask for the data of each item.
+
// Get the datablob for this record
CssmDataContainer dataBlob(allocator());
for (;;)
if (!DbDbCursorImpl::next(attrs, &dataBlob, uniqueId))
return false;
- // Keep going until we find a non key type record.
CSSM_DB_RECORDTYPE rt = attrs->recordType();
- if (rt != CSSM_DL_DB_RECORD_SYMMETRIC_KEY
- && rt != CSSM_DL_DB_RECORD_PRIVATE_KEY
- && rt != CSSM_DL_DB_RECORD_PUBLIC_KEY)
+ if (rt == CSSM_DL_DB_RECORD_SYMMETRIC_KEY ||
+ rt == CSSM_DL_DB_RECORD_PRIVATE_KEY ||
+ rt == CSSM_DL_DB_RECORD_PUBLIC_KEY)
{
- // @@@ Check the label and if it doesn't start with the magic for a SSKey return the key.
+ // This is a key. Free it, and then check if we should return the item (but not the data)
+ database()->csp()->freeKey(*reinterpret_cast<CssmKey *>(dataBlob.Data));
+
+ if(!data) {
+ break;
+ }
+ } else {
+ // This is a non-key item. Return it.
break;
}
- else
+ }
+
+ // If the caller requested any data, return the data.
+ if(data) {
+ if (!SSGroupImpl::isGroup(dataBlob))
{
- // Free the key we just retrieved
- database()->csp()->freeKey(*reinterpret_cast<CssmKey *>(dataBlob.Data));
+ data->Data = dataBlob.Data;
+ data->Length = dataBlob.Length;
+ dataBlob.Data = NULL;
+ dataBlob.Length = 0;
+ return true;
}
- }
- if (!SSGroupImpl::isGroup(dataBlob))
- {
- data->Data = dataBlob.Data;
- data->Length = dataBlob.Length;
- dataBlob.Data = NULL;
- dataBlob.Length = 0;
- return true;
- }
+ // Get the group for dataBlob
+ SSGroup group(database(), dataBlob);
- // Get the group for dataBlob
- SSGroup group(database(), dataBlob);
+ // TODO: Add attrs to cred
- // Decode the dataBlob, pass in the DL allocator.
- group->decodeDataBlob(dataBlob, cred, database()->allocator(), *data);
+ // Decode the dataBlob, pass in the DL allocator.
+ group->decodeDataBlob(dataBlob, cred, database()->allocator(), *data);
+ }
return true;
}