The SafeNet Authentication Client SDK allow you to create CKO_DATA object inside USB token, here is the sample code described in .net C#.
public static string createDataObject()
{
try
{
PKCS11.Initialize("etoken.dll");
PKCS11.Slot[] slots = PKCS11.GetSlotList(true);
if (slots.Length > 0)
{
PKCS11.Slot slot = slots[0];
PKCS11.Session session = PKCS11.OpenSession(slot, PKCS11.CKF_RW_SESSION | PKCS11.CKF_SERIAL_SESSION);
//create data object
List<PKCS11.Attribute> attListprv = new List<PKCS11.Attribute>();
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_CLASS, PKCS11.CKO_DATA));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_TOKEN, true));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_PRIVATE, true));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_LABEL, "MyObject"));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_VALUE, "your_value***"));
session.Login(1, "token_password***");
PKCS11.Object.Create(session, attListprv.ToArray());
return "data object created";
}
else
{
return "Token not found";
}
}
catch (Exception exc)
{
return "Error: invalid login or " + exc.Message;
}
}
public static string createDataObject()
{
try
{
PKCS11.Initialize("etoken.dll");
PKCS11.Slot[] slots = PKCS11.GetSlotList(true);
if (slots.Length > 0)
{
PKCS11.Slot slot = slots[0];
PKCS11.Session session = PKCS11.OpenSession(slot, PKCS11.CKF_RW_SESSION | PKCS11.CKF_SERIAL_SESSION);
//create data object
List<PKCS11.Attribute> attListprv = new List<PKCS11.Attribute>();
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_CLASS, PKCS11.CKO_DATA));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_TOKEN, true));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_PRIVATE, true));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_LABEL, "MyObject"));
attListprv.Add(new PKCS11.Attribute(PKCS11.CKA_VALUE, "your_value***"));
session.Login(1, "token_password***");
PKCS11.Object.Create(session, attListprv.ToArray());
return "data object created";
}
else
{
return "Token not found";
}
}
catch (Exception exc)
{
return "Error: invalid login or " + exc.Message;
}
}