p11-glue / p11-kit

Provides a way to load and enumerate PKCS#11 modules.
https://p11-glue.github.io/p11-glue/p11-kit.html
Other
151 stars 95 forks source link

p11-kit: Expose version information through macros #635

Closed ueno closed 6 months ago

ueno commented 7 months ago

This provides P11_KITVERSION{MAJOR,MINOR,MICRO} from the <p11-kit/version.h> header, along with a helper macro P11_KIT_CHECK_VERSION(major, minor, micro) for checking the version requirement with #if directive.

Fixes: #523

coveralls commented 7 months ago

Coverage Status

coverage: 69.556% (+0.001%) from 69.555% when pulling fda7039919bd26c6ebc152288a7c91afab380686 on ueno:wip/dueno/version-api into 8832556a467f65b24d51fda14ea42a42d406c406 on p11-glue:master.

ueno commented 6 months ago

Thanks for the review!

bcsgh commented 6 months ago

Why is P11_KIT_CHECK_VERSION a macro rather than a function? That kind of removes one of the reason for including this sort of API which is to check at runtime that the library linked in (either linked statically at build time or dynamically from whatever environment things are run in) matches the expectation of the calling code. This macro at most allows calling code the verify that the set of headers resolved at build time are the expected ones but doesn't, by itself, provide a way to know what version of the p11 library the code is then linked with.

Given that p11 seems to require non-static builds, it seems like being able to verify that the (unavoidable) .so that is chosen at run time is what the calling code expects it to be (or at least having a way to know what it actually is) would be at least as desirable here as it is for other libraries that provide that sort of function:

ueno commented 6 months ago

I actually thought that run-time detection was already possible through PKCS#11 API (because libp11-kit.so is the same binary as p11-kit-proxy.so), but it turns out not the case. Maybe we could embed the actual version.