// Searchs for an RSA public key object CryptokiCollection template = new CryptokiCollection(); template.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_PUBLIC_KEY)); template.Add(new ObjectAttribute(ObjectAttribute.CKA_KEY_TYPE, Key.CKK_RSA)); // Launches the search specifying the template just created CryptokiCollection objects = session.Objects.Find(template, 1); if(objects.count == 0) { // PUBLIC KEY NOT FOUND return false; } // takes the first object as key RSAPublicKey publicKey = (RSAPublicKey )objects[0]; // Extracts modulus and public exponent byte[] modulus = publicKey .Modulus; byte[] publicExponent = publicKey .PublicExponent;