methodtPkcs11Token.CreateDataObject
function CreateDataObject(const aValue : tBytes; const aDataLabel: string; aPrivate : Boolean; out aObject : CK_OBJECT_HANDLE): CK_RV;
Writes a CKO_DATA object -- arbitrary bytes under a label, on the token.
For small state that has to live somewhere the holder of a FILE cannot reach: a high-water mark, a counter, an anchor. Not for bulk data. A token's flash is finite, so write it when something changes and not on a schedule.
aPrivate=True requires a logged-in session to READ it back as well as to write it, which is usually what such state wants.
NOT EVERY TOKEN SUPPORTS THIS. A device may answer CKR_ATTRIBUTE_TYPE_INVALID, CKR_TEMPLATE_INCONSISTENT or CKR_FUNCTION_NOT_SUPPORTED, and that is a legitimate answer rather than a fault -- callers are expected to probe and have somewhere else to put it. Needs a read/write session: see ReopenReadWrite.