Date: Tue, 21 Oct 2014 21:09:54 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r273425 - stable/9/lib/libcrypt Message-ID: <201410212109.s9LL9s3g094325@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Tue Oct 21 21:09:54 2014 New Revision: 273425 URL: https://svnweb.freebsd.org/changeset/base/273425 Log: MFC r272830 (des): Change the hardcoded default back from SHA512 to DES. This will become EN-14:11.crypt. PR: 192277 Modified: stable/9/lib/libcrypt/crypt.c Directory Properties: stable/9/lib/libcrypt/ (props changed) Modified: stable/9/lib/libcrypt/crypt.c ============================================================================== --- stable/9/lib/libcrypt/crypt.c Tue Oct 21 21:08:45 2014 (r273424) +++ stable/9/lib/libcrypt/crypt.c Tue Oct 21 21:09:54 2014 (r273425) @@ -37,24 +37,26 @@ __FBSDID("$FreeBSD$"); #include "crypt.h" /* - * List of supported crypt(3) formats. The first element in the list will - * be the default. + * List of supported crypt(3) formats. + * + * The default algorithm is the last entry in the list (second-to-last + * array element since the last is a sentinel). The reason for placing + * the default last rather than first is that DES needs to be at the + * bottom for the algorithm guessing logic in crypt(3) to work correctly, + * and it needs to be the default for backward compatibility. */ static const struct crypt_format { const char *const name; char *(*const func)(const char *, const char *); const char *const magic; } crypt_formats[] = { - /* default format */ - { "sha512", crypt_sha512, "$6$" }, - - /* other supported formats */ { "md5", crypt_md5, "$1$" }, #ifdef HAS_BLOWFISH { "blf", crypt_blowfish, "$2" }, #endif { "nth", crypt_nthash, "$3$" }, { "sha256", crypt_sha256, "$5$" }, + { "sha512", crypt_sha512, "$6$" }, #ifdef HAS_DES { "des", crypt_des, "_" }, #endif @@ -63,7 +65,8 @@ static const struct crypt_format { { NULL, NULL, NULL } }; -static const struct crypt_format *crypt_format = &crypt_formats[0]; +static const struct crypt_format *crypt_format = + &crypt_formats[(sizeof crypt_formats / sizeof *crypt_formats) - 2]; #define DES_SALT_ALPHABET \ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410212109.s9LL9s3g094325>