diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-10 18:52:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-10 18:52:35 +0000 |
commit | 2211d5268cc6fc5575f758a9835070fae5ffc405 (patch) | |
tree | 46b23253b2be2c2c5bcdb6909a740e894a93ae07 /loginutils | |
parent | 56dceb9b7722193ef53fb1afb981f1289eecb0b0 (diff) | |
download | busybox-w32-2211d5268cc6fc5575f758a9835070fae5ffc405.tar.gz busybox-w32-2211d5268cc6fc5575f758a9835070fae5ffc405.tar.bz2 busybox-w32-2211d5268cc6fc5575f758a9835070fae5ffc405.zip |
libbb: add optionl support for SHA256/512 encrypted passwords
function old new delta
sha_crypt - 2423 +2423
cryptpw_main 128 183 +55
to64 - 29 +29
pw_encrypt 974 1000 +26
str_rounds - 11 +11
login_main 1532 1541 +9
packed_usage 25215 25200 -15
__md5_to64 29 - -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 3/1 up/down: 2553/-44) Total: 2509 bytes
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/Config.in | 14 | ||||
-rw-r--r-- | loginutils/cryptpw.c | 28 |
2 files changed, 34 insertions, 8 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in index bb1369cdd..5f66e8685 100644 --- a/loginutils/Config.in +++ b/loginutils/Config.in | |||
@@ -58,7 +58,7 @@ config USE_BB_SHADOW | |||
58 | password servers and whatnot. | 58 | password servers and whatnot. |
59 | 59 | ||
60 | config USE_BB_CRYPT | 60 | config USE_BB_CRYPT |
61 | bool "Use internal DES and MD5 crypt functions" | 61 | bool "Use internal crypt functions" |
62 | default y | 62 | default y |
63 | help | 63 | help |
64 | Busybox has internal DES and MD5 crypt functions. | 64 | Busybox has internal DES and MD5 crypt functions. |
@@ -79,6 +79,18 @@ config USE_BB_CRYPT | |||
79 | In static build, it makes code _smaller_ by about 1.2k, | 79 | In static build, it makes code _smaller_ by about 1.2k, |
80 | and likely many kilobytes less of bss. | 80 | and likely many kilobytes less of bss. |
81 | 81 | ||
82 | config USE_BB_CRYPT_SHA | ||
83 | bool "Enable SHA256/512 crypt functions" | ||
84 | default n | ||
85 | depends on USE_BB_CRYPT | ||
86 | help | ||
87 | Enable this if you have passwords starting with "$5$" or "$6$" | ||
88 | in your /etc/passwd or /etc/shadow files. These passwords | ||
89 | are hashed using SHA256 and SHA512 algorithms. Support for them | ||
90 | was added to glibc in 2008. | ||
91 | With this option off, login will fail password check for any | ||
92 | user which has password encrypted with these algorithms. | ||
93 | |||
82 | config ADDGROUP | 94 | config ADDGROUP |
83 | bool "addgroup" | 95 | bool "addgroup" |
84 | default n | 96 | default n |
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index db5d95920..d76deac20 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c | |||
@@ -34,22 +34,36 @@ done | |||
34 | int cryptpw_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 34 | int cryptpw_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
35 | int cryptpw_main(int argc UNUSED_PARAM, char **argv) | 35 | int cryptpw_main(int argc UNUSED_PARAM, char **argv) |
36 | { | 36 | { |
37 | char salt[sizeof("$N$XXXXXXXX")]; | 37 | char salt[sizeof("$N$") + 16]; |
38 | char *opt_a; | 38 | char *opt_a; |
39 | int opts; | ||
39 | 40 | ||
40 | if (!getopt32(argv, "a:", &opt_a) || opt_a[0] != 'd') { | 41 | opts = getopt32(argv, "a:", &opt_a); |
42 | |||
43 | if (opts && opt_a[0] == 'd') { | ||
44 | crypt_make_salt(salt, 2/2, 0); /* des */ | ||
45 | #if TESTING | ||
46 | strcpy(salt, "a."); | ||
47 | #endif | ||
48 | } else { | ||
41 | salt[0] = '$'; | 49 | salt[0] = '$'; |
42 | salt[1] = '1'; | 50 | salt[1] = '1'; |
43 | salt[2] = '$'; | 51 | salt[2] = '$'; |
44 | crypt_make_salt(salt + 3, 4, 0); /* md5 */ | 52 | #if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA |
53 | if (opts && opt_a[0] == 's') { | ||
54 | salt[1] = '5' + (strcmp(opt_a, "sha512") == 0); | ||
55 | crypt_make_salt(salt + 3, 16/2, 0); /* sha */ | ||
45 | #if TESTING | 56 | #if TESTING |
46 | strcpy(salt + 3, "ajg./bcf"); | 57 | strcpy(salt, "$6$em7yVj./Mv5n1V5X"); |
47 | #endif | 58 | #endif |
48 | } else { | 59 | } else |
49 | crypt_make_salt(salt, 1, 0); /* des */ | 60 | #endif |
61 | { | ||
62 | crypt_make_salt(salt + 3, 8/2, 0); /* md5 */ | ||
50 | #if TESTING | 63 | #if TESTING |
51 | strcpy(salt, "a."); | 64 | strcpy(salt + 3, "ajg./bcf"); |
52 | #endif | 65 | #endif |
66 | } | ||
53 | } | 67 | } |
54 | 68 | ||
55 | puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_fgetline(stdin), salt, 1)); | 69 | puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_fgetline(stdin), salt, 1)); |