title: Create 3DES key with pkcs11Interop and output key value, or proivde key value for creation
body: <p>I was wondering whether it is possible using pkcs11interop to create a 3DES key and specify the key value for creation, or otherwise create a key and output the generated key value. Basically I need the secret key to be exported to another device. </p>
  
  <p>I've tried using the CKA_VALUE attribute and passing the key as a byte[] array but with no success.</p>
  
  <p>Is such thing possible please? Can someone assist me please? </p>
  
  <p>EDIT:</p>
  
  <p>Here is the code I have with no luck so far:</p>
  
  <pre><code>public ObjectHandle generate3DESKey(string keyLabel)
  {
  ObjectHandle key = null;
  // Generate symetric key 
  
  // Prepare attribute template of new key
  List&lt;ObjectAttribute&gt; objectAttributes = new List&lt;ObjectAttribute&gt;();
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_TOKEN, true));
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKO.CKO_SECRET_KEY));
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_KEY_TYPE, CKK.CKK_DES3));
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_ENCRYPT, true));
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_EXTRACTABLE, true));
  
  objectAttributes.Add(new ObjectAttribute(CKA.CKA_LABEL, keyLabel));
  
  
  // Specify key generation mechanism
  Mechanism mechanism = new Mechanism(CKM.CKM_DES3_KEY_GEN);
  
  // Generate key
  key = _session.GenerateKey(mechanism, objectAttributes);
  
  List&lt;CKA&gt; retrieveTemplate = new List&lt;CKA&gt;();
  retrieveTemplate.Add(CKA.CKA_VALUE);
  
  var test = _session.GetAttributeValue(key, retrieveTemplate);
  var testval = test[0].GetValueAsString();
  return key;
  }
  </code></pre>
  
  <p>So what I'm trying with this code is to create a 3DES key and then get it's value using the GetAttributeValue as instructed below. I've tried the GetValueAsByteArray and GetValueAsString but all without success. What I've noticed is that the the cannotread properties on the retrieved attribute is set to true even though I've set the extractable attribute on creation. </p>
  
  <p>Apart from this I also contemplated passing the key value on generating the 3DES key however what puzzled me is the fact that documentation says that the key value used with the CKA.CKA_VALUE should be a byte array of length 24. In my case the key that I need to create is 16 length long and not 24. I want to create a key similar to this which is represented in hex over here: 1616161616161616 1010101010101010 </p>