Subversion Repositories MLServ

Rev

Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
Line 1... Line 1...
1
/* $Id: crypt.c 7 2024-09-25 00:56:55Z nishi $ */
1
/* $Id: crypt.c 8 2024-09-25 00:57:33Z nishi $ */
2
 
2
 
3
#include "cm_crypt.h"
3
#include "cm_crypt.h"
4
 
4
 
5
#include <unistd.h>
5
#include <unistd.h>
6
#include <stdio.h>
6
#include <stdio.h>
Line 35... Line 35...
35
		sprintf(buffer, "$%da$08$%s$", num, salt);
35
		sprintf(buffer, "$%da$08$%s$", num, salt);
36
 
36
 
37
		r = crypt(string, buffer);
37
		r = crypt(string, buffer);
38
 
38
 
39
		free(buffer);
39
		free(buffer);
-
 
40
	}
-
 
41
#ifdef __NetBSD__
40
	} else if(num == C_ARGON2) {
42
	else if(num == C_ARGON2) {
41
		if(strlen(salt) != 16) return NULL;
43
		if(strlen(salt) != 16) return NULL;
42
		char* buffer = malloc(1 + 8 + 1 + 4 + 1 + 16 + 1 + 1 + 7);
44
		char* buffer = malloc(1 + 8 + 1 + 4 + 1 + 16 + 1 + 1 + 7);
43
		buffer[1 + 8 + 1 + 4 + 1 + 16 + 1 + 7] = 0;
45
		buffer[1 + 8 + 1 + 4 + 1 + 16 + 1 + 7] = 0;
44
		sprintf(buffer, "$argon2id$v=19$m=4096$%s$", salt);
46
		sprintf(buffer, "$argon2id$v=19$m=4096$%s$", salt);
45
 
47
 
46
		r = crypt(string, buffer);
48
		r = crypt(string, buffer);
47
 
49
 
48
		free(buffer);
50
		free(buffer);
49
	}
51
	}
-
 
52
#endif
50
	if(r == NULL || strcmp(r, "*0") == 0 || strcmp(r, ":") == 0) r = NULL;
53
	if(r == NULL || strcmp(r, "*0") == 0 || strcmp(r, ":") == 0) r = NULL;
51
	return r;
54
	return r;
52
}
55
}
53
 
56
 
54
int cm_crypt_try(int num) {
57
int cm_crypt_try(int num) {