Coder Social home page Coder Social logo

Comments (2)

gamringer avatar gamringer commented on June 14, 2024

When creating an object, the code looks for the object class (CKA_CLASS) in order to return the correct PHP object type:

Pkcs11\Key for the following:
CKO_PUBLIC_KEY
CKO_PRIVATE_KEY
CKO_SECRET_KEY
CKO_OTP_KEY

php-pkcs11/pkcs11session.c

Lines 584 to 592 in 14cb4e8

if (classId == 2 || classId == 3 || classId == 4 || classId == 8) {
pkcs11_key_object* key_obj;
object_init_ex(retval, ce_Pkcs11_Key);
key_obj = Z_PKCS11_KEY_P(retval);
key_obj->session = objval;
key_obj->key = hObject;
GC_ADDREF(&objval->std);
return rv;
}

Pkcs11\Object for the the rest.

php-pkcs11/pkcs11session.c

Lines 596 to 602 in 14cb4e8

object_init_ex(retval, ce_Pkcs11_P11Object);
object_obj = Z_PKCS11_OBJECT_P(retval);
object_obj->session = objval;
object_obj->object = hObject;
GC_ADDREF(&objval->std);
return rv;

To do so, it calls into getObjectClass

getObjectClass(objval, &hObject, &classId);

Inside getObjectClass, we get the CKA_CLASS, but it seems as though by that time, CK_OBJECT_HANDLE_PTR hObject that was passed as argument is no longer referencing the object that we just created.

php-pkcs11/pkcs11.c

Lines 177 to 191 in 14cb4e8

CK_ATTRIBUTE template[] = {
{CKA_CLASS, NULL_PTR, 0}
};
CK_RV rv;
rv = session->pkcs11->functionList->C_GetAttributeValue(
session->session,
*hObject,
template,
1
);
if (rv != CKR_OK) {
pkcs11_error(rv, "Unable to get attribute value");
return;
}

from php-pkcs11.

pemedina avatar pemedina commented on June 14, 2024

Thanks for your reply.

We're currently trying to debug our setup with the info provided.

from php-pkcs11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.