Whitespace and indentation changes.
Also changed line-endings from DOS CRLF to only LF. In addition, made functions const correct.
This commit is contained in:
@ -56,7 +56,7 @@ int i;
|
||||
* @return The keys structure or NULL on error
|
||||
*/
|
||||
static MAXKEYS *
|
||||
secrets_readKeys(char* path)
|
||||
secrets_readKeys(const char* path)
|
||||
{
|
||||
char secret_file[PATH_MAX+1];
|
||||
char *home;
|
||||
@ -65,10 +65,16 @@ struct stat secret_stats;
|
||||
int fd;
|
||||
int len;
|
||||
static int reported = 0;
|
||||
|
||||
if (path != NULL)
|
||||
{
|
||||
snprintf(secret_file, PATH_MAX, "%s/.secrets", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(secret_file, PATH_MAX, "%s/.secrets", get_datadir());
|
||||
}
|
||||
|
||||
/* Try to access secrets file */
|
||||
if (access(secret_file, R_OK) == -1)
|
||||
{
|
||||
@ -150,6 +156,7 @@ static int reported = 0;
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (secret_stats.st_mode != (S_IRUSR|S_IFREG))
|
||||
{
|
||||
close(fd);
|
||||
@ -224,7 +231,7 @@ static int reported = 0;
|
||||
* @param secret_file The file with secret keys
|
||||
* @return 0 on success and 1 on failure
|
||||
*/
|
||||
int secrets_writeKeys(char *path)
|
||||
int secrets_writeKeys(const char *path)
|
||||
{
|
||||
int fd,randfd;
|
||||
unsigned int randval;
|
||||
@ -337,18 +344,20 @@ if(strlen(path) > PATH_MAX)
|
||||
* @return The decrypted password
|
||||
*/
|
||||
char *
|
||||
decryptPassword(char *crypt)
|
||||
decryptPassword(const char *crypt)
|
||||
{
|
||||
MAXKEYS *keys;
|
||||
AES_KEY aeskey;
|
||||
unsigned char *plain;
|
||||
char *ptr;
|
||||
const char *ptr;
|
||||
unsigned char encrypted[80];
|
||||
int enlen;
|
||||
|
||||
keys = secrets_readKeys(NULL);
|
||||
if (!keys)
|
||||
{
|
||||
return strdup(crypt);
|
||||
}
|
||||
/*
|
||||
** If the input is not a HEX string return the input
|
||||
** it probably was not encrypted
|
||||
@ -388,7 +397,7 @@ int enlen;
|
||||
* @return The encrypted password
|
||||
*/
|
||||
char *
|
||||
encryptPassword(char* path, char *password)
|
||||
encryptPassword(const char* path, const char *password)
|
||||
{
|
||||
MAXKEYS *keys;
|
||||
AES_KEY aeskey;
|
||||
@ -398,7 +407,9 @@ unsigned char padded_passwd[80];
|
||||
unsigned char encrypted[80];
|
||||
|
||||
if ((keys = secrets_readKeys(path)) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(padded_passwd, 0, 80);
|
||||
strncpy((char *)padded_passwd, password, 79);
|
||||
|
||||
@ -46,12 +46,13 @@
|
||||
/**
|
||||
* The key structure held in the secrets file
|
||||
*/
|
||||
typedef struct maxkeys {
|
||||
typedef struct maxkeys
|
||||
{
|
||||
unsigned char enckey[MAXSCALE_KEYLEN];
|
||||
unsigned char initvector[MAXSCALE_IV_LEN];
|
||||
} MAXKEYS;
|
||||
|
||||
extern int secrets_writeKeys(char *filename);
|
||||
extern char *decryptPassword(char *);
|
||||
extern char *encryptPassword(char*,char *);
|
||||
extern int secrets_writeKeys(const char *filename);
|
||||
extern char *decryptPassword(const char *);
|
||||
extern char *encryptPassword(const char*, const char *);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user