feat: implemented hash based login command.

This commit is contained in:
Lorenzo Torres 2025-02-12 20:53:42 +01:00
parent 9418c7b9a4
commit d2d12e9767
8 changed files with 56 additions and 25 deletions

21
auth.c
View file

@ -25,13 +25,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef AUTH_PAM
#include <openssl/sha.h>
#include <auth.h>
int pam_conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) {
void auth_sha256(char *string, char buffer[65]) {
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, string, strlen(string));
SHA256_Final(hash, &sha256);
int i = 0;
for(i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(buffer + (i * 2), "%02x", hash[i]);
}
buffer[64] = '\0';
}
uint8_t auth_pam(char *username, char *password)
{
}
#endif