<link>http://www.ncryptoki.com/forum.aspx</link> <description /> <docs>http://www.rssboard.org/rss-specification</docs> <generator>mojoPortal Forum module</generator> <item> <title>Re: CKM XOR BASE AND DATA, Hi Ugo,

I need the same that magodalespaul, do you have a complete working example? 

I need to create a master double des key that receive 3 components (16 bytes each one).

Thanks for your support,

Best Regards,

]]>
http://www.ncryptoki.com/Forums/Thread.aspx?pageid=9&t=16~-1#post475 magodalespaul http://www.ncryptoki.com/Forums/Thread.aspx?pageid= Wed, 15 May 2013 14:56:28 GMT Re: CKM XOR BASE AND DATA, In the current version you should work a little with unsafe segment.

First of all you should declare your param structure:

[StructLayout(LayoutKind.Sequential)]
public struct CK_KEY_DERIVATION_STRING_DATA
{
    public int len;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
    public byte[] data;
}

Note that I specified SizeCont=8, considering for example a DES key. If your key has different length you should specify the exact length.

Then, you should convert your structure to a byte array:

CK_KEY_DERIVATION_STRING_DATA param = new CK_KEY_DERIVATION_STRING_DATA();
param.data = new byte[]{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10};
param.len = 8;

int len = Marshal.SizeOf(param);
IntPtr pointer = Marshal.AllocCoTaskMem(len);

Marshal.StructureToPtr(param, pointer, false);

unsafe
{
    byte* p = (byte*)pointer.ToPointer();
    byte[] b = new byte[len];
    for (int i = 0; i < len; i++)
    {
        b[i] = p[i];
    }

    Mechanism m = new Mechanism(Mechanism.CKM_XOR_BASE_AND_DATA, b);

}

]]>
http://www.ncryptoki.com/Forums/Thread.aspx?pageid=9&t=16~-1#post100 magodalespaul http://www.ncryptoki.com/Forums/Thread.aspx?pageid= Wed, 16 Mar 2011 11:34:10 GMT
CKM XOR BASE AND DATA, Hi, i need a help, i trying to create a Master key that receive 3 key Values, for example, i insert the value of the first key, then i receive the value of the second key and for last i receive the value of the third key, so with this values i can make the Master key, i found the mechanism CKM_XOR_BASE_AND_DATA, but i don't know how to use it, i'm using C# right now,  if you can show me a example how to use it i will be grateful.

 

Tks

]]>
http://www.ncryptoki.com/Forums/Thread.aspx?pageid=9&t=16~-1#post98 magodalespaul http://www.ncryptoki.com/Forums/Thread.aspx?pageid= Tue, 15 Mar 2011 19:14:27 GMT