mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-29 13:01:14 +03:00
build: improve a test build workaround with bcrypt
- cmake: extend workaround for linking a test with shared libssh2. One of the tests uses internal libssh2 functions, and with CMake it compiles `src/misc.c` directly for this. `misc.c` references bcrypt / blowfish code. This needs a workaround for build configs where libssh2 doesn't export these. Before this patch, we enabled this workaround for MSVC. In the patch we extend this to all Windows. There is no CI test for this, but gcc and llvm/clang + mingw64 builds also need it. This may well apply to other configurations (it should, as shared libs are not supposed to export internal functions), so also make it easy to enable it at a single point. [ autotools builds force-link this one test against static libssh2. ] - make `misc.c` not depend on bcrypt. By moving out our `bcrypt_pbkdf()` wrapper into `bcrypt_pbkdf.c` itself. This allows to compile `misc.c` into tests without pulling in bcrypt / blowfish functions, and simplify the above workaround. Source code uses `HAVE_BCRYPT_PBKDF`, a leftover from original bcrypt source. We never define this inside libssh2. Defining it breaks the build, and this patch doesn't change that. - make `bcrypt_pbkdf()` static. While here, make the low-level `bcrypt_pbkdf()` function static to avoid namespace pollution. Closes #855
This commit is contained in:
@ -315,22 +315,3 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Workaround for Visual Studio */
|
||||
#ifdef _MSC_VER
|
||||
int
|
||||
bcrypt_pbkdf(const char *pass, size_t passlen, const uint8_t *salt,
|
||||
size_t saltlen,
|
||||
uint8_t *key, size_t keylen, unsigned int rounds)
|
||||
{
|
||||
(void)pass;
|
||||
(void)passlen;
|
||||
(void)salt;
|
||||
(void)saltlen;
|
||||
(void)key;
|
||||
(void)keylen;
|
||||
(void)rounds;
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user