EldoS | Feel safer!

Software components for data protection, secure storage and transfer

storing data objects on smart card token

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#13592
Posted: 06/06/2010 14:22:48
by Tomislav Jakopović (Basic support level)
Joined: 05/22/2010
Posts: 38

Hi,

I try to store a simple data object on the token using TEIPKCS11SessionInfo object.

Quote

SBPKCS11Base.TElPKCS11DataObject obj = new SBPKCS11Base.TElPKCS11DataObject();

obj.Value = new byte[] { 0x56, 0x45 };
obj.ObjectLabel = "StudentData";
sessionInfo.AddObject(TSBPKCS11ObjectType.otData, false, null);


but when I try to set obj.value, I get null reference exception.
I can't seem to find how to use these methods in help file.

Any thoughts?
#13593
Posted: 06/06/2010 22:52:07
by Ken Ivanov (EldoS Corp.)

Please do it in the following way:
Code
int i = sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true/false, null);
SBPKCS11Base.TElPKCS11DataObject obj = ((SBPKCS11Base.TElPKCS11DataObject)sessionInfo.get_Objects(i));
obj.Value = new byte[] { 0x56, 0x45 };
#13596
Posted: 06/07/2010 03:30:42
by Tomislav Jakopović (Basic support level)
Joined: 05/22/2010
Posts: 38

Quote
Innokentiy Ivanov wrote:
Please do it in the following way:
Code
int i = sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true/false, null);
SBPKCS11Base.TElPKCS11DataObject obj = ((SBPKCS11Base.TElPKCS11DataObject)sessionInfo.get_Objects(i));
obj.Value = new byte[] { 0x56, 0x45 };
Quote
Innokentiy Ivanov wrote:
Please do it in the following way:
Code
int i = sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true/false, null);
SBPKCS11Base.TElPKCS11DataObject obj = ((SBPKCS11Base.TElPKCS11DataObject)sessionInfo.get_Objects(i));
obj.Value = new byte[] { 0x56, 0x45 };


Thank you.

Will it be possible to later on read the object and change the value??
I would appreciate a code snippet if it's not a big of a hassle
#13598
Posted: 06/07/2010 04:18:52
by Ken Ivanov (EldoS Corp.)

Sure. You can access the data object by iterating over the Objects[] property (get_Objects() method in C#) and searching for the needed object. Then simply assign a new value to its Value property to change the value of the token object.
#13601
Posted: 06/07/2010 11:50:07
by Tomislav Jakopović (Basic support level)
Joined: 05/22/2010
Posts: 38

Quote
Innokentiy Ivanov wrote:
Sure. You can access the data object by iterating over the Objects[] property (get_Objects() method in C#) and searching for the needed object. Then simply assign a new value to its Value property to change the value of the token object.


Hi

I followed your approach, but on the addobject method I received this exception:

PKCS#11 error CKR_TEMPLATE_INCOMPLETE in function C_CreateObject

maybe I should pass some attibutes to AddObject method call?
#13604
Posted: 06/07/2010 13:36:13
by Ken Ivanov (EldoS Corp.)

It is likely that the driver expects one (or more) other attributes to be provided (though none of them is marked as obligatory in PKCS#11 specification). First of all, please try to use the overloaded AddObject() method:

int i = sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true/false, false, true, null);
#13605
Posted: 06/07/2010 14:25:51
by Tomislav Jakopović (Basic support level)
Joined: 05/22/2010
Posts: 38

Quote
Innokentiy Ivanov wrote:
It is likely that the driver expects one (or more) other attributes to be provided (though none of them is marked as obligatory in PKCS#11 specification). First of all, please try to use the overloaded AddObject() method:

int i = sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true/false, false, true, null);


Hi,

Same error happens.Can I somehow provide this attribute by hand?
What does this attribute stand for?

I googled and I guess you need to have some sort of template for storing files...
#13606
Posted: 06/07/2010 15:04:04
by Ken Ivanov (EldoS Corp.)

Okay, let's try a little more complex thing. Please create the attributes object and set it up in the following way:
Code
TElPKCS11AttributeList attrs = new TElPKCS11AttributeList();
attrs.Add(SBPKCS11Common.Unit.CKA_LABEL, SBUtils.Unit.BytesOfString("MyDataObject"));
attrs.Add(SBPKCS11Common.Unit.CKA_APPLICATION, SBUtils.Unit.BytesOfString("MyApplication"));
sessionInfo.AddObject(TSBPKCS11ObjectType.otData, true, false, true, attrs);
#13608
Posted: 06/07/2010 18:14:51
by Tomislav Jakopović (Basic support level)
Joined: 05/22/2010
Posts: 38

Same thing happens.
#13612
Posted: 06/08/2010 03:48:06
by Ken Ivanov (EldoS Corp.)

Let's try to investigate the issue from another side. Do you have a token with some data object(s) already created? Or, alternatively, are you able to create data objects with some third-party tools?
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 5197 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!