Comments (11)
Does ObjectId map to CKA_ID ? If so, your objects might just have no CKA_ID value?
from pkcs11interop.
Hi Ian, i tryed also to set attributes.Add(CKA.CKA_ID) instead LABEL but i had always value empty
from pkcs11interop.
Hello Armando. I can see you are using 64-bit Linux that is currently considered to be an unsupported plaform. I will publish my experimental "Linux-x86_64" branch in few hours so you can test with it. I will let you know here when it is ready.
from pkcs11interop.
Great :)
from pkcs11interop.
Ooh cool! a few of us at work were hoping for that today :D
from pkcs11interop.
I have just committed the first version of Pkcs11Interop that runs on 64bit Linux into Linux-x86_64 branch. It can be easily downloaded as a ZIP archive. Please note that this version is compatible only with Linux x86_64 and it breaks compatibility with all the other platforms including 64bit Windows. Please use Master branch or official releases for other platforms. It is possible that Linux-x86_64 and Master branches will be merged one day but I need to perform more tests before that can happen. Sadly I have only a few PKCS#11 implementations available for testing on this platform and all of them "break standards" in some way.
Armando: Could you please test this version and let me know if it solves your problem?
Ian: Your feedback is also greatly appreciated!
from pkcs11interop.
Hi Jariq, i tested it with follow code and WORK FINE :-) for object find and get attributes value. i'm going to test enc/dec now. Also i had some problem with 64/32 bit arch with my monosim / comex-project and i solved using intptr for DllImport and ulong to reading value https://code.google.com/p/comex-project/source/browse/trunk/comex-base/Src/Readers/PcscReader.cs
Thanks, i post news here after my other tests
using System;
using System.Collections.Generic;
using Net.Pkcs11Interop.HighLevelAPI;
using Net.Pkcs11Interop.Common;
namespace Pkcs11InteropConsole
{
class MainClass
{
private static Dictionary<ulong, Slot> slots = new Dictionary<ulong, Slot>();
public static void Main(string[] args)
{
// init pkcs11 utimaco library
Pkcs11 pkcs11 = new Pkcs11(@"/usr/lib64/libcs2_pkcs11.so", false);
// Get list of available slots
List<Slot> slotList = pkcs11.GetSlotList(false);
// generate slot dictionary
foreach (Slot slot in slotList)
{
// check for slot id already present
if (!slots.ContainsKey(slot.SlotId))
{
Console.WriteLine("ID: " + slot.SlotId.ToString());
slots.Add(slot.SlotId, slot);
}
}
ParseSlot(slots[0]);
pkcs11.Dispose();
}
private static void ParseSlot(Slot slotObj)
{
// open session
Session session = slotObj.OpenSession(false);
// login user
session.Login(CKU.CKU_USER, "<user pin>");
// get all token objects
List<ObjectAttribute> attributesToFind = new List<ObjectAttribute>();
attributesToFind.Add(new ObjectAttribute(CKA.CKA_TOKEN, true));
attributesToFind.Add(new ObjectAttribute(CKA.CKA_KEY_TYPE, (ulong)CKK.CKK_DES2));
List<ObjectHandle> foundObjects = session.FindAllObjects(attributesToFind);
Console.WriteLine("Objects Founded: " + foundObjects.Count.ToString());
// set CKA_LABEL to obtain
List<CKA> attributes = new List<CKA>();
attributes.Add(CKA.CKA_LABEL);
attributes.Add(CKA.CKA_KEY_TYPE);
attributes.Add(CKA.CKA_MODIFIABLE);
attributes.Add(CKA.CKA_SENSITIVE);
attributes.Add(CKA.CKA_EXTRACTABLE);
attributes.Add(CKA.CKA_CHECK_VALUE);
// loop for each object founded into selected slot
foreach (ObjectHandle oh in foundObjects)
{
if (oh.ObjectId != 0)
{
Console.WriteLine("\r\nObjectHandle: " + oh.ObjectId.ToString("X8"));
List<ObjectAttribute> oAttr = session.GetAttributeValue(oh, attributes);
Console.WriteLine(" LABEL : " + oAttr[0].GetValueAsString());
Console.WriteLine(" KEY_TYPE : " + oAttr[1].GetValueAsUint().ToString());
Console.WriteLine(" MODIFIABLE : " + oAttr[2].GetValueAsBool().ToString());
Console.WriteLine(" SENSITIVE : " + oAttr[3].GetValueAsBool().ToString());
Console.WriteLine(" EXTRACTABLE : " + oAttr[4].GetValueAsBool().ToString());
Console.WriteLine(" CHECK_VALUE : " + BitConverter.ToString((oAttr[5].GetValueAsByteArray())));
}
}
// logout close and dispose pkcs11 instance
session.Logout();
session.CloseSession();
}
}
}
from pkcs11interop.
On linux, CK_ULONG is the same size as a pointer ( UIntPtr )
On windows, CK_ULONG is always 32bits
I have a half baked approach to doing this using generics but I've not tried it yet.
from pkcs11interop.
Hi all,
i tryed also enc/dec with founded secret key object and it work fine :)
thanks
from pkcs11interop.
Thanks for letting me know.
from pkcs11interop.
FYI: Pkcs11Interop 2.0 has just been released. It supports platforms with 32-bit C 'long' type (Win32, Win64 and Linux32) and also platforms with 64-bit C 'long' type (Linux64).
from pkcs11interop.
Related Issues (20)
- Private key is not in certificate
- Method C_OpenSession returned CKR_CRYPTOKI_NOT_INITIALIZED
- Pkcs11Interop is not supported on this platform HOT 25
- Missing attribute CKA_NAME_HASH_ALGORITHM
- problem in Pkcs11Interop with new dll from epass 2003
- CKR_OPERATION_NOT_INITIALIZED in multithreaded application
- Missing param represents object handle
- Method C_Login returned CKR_SESSION_HANDLE_INVALID
- Incorrect CK_VERSION string value
- Get Key Value From HSM
- Not able to use C_Sign with yubikey PIV slot with CKA_ALWAYS_AUTHENTICATE HOT 5
- Linux : NativeULong as System.UInt32 causes error while accessing CK_GCM_PARAMS structure from PKCS11 standards HOT 2
- mac os compile problem MAUI .net core 7.0 how to fix ?
- SafeNet Data Objects HOT 7
- ComputeDigest/CreateDigestInfo - with newest Pkcs11Interop - how to ?
- C_Sign returned CKR_OPERATION_NOT_INITIALIZED in multithreaded application
- C_Encrypt with AES mechanism always returns with CKR_GENERAL_ERROR HOT 1
- C_FindObjects does return with nothing while running application in docker
- C_FindObjects does return with nothing while running application in docker HOT 3
- session.Decrypt returning garbage characters appended in PKCS#11 Multipart Decryption with Pkcs11Interop v 4.x.x
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkcs11interop.