static char *make_sha512_salt_para(char *);
static char *make_bf_salt(int, int);
static char *make_bf_salt_para(int, char *);
-static char *int_to_base64(int);
static char *generate_random_salt(char *, int);
static char *generate_poor_salt(char *, int);
-static void full_usage(void);
-static void brief_usage(void);
+static void full_usage(void) __attribute__((noreturn));
+static void brief_usage(void) __attribute__((noreturn));
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/* 0 .. 63, ascii - 64 */
int c;
char *saltpara = NULL;
char *salt;
- char *hashed;
+ char *hashed, *hashed2;
int flag = 0;
int length = 0; /* Not Set */
int rounds = 0; /* Not set, since blowfish needs 4 by default, a side effect
}
else
{
- hashed = strdup(rb_crypt(getpass("plaintext: "), salt));
+ plaintext = getpass("plaintext: ");
+ hashed = rb_crypt(plaintext, salt);
+ if (!hashed)
+ {
+ fprintf(stderr, "rb_crypt() failed\n");
+ return 1;
+ }
+ hashed = strdup(hashed);
+
plaintext = getpass("again: ");
+ hashed2 = rb_crypt(plaintext, salt);
+ if (!hashed2)
+ {
+ fprintf(stderr, "rb_crypt() failed\n");
+ return 1;
+ }
- if (strcmp(rb_crypt(plaintext, salt), hashed) != 0)
+ if (strcmp(hashed, hashed2) != 0)
{
fprintf(stderr, "Passwords do not match\n");
return 1;
return 0;
}
-char *
-int_to_base64(int value)
-{
- static char buf[5];
- int i;
-
- for(i = 0; i < 4; i++)
- {
- buf[i] = saltChars[value & 63];
- value >>= 6; /* Right shifting 6 places is the same as dividing by 64 */
- }
-
- buf[i] = '\0'; /* not REALLY needed as it's static, and thus initialized
- ** to \0.
- */
- return buf;
-}
-
char *
make_md5_salt_para(char *saltpara)
{