-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't derive ECDH secret #51
Comments
I solved the issue using this struct I created:
It is working on linux an macos machines, but is failing under windows with MECHANISM_PARAM_INVALID error. |
This is most likely due to the structure packing alignment issue described here. In short, although the PKCS11 v2.40 spec explicitly says:
in practice (most) Linux libraries don't do this, while (most) Windows libraries do. Depending on the library used, calling |
The C# Pkcs11Interop library solves both this (structure packing alignment) and another common Cryptoki interop issue (the C public Pkcs11LibraryFactory()
{
if (Platform.NativeULongSize == 4)
{
if (Platform.StructPackingSize == 0)
_factory = new HighLevelAPI40.Factories.Pkcs11LibraryFactory();
else
_factory = new HighLevelAPI41.Factories.Pkcs11LibraryFactory();
}
else
{
if (Platform.StructPackingSize == 0)
_factory = new HighLevelAPI80.Factories.Pkcs11LibraryFactory();
else
_factory = new HighLevelAPI81.Factories.Pkcs11LibraryFactory();
}
} We could maybe consider doing something similar in the future? |
I've tried it and it still fails with same error. Maybe the fact that the struct for |
I am trying to derive a shared secret between two EC parties, but I have difficulties providing correct CKM. As there is no CK_ECDH1_DERIVE_PARAMS struct defined, I am trying to allocate native memory myself, but without luck so far.
Can you advise what I am doing wrong?
The text was updated successfully, but these errors were encountered: