Import and export of secret key

6/23/2015 4:22:40 PM
Gravatar
Total Posts 1

Import and export of secret key

I just started using the API using c# and wanted to know how to import and export secret keys from/to <span data-scayt_word="HSMs" data-scaytid="3">HSMs?

example

create a new secret key

 <span data-scayt_word="var" data-scaytid="6">var t<span data-scayt_word="yRequestTemplate" data-scaytid="48">emplate = new <span data-scayt_word="CryptokiCollection" data-scaytid="8">CryptokiCollection
                        {
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="9">ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_SECRET_KEY),
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="10">ObjectAttribute(ObjectAttribute.CKA_KEY_TYPE, Key.CKK_AES),
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="11">ObjectAttribute(ObjectAttribute.CKA_LABEL, <span data-scayt_word="myLabel" data-scaytid="141">myLabel),
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="179">ObjectAttribute(ObjectAttribute.CKA_ENCRYPT, true),
                           new <span data-scayt_word="ObjectAttribute" data-scaytid="180">ObjectAttribute(ObjectAttribute.CKA_DECRYPT, true),                           

                           new <span data-scayt_word="ObjectAttribute" data-scaytid="13">ObjectAttribute(ObjectAttribute.CKA_TOKEN, true),
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="17">ObjectAttribute(ObjectAttribute.CKA_PRIVATE, true),
                           
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="20">ObjectAttribute(ObjectAttribute.CKA_VALUE_LEN, 32),
                            new <span data-scayt_word="ObjectAttribute" data-scaytid="32">ObjectAttribute(ObjectAttribute.CKA_SENSITIVE, false),
                        };

now I need to export from one <span data-scayt_word="HSM" data-scaytid="167">HSM to another, what is the best way to do that?

6/23/2015 5:49:59 PM
Gravatar
Total Posts 300
Ugo Chirico http://www.ugochirico.com

Re: Import and export of secret key

You can find in our wiki an example on extracting an extractable DES key from an HSM:

http://wiki.ncryptoki.com/How-to-extract-a-DES-secret-key.ashx

 

Consider also that usually to import/export a secret key from an HSM you must use wrap/unwrap functions by using a RSA key pair to wrap/unwrap the key.