-
Notifications
You must be signed in to change notification settings - Fork 457
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
introducing macro LTC_NO_WIN32_BCRYPT #653
Conversation
hmm, we're also building against 2022 and the build is fine!? shouldn't you better fix the build instead of disabling the "correct/modern API"? I'm just asking :) if you prefer it like that, we can also merge it! |
The thing is that when building perl bindings with VS2022 I need to explicitly instruct linker to link with Although I only suggest to have an option to opt out from using |
This PR doesn't make sense to me. The use of BCryptGenRandom() or CryptGenRandom() is a build-time decision, while tomcrypt_cfg.h is a public header that somehow should reflect how libtomcrypt was built. All this considered, I don't quite understand why LTC_WIN32_BCRYPT is even defined in a public header... unless it's something for others to use as an indicator if bcrypt.lib should be added when linking, which is actually reasonable. Actually, the way tomcrypt_cfg.h is designed and meant to be used is pretty clear, and the comment at the top does clarify it: libtomcrypt/src/headers/tomcrypt_cfg.h Lines 4 to 8 in 427ce33
In other words, if you want a special build, you're supposed to patch (and I guess, carry around the patch). For example like this: diff --git a/src/headers/tomcrypt_cfg.h b/src/headers/tomcrypt_cfg.h
index 3d90d03c..93e2c3d2 100644
--- a/src/headers/tomcrypt_cfg.h
+++ b/src/headers/tomcrypt_cfg.h
@@ -313,7 +313,7 @@ typedef unsigned long ltc_mp_digit;
#endif
#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && !defined(LTC_WIN32_BCRYPT)
-# define LTC_WIN32_BCRYPT
+# undef LTC_WIN32_BCRYPT
#endif
/* Define `LTC_NO_NULL_TERMINATION_CHECK` in the user code |
... maybe I'm being a bit too loud. Dunno. I just had a look at tomcrypt_custom.h, and that gave me pause. I'll dig deeper this evening... |
1. It's internal anyway, so doesn't quite need to be reflected in a public header file. 2. This makes it easy for someone build this library to choose not to use BCryptGenRandom() by simply definining LTC_NO_WIN32_BCRYPT, which was hard to reflect in an unmodified public header file. Alternative to libtom#653
I gave this another thought, and found that the easiest is to make LTC_WIN32_BCRYPT a private macro, see #660. Fortunately, this macro doesn't exist in any release, so that won't break anything, as far as I can tell. |
I am basically fine with whatever solution that allows me to opt out from
using BCryptGenRandom().
This was just the easiest hack. I would stick to an official way how to do
it, if we have one.
|
My vote is obviously on #660 😉 |
1. It's internal anyway, so doesn't quite need to be reflected in a public header file. 2. This makes it easy for someone build this library to choose not to use BCryptGenRandom() by simply definining LTC_NO_WIN32_BCRYPT, which was hard to reflect in an unmodified public header file. Alternative to libtom#653
Forcing the use of
BCryptGenRandom
with newer MS Visual Studio makes me troubles with my CryptX module.See https://www.cpantesters.org/cpan/report/00af9ff6-6e86-1014-b515-6e66cb952333
Defining LTC_NO_WIN32_BCRYPT avoids using
BCryptGenRandom