int copyObjectAttributes(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, struct p11Object_t *pObject, struct attributesForObject_t *attr) { unsigned int i; int index, rc = CKR_OK; for (i = 0; (attr[i].attribute.type && (rc == CKR_OK)) ; i++) { index = findAttributeInTemplate(attr[i].attribute.type, pTemplate, ulCount); if (index == -1) { /* The attribute is not present - is it optional? */ if (attr[i].condition == AC_DEFAULT) { rc = addAttribute(pObject, &attr[i].attribute); } else if (attr[i].condition != AC_OPTIONAL) { /* the attribute is not optional */ #ifdef DEBUG debug("[createKeyObject] Error creating object - the following attribute is not present!"); dumpAttribute(&(attr[i].attribute)); #endif return CKR_TEMPLATE_INCOMPLETE; } } else { rc = addAttribute(pObject, &pTemplate[index]); } } return rc; }
bool SimpleTableDump::dump(std::string name, std::shared_ptr<AbstractTable> table) { verify(table); auto mainTable = std::dynamic_pointer_cast<Store>(table)->getMainTables()[0]; prepare(name); for(size_t i=0; i < mainTable->columnCount(); ++i) { // For each attribute dump dictionary and values dumpDictionary(name, mainTable, i); dumpAttribute(name, mainTable, i); } dumpHeader(name, mainTable); dumpMetaData(name, mainTable); return true; }
bool SimpleTableDump::dumpDelta(std::string name, atable_ptr_t table) { verify(table); auto deltaTable = std::dynamic_pointer_cast<Store>(table)->getDeltaTable(); prepare(name); for (size_t i = 0; i < deltaTable->columnCount(); ++i) { // For each attribute dump dictionary and values dumpDictionary(name, deltaTable, i, true); dumpAttribute(name, deltaTable, i); } dumpHeader(name, deltaTable); dumpMetaData(name, deltaTable); return true; }
int createStorageObject(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, struct p11Object_t *pObject) { int index; unsigned int i, rc; rc = createObject(pTemplate, ulCount, pObject); if (rc) { return rc; } for (i = 0; attributesStorageObject[i].attribute.type; i++) { index = findAttributeInTemplate(attributesStorageObject[i].attribute.type, pTemplate, ulCount); if (index == -1) { /* The attribute is not present - is it optional? */ if (attributesStorageObject[i].condition == AC_DEFAULT) { addAttribute(pObject, &attributesStorageObject[i].attribute); } else if (attributesStorageObject[i].condition != AC_OPTIONAL) { /* the attribute is not optional */ #ifdef DEBUG debug("[createStorageObject] Error creating storage object - the following attribute is not present!"); dumpAttribute(&(attributesStorageObject[i].attribute)); #endif removeAllAttributes(pObject); return CKR_TEMPLATE_INCOMPLETE; } } else { addAttribute(pObject, &pTemplate[index]); /* The object is public */ if ((pTemplate[index].type == CKA_PRIVATE ) && (*(CK_BBOOL *)pTemplate[index].pValue == CK_FALSE)) { pObject->publicObj = TRUE; } /* The object is a token object */ if ((pTemplate[index].type == CKA_TOKEN ) && (*(CK_BBOOL *)pTemplate[index].pValue == CK_TRUE)) { pObject->tokenObj = TRUE; } } } return 0; }
int dumpAttributeList(struct p11Object_t *pObject) { CK_ATTRIBUTE_PTR attr; struct p11Attribute_t *p11Attr; debug("\n******** attribute list for object ********\n"); p11Attr = pObject->attrList; while (p11Attr != NULL) { attr = &p11Attr->attrData; dumpAttribute(attr); p11Attr = p11Attr->next; } debug("\n******** end attribute list ********\n"); return 0; }