Coder Social home page Coder Social logo

FindObjects bool is always false about pkcs11 HOT 9 CLOSED

miekg avatar miekg commented on August 21, 2024
FindObjects bool is always false

from pkcs11.

Comments (9)

dmjones avatar dmjones commented on August 21, 2024

This definitely looks broken to me.

It is impossible to determine whether C_FindObjects would have returned more values than max without calling it again. Only when C_FindObjects returns zero can you be sure the token has no more objects to return.

I think a breaking change is required to remove this boolean response value. It is misleading and I can't see how it can ever be accurate. It's already tripped me up on some code I wrote to work with SoftHSM2.

In a pathological case, you cannot even be sure the token has run out of objects if ulCount < maz. The token is under no obligation to always fill the available space. Its only obligation is to return 0 if no more objects exist.

The workaround for now is to ignore this boolean value and keep calling until no objects are returned.

from pkcs11.

dmjones avatar dmjones commented on August 21, 2024

@miekg Can we reopen this?

from pkcs11.

mtharp avatar mtharp commented on August 21, 2024

Your interpretation of the spec seems correct to me. It's unclear whether changing the code would be a good idea since implementations may be depending on it never returning true (see this example in the pkcs11 tree: https://github.com/miekg/pkcs11/blob/master/p11/session.go#L75)

The safest fix would be updating the comment to mark it as deprecated and describing what the correct use should be.

from pkcs11.

miekg avatar miekg commented on August 21, 2024

from pkcs11.

mtharp avatar mtharp commented on August 21, 2024

The existing signature is sufficient to use the function correctly, you just ignore the boolean and stop searching when the result is empty. So there's not really any benefit to changing it until there are other breaking changes to bundle it with. I opened a pull request to update the docs and fix the p11 version of the function to not use it.

from pkcs11.

dmjones avatar dmjones commented on August 21, 2024

I'd opt for a breaking change. Removing a return value will break builds, so people won't miss this happening. People who are ignoring the return value are minimally inconvenienced. People with broken code that assumes it works correctly will have more work to do, but they had buggy code anyway.

I fear people will miss documentation changes.

from pkcs11.

miekg avatar miekg commented on August 21, 2024

from pkcs11.

mtharp avatar mtharp commented on August 21, 2024

Should #55 be addressed at the same time then?

Ideally there should be a tag before the breaking change so that people using dependency management can pin it until they can update their code.

from pkcs11.

miekg avatar miekg commented on August 21, 2024

If we're going to break things, its better to group those, so yes?

releases is a separate issues: now with vgo we should actually start doing this.

from 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.