Source
xxxxxxxxxx
/*
* Copyright (C) 2001-2008 Marco d'Itri
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* for crypt, snprintf and strcasecmp */
/* System library */
/* Application-specific */
/* Global variables */
static const struct option longopts[] = {
{"method", optional_argument, NULL, 'm'},
/* for backward compatibility with versions < 4.7.25 (< 20080321): */
{"hash", optional_argument, NULL, 'H'},
{"help", no_argument, NULL, 'h'},
{"password-fd", required_argument, NULL, 'P'},
{"stdin", no_argument, NULL, 's'},
{"salt", required_argument, NULL, 'S'},
{"rounds", required_argument, NULL, 'R'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0 }
};
extern char *optarg;
extern int optind;
static const char valid_salts[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
struct crypt_method {
const char *method; /* short name used by the command line option */
const char *prefix; /* salt prefix */
const unsigned int minlen; /* minimum salt length */
const unsigned int maxlen; /* maximum salt length */
const unsigned int rounds; /* supports a variable number of rounds */
const char *desc; /* long description for the methods list */
};
static const struct crypt_method methods[] = {
/* method prefix minlen, maxlen rounds description */
{ "des", "", 2, 2, 0,
N_("standard 56 bit DES-based crypt(3)") },
{ "md5", "$1$", 8, 8, 0, "MD5" },
{ "bf", "$2a$", 22, 22, 1, "Blowfish" },
{ "bf", "$2a$", 22, 22, 1, "Blowfish, system-specific on 8-bit chars" },
/* algorithm 2y fixes CVE-2011-2483 */
{ "bfy", "$2y$", 22, 22, 1, "Blowfish, correct handling of 8-bit chars" },