Get all the keys(public key and private key) from HSM and list them)

7/19/2017 10:24:35 PM
kkc
Gravatar
Total Posts 13

Get all the keys(public key and private key) from HSM and list them)

Hi, I just want to output and list all the keys from HSM, can you provide me a  function or simple code to do it. thank you very much.

7/20/2017 12:15:39 PM
Gravatar
Total Posts 300
Ugo Chirico http://www.ugochirico.com

Re: Get all the keys(public key and private key) from HSM and list them)

There is a page in our wiki that shows how to list all keys:

http://wiki.ncryptoki.com/List-all-keys-Public-and-Private.ashx

7/20/2017 12:47:44 PM
Gravatar
Total Posts 300
Ugo Chirico http://www.ugochirico.com

Re: Get all the keys(public key and private key) from HSM and list them)

I hava just updated the wiki page with the print out

This is a snippet that prints out the label of the found keys:

// Launches the search specifying the template just created
CryptokiCollection pubKeyObjects = session.Objects.Find(templatePub , 100);

// prints the label of all keys
for(int i = 0; i < pubKeyObjects .count(); i++)
{
    RSAPublicKey publicKey = (RSAPublicKey )pubKeyObjects[i];
    Console.WriteLine("Public Key: " + publicKey.Label);
}
7/20/2017 3:03:07 PM
kkc
Gravatar
Total Posts 13

Re: Get all the keys(public key and private key) from HSM and list them)

Thank you Ugo.