summaryrefslogtreecommitdiff
path: root/com32/menu
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:28 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:28 -0700
commit6186970871197b5e492c083d688fa68def38a478 (patch)
tree96777d29e1af2749c28fb2098917e6a568a9e1b0 /com32/menu
parentc1e6d216f7dee0dd756b0e6fc332c9c4ea2cf1d7 (diff)
downloadsyslinux-6186970871197b5e492c083d688fa68def38a478.tar.gz
Run Nindent on com32/menu/passwd.c
Automatically reformat com32/menu/passwd.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/menu')
-rw-r--r--com32/menu/passwd.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/com32/menu/passwd.c b/com32/menu/passwd.c
index 534fe8bd..d5cfd082 100644
--- a/com32/menu/passwd.c
+++ b/com32/menu/passwd.c
@@ -19,78 +19,78 @@
static int passwd_compare_sha1(const char *passwd, const char *entry)
{
- struct {
- SHA1_CTX ctx;
- unsigned char sha1[20], pwdsha1[20];
- } d;
- const char *p;
- int rv;
-
- SHA1Init(&d.ctx);
-
- if ( (p = strchr(passwd+3, '$')) ) {
- SHA1Update(&d.ctx, (void *)passwd+3, p-(passwd+3));
- p++;
- } else {
- p = passwd+3; /* Assume no salt */
- }
+ struct {
+ SHA1_CTX ctx;
+ unsigned char sha1[20], pwdsha1[20];
+ } d;
+ const char *p;
+ int rv;
+
+ SHA1Init(&d.ctx);
+
+ if ((p = strchr(passwd + 3, '$'))) {
+ SHA1Update(&d.ctx, (void *)passwd + 3, p - (passwd + 3));
+ p++;
+ } else {
+ p = passwd + 3; /* Assume no salt */
+ }
- SHA1Update(&d.ctx, (void *)entry, strlen(entry));
- SHA1Final(d.sha1, &d.ctx);
+ SHA1Update(&d.ctx, (void *)entry, strlen(entry));
+ SHA1Final(d.sha1, &d.ctx);
- memset(d.pwdsha1, 0, 20);
- unbase64(d.pwdsha1, 20, p);
+ memset(d.pwdsha1, 0, 20);
+ unbase64(d.pwdsha1, 20, p);
- rv = !memcmp(d.sha1, d.pwdsha1, 20);
+ rv = !memcmp(d.sha1, d.pwdsha1, 20);
- memset(&d, 0, sizeof d);
- return rv;
+ memset(&d, 0, sizeof d);
+ return rv;
}
static int passwd_compare_md5(const char *passwd, const char *entry)
{
- const char *crypted = crypt_md5(entry, passwd+3);
- int len = strlen(crypted);
+ const char *crypted = crypt_md5(entry, passwd + 3);
+ int len = strlen(crypted);
- return !strncmp(crypted, passwd, len) &&
- (passwd[len] == '\0' || passwd[len] == '$');
+ return !strncmp(crypted, passwd, len) &&
+ (passwd[len] == '\0' || passwd[len] == '$');
}
static int passwd_compare_sha256(const char *passwd, const char *entry)
{
- const char *crypted = sha256_crypt(entry, passwd+3);
- int len = strlen(crypted);
+ const char *crypted = sha256_crypt(entry, passwd + 3);
+ int len = strlen(crypted);
- return !strncmp(crypted, passwd, len) &&
- (passwd[len] == '\0' || passwd[len] == '$');
+ return !strncmp(crypted, passwd, len) &&
+ (passwd[len] == '\0' || passwd[len] == '$');
}
static int passwd_compare_sha512(const char *passwd, const char *entry)
{
- const char *crypted = sha512_crypt(entry, passwd+3);
- int len = strlen(crypted);
+ const char *crypted = sha512_crypt(entry, passwd + 3);
+ int len = strlen(crypted);
- return !strncmp(crypted, passwd, len) &&
- (passwd[len] == '\0' || passwd[len] == '$');
+ return !strncmp(crypted, passwd, len) &&
+ (passwd[len] == '\0' || passwd[len] == '$');
}
int passwd_compare(const char *passwd, const char *entry)
{
- if ( passwd[0] != '$' || !passwd[1] || passwd[2] != '$' ) {
- /* Plaintext passwd, yuck! */
- return !strcmp(entry, passwd);
- } else {
- switch (passwd[1]) {
- case '1':
- return passwd_compare_md5(passwd, entry);
- case '4':
- return passwd_compare_sha1(passwd, entry);
- case '5':
- return passwd_compare_sha256(passwd, entry);
- case '6':
- return passwd_compare_sha512(passwd, entry);
- default:
- return 0; /* Unknown encryption algorithm -> false */
+ if (passwd[0] != '$' || !passwd[1] || passwd[2] != '$') {
+ /* Plaintext passwd, yuck! */
+ return !strcmp(entry, passwd);
+ } else {
+ switch (passwd[1]) {
+ case '1':
+ return passwd_compare_md5(passwd, entry);
+ case '4':
+ return passwd_compare_sha1(passwd, entry);
+ case '5':
+ return passwd_compare_sha256(passwd, entry);
+ case '6':
+ return passwd_compare_sha512(passwd, entry);
+ default:
+ return 0; /* Unknown encryption algorithm -> false */
+ }
}
- }
}