From 57587c97254b324d05b6efcbcaabde77b5955bec Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 30 Jan 2017 11:28:16 +0100 Subject: axspawn: Move calc_md5_pw to eleminate need for declaration and make static. Signed-off-by: Ralf Baechle --- ax25/access.c | 59 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'ax25') diff --git a/ax25/access.c b/ax25/access.c index 7f3d0c3..2ce2c94 100644 --- a/ax25/access.c +++ b/ax25/access.c @@ -20,8 +20,6 @@ static long seed = 1L; -void calc_md5_pw (const char *MD5prompt, const char *MD5pw, char *MD5result); - /*--------------------------------------------------------------------------*/ static int conv_rand(void) @@ -98,6 +96,35 @@ static char *generate_rand_pw(int len) /*--------------------------------------------------------------------------*/ +static void calc_md5_pw (const char *MD5prompt, const char *MD5pw, + char *MD5result) +{ + MD5_CTX context; + short i, n, len; + char buffer[1024]; + + strncpy(buffer, MD5prompt, 10); + buffer[10] = 0; + strcat(buffer, MD5pw); + + MD5Init(&context); + + len = strlen(buffer); + for (i= 0; i < len; i += 16) { + n = (len - i) > 16 ? 16 : (len - i); + MD5Update(&context, (unsigned char *) buffer+i, n); + } + + MD5Final(&context); + + MD5result[0] = '\0'; + for (i = 0; i < 16; i++) { + MD5result[i] = context.digest[i]; + } +} + +/*--------------------------------------------------------------------------*/ + void ask_pw_sys(char *prompt, char *pass_want, char *pw) { char buffer[2048]; @@ -171,34 +198,6 @@ void ask_pw_md5(char *prompt, char *pass_want, char *pw) /*--------------------------------------------------------------------------*/ -void calc_md5_pw (const char *MD5prompt, const char *MD5pw, char *MD5result) -{ - MD5_CTX context; - short i, n, len; - char buffer[1024]; - - strncpy(buffer, MD5prompt, 10); - buffer[10] = 0; - strcat(buffer, MD5pw); - - MD5Init(&context); - - len = strlen(buffer); - for (i= 0; i < len; i += 16) { - n = (len - i) > 16 ? 16 : (len - i); - MD5Update(&context, (unsigned char *) buffer+i, n); - } - - MD5Final(&context); - - MD5result[0] = '\0'; - for (i = 0; i < 16; i++) { - MD5result[i] = context.digest[i]; - } -} - -/*--------------------------------------------------------------------------*/ - static void write_example_passwd(char *pwfile, char pwlocation, struct passwd *pw) { -- cgit v1.2.3