Skip to content

Commit

Permalink
Removed dependency of fastpbkdf2
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed May 5, 2024
1 parent 02fc597 commit 4c75fd7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ set(APP_VERSION, "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
endif()

# Man build and install
if(NOT DEFINED WIN32)
add_subdirectory(man)
add_subdirectory(src/vscp/vscp-mkpasswd)
endif()
#if(NOT DEFINED WIN32)
# add_subdirectory(man)
# add_subdirectory(src/vscp/vscp-mkpasswd)
#endif()

option(USE_SSL "Use SSL" TRUE)

Expand Down Expand Up @@ -297,8 +297,6 @@ if (WIN32)
src/common/crc8.c
src/common/vscpmd5.h
src/common/vscpmd5.c
./third_party/fastpbkdf2/fastpbkdf2.h
./third_party/fastpbkdf2/fastpbkdf2.c
src/common/randpassword.h
src/common/randpassword.cpp
)
Expand Down Expand Up @@ -348,8 +346,6 @@ else()
src/common/crc8.c
src/common/vscpmd5.h
src/common/vscpmd5.c
./third_party/fastpbkdf2/fastpbkdf2.h
./third_party/fastpbkdf2/fastpbkdf2.c
src/common/randpassword.h
src/common/randpassword.cpp
)
Expand All @@ -368,7 +364,6 @@ if (WIN32)
./third_party/sqlite3/
./third_party/spdlog/include/
./third_party/mustache/
./third_party/fastpbkdf2/
./src/common/windows
${PThreads4W_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
Expand All @@ -387,7 +382,6 @@ else()
./third_party/sqlite3/
./third_party/mustache/
./third_party/spdlog/include/
./third_party/fastpbkdf2/
${PThreads4W_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${OPENSSL_INCLUDE_DIR}
Expand Down
39 changes: 20 additions & 19 deletions src/vscp/common/vscphelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include <canal_macro.h>
#include <crc.h>
#include <crc8.h>
#include <fastpbkdf2.h>
//#include <fastpbkdf2.h>
#include <vscp_aes.h>
#include <vscpbase64.h>
#include <vscpmd5.h>
Expand Down Expand Up @@ -7379,7 +7379,7 @@ vscp_getHashPasswordComponents(uint8_t *pSalt, uint8_t *pHash, const std::string
////////////////////////////////////////////////////////////////////////////////
// vscp_makePasswordHash
//

/*
bool
vscp_makePasswordHash(std::string &result, const std::string &password, uint8_t *pSalt)
{
Expand Down Expand Up @@ -7419,32 +7419,33 @@ vscp_makePasswordHash(std::string &result, const std::string &password, uint8_t
return true;
}
*/

////////////////////////////////////////////////////////////////////////////////
// vscp_isPasswordValid
//

bool
vscp_isPasswordValid(const std::string &stored_pw, const std::string &password)
{
std::string calcHash; // Calculated hash
uint8_t salt[16]; // Stored salt
uint8_t hash[32]; // Stored hash
// bool
// vscp_isPasswordValid(const std::string &stored_pw, const std::string &password)
// {
// std::string calcHash; // Calculated hash
// uint8_t salt[16]; // Stored salt
// uint8_t hash[32]; // Stored hash

if (!vscp_getHashPasswordComponents(salt, hash, stored_pw)) {
return false;
}
// if (!vscp_getHashPasswordComponents(salt, hash, stored_pw)) {
// return false;
// }

if (!vscp_makePasswordHash(calcHash, password, salt)) {
return false;
}
// if (!vscp_makePasswordHash(calcHash, password, salt)) {
// return false;
// }

if (stored_pw != calcHash) {
return false;
}
// if (stored_pw != calcHash) {
// return false;
// }

return true;
}
// return true;
// }

///////////////////////////////////////////////////////////////////////////////
// vscp_getSalt
Expand Down
8 changes: 4 additions & 4 deletions src/vscp/common/vscphelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2229,8 +2229,8 @@ vscp_getHashPasswordComponents(uint8_t *pSalt, uint8_t *pHash, const std::string
* @param password Clear text password to be hashed.
* @return true on success, false otherwise.
*/
bool
vscp_makePasswordHash(std::string &result, const std::string &password, uint8_t *pSalt = NULL);
//bool
//vscp_makePasswordHash(std::string &result, const std::string &password, uint8_t *pSalt = NULL);

/*!
* Validate password
Expand All @@ -2240,8 +2240,8 @@ vscp_makePasswordHash(std::string &result, const std::string &password, uint8_t
* @return true on success, false otherwise.
*/

bool
vscp_isPasswordValid(const std::string &stored_pw, const std::string &password);
//bool
//vscp_isPasswordValid(const std::string &stored_pw, const std::string &password);

/*!
* Get salt
Expand Down

0 comments on commit 4c75fd7

Please sign in to comment.