Reindent server/core/secrets.c

This commit is contained in:
Johan Wikman
2015-11-30 18:26:04 +02:00
parent 233f50f3e6
commit 17eb80072f
2 changed files with 28 additions and 27 deletions

View File

@ -56,13 +56,13 @@ secrets_random_str(unsigned char *output, int len)
static MAXKEYS * static MAXKEYS *
secrets_readKeys(const char* path) secrets_readKeys(const char* path)
{ {
char secret_file[PATH_MAX + 1]; char secret_file[PATH_MAX + 1];
char *home; char *home;
MAXKEYS *keys; MAXKEYS *keys;
struct stat secret_stats; struct stat secret_stats;
int fd; int fd;
int len; int len;
static int reported = 0; static int reported = 0;
if (path != NULL) if (path != NULL)
{ {
@ -212,10 +212,10 @@ secrets_readKeys(const char* path)
*/ */
int secrets_writeKeys(const char *path) int secrets_writeKeys(const char *path)
{ {
int fd, randfd; int fd, randfd;
unsigned int randval; unsigned int randval;
MAXKEYS key; MAXKEYS key;
char secret_file[PATH_MAX + 10]; char secret_file[PATH_MAX + 10];
if (strlen(path) > PATH_MAX) if (strlen(path) > PATH_MAX)
{ {
@ -312,12 +312,12 @@ int secrets_writeKeys(const char *path)
char * char *
decryptPassword(const char *crypt) decryptPassword(const char *crypt)
{ {
MAXKEYS *keys; MAXKEYS *keys;
AES_KEY aeskey; AES_KEY aeskey;
unsigned char *plain; unsigned char *plain;
const char *ptr; const char *ptr;
unsigned char encrypted[80]; unsigned char encrypted[80];
int enlen; int enlen;
keys = secrets_readKeys(NULL); keys = secrets_readKeys(NULL);
if (!keys) if (!keys)
@ -325,9 +325,9 @@ decryptPassword(const char *crypt)
return strdup(crypt); return strdup(crypt);
} }
/* /*
** If the input is not a HEX string return the input ** If the input is not a HEX string return the input
** it probably was not encrypted ** it probably was not encrypted
*/ */
for (ptr = crypt; *ptr; ptr++) for (ptr = crypt; *ptr; ptr++)
{ {
if (!isxdigit(*ptr)) if (!isxdigit(*ptr))
@ -365,12 +365,12 @@ decryptPassword(const char *crypt)
char * char *
encryptPassword(const char* path, const char *password) encryptPassword(const char* path, const char *password)
{ {
MAXKEYS *keys; MAXKEYS *keys;
AES_KEY aeskey; AES_KEY aeskey;
int padded_len; int padded_len;
char *hex_output; char *hex_output;
unsigned char padded_passwd[80]; unsigned char padded_passwd[80];
unsigned char encrypted[80]; unsigned char encrypted[80];
if ((keys = secrets_readKeys(path)) == NULL) if ((keys = secrets_readKeys(path)) == NULL)
{ {

View File

@ -19,7 +19,7 @@
*/ */
/** /**
* @file secrets.h * @file secrets.h
* *
* @verbatim * @verbatim
* Revision History * Revision History
@ -55,4 +55,5 @@ typedef struct maxkeys
extern int secrets_writeKeys(const char *filename); extern int secrets_writeKeys(const char *filename);
extern char *decryptPassword(const char *); extern char *decryptPassword(const char *);
extern char *encryptPassword(const char*, const char *); extern char *encryptPassword(const char*, const char *);
#endif #endif