Welcome
Guest
, you are in:
<root>
•
Login
NCryptoki Wiki
Navigation
¶
Main Page
Random Page
Create a new Page
All Pages
Categories
Navigation Paths
Administration
File Management
Create Account
Search the wiki
»
Back
List all keys, Public and Private
Modified on 2017/07/20 12:46
by
Administrator
Categorized as
Uncategorized
This snippet shows how to list all public and private keys: <pre class="brush: text"> // Searchs for private key objects CryptokiCollection templatePri = new CryptokiCollection(); templatePri .Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_PRIVATE_KEY)); // Launches the search specifying the template just created CryptokiCollection priKeyObjects = session.Objects.Find(templatePri , 100); // prints the label of all keys for(int i = 0; i < priKeyObjects .count(); i++) { RSAPrivateKey privateKey = (RSAPrivateKey)priKeyObjects [i]; Console.WriteLine("Private Key: " + privateKey.Label); } // Searchs for public key objects CryptokiCollection templatePub = new CryptokiCollection(); templatePub .Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_PUBLIC_KEY)); // 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); } </pre>
Meta Keywords:
Meta Description:
Change Comment:
ScrewTurn Wiki
version 3.0.4.560. Some of the icons created by
FamFamFam
.