musl: add a hack to remove unused crypt() algorithms, saves ~14k after lzma
[openwrt/staging/chunkeey.git] / toolchain / musl / patches / 901-crypt_size_hack.patch
1 --- a/src/crypt/crypt_r.c
2 +++ b/src/crypt/crypt_r.c
3 @@ -16,17 +16,7 @@ char *__crypt_r(const char *key, const c
4 * use the structure to store any internal state, and treats
5 * it purely as a char buffer for storing the result. */
6 char *output = (char *)data;
7 - if (salt[0] == '$' && salt[1] && salt[2]) {
8 - if (salt[1] == '1' && salt[2] == '$')
9 - return __crypt_md5(key, salt, output);
10 - if (salt[1] == '2' && salt[3] == '$')
11 - return __crypt_blowfish(key, salt, output);
12 - if (salt[1] == '5' && salt[2] == '$')
13 - return __crypt_sha256(key, salt, output);
14 - if (salt[1] == '6' && salt[2] == '$')
15 - return __crypt_sha512(key, salt, output);
16 - }
17 - return __crypt_des(key, salt, output);
18 + return __crypt_md5(key, salt, output);
19 }
20
21 weak_alias(__crypt_r, crypt_r);
22 --- a/src/crypt/crypt_sha512.c
23 +++ b/src/crypt/crypt_sha512.c
24 @@ -12,6 +12,7 @@
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdint.h>
28 +#if 0
29
30 /* public domain sha512 implementation based on fips180-3 */
31 /* >=2^64 bits messages are not supported (about 2000 peta bytes) */
32 @@ -369,3 +370,4 @@ char *__crypt_sha512(const char *key, co
33 return "*";
34 return p;
35 }
36 +#endif
37 --- a/src/crypt/crypt_blowfish.c
38 +++ b/src/crypt/crypt_blowfish.c
39 @@ -50,6 +50,7 @@
40 #include <string.h>
41 #include <stdint.h>
42
43 +#if 0
44 typedef uint32_t BF_word;
45 typedef int32_t BF_word_signed;
46
47 @@ -796,3 +797,4 @@ char *__crypt_blowfish(const char *key,
48
49 return "*";
50 }
51 +#endif
52 --- a/src/crypt/crypt_des.c
53 +++ b/src/crypt/crypt_des.c
54 @@ -56,6 +56,7 @@
55 #include <stdint.h>
56 #include <string.h>
57
58 +#if 0
59 struct expanded_key {
60 uint32_t l[16], r[16];
61 };
62 @@ -1016,3 +1017,4 @@ char *__crypt_des(const char *key, const
63
64 return (setting[0]=='*') ? "x" : "*";
65 }
66 +#endif
67 --- a/src/crypt/encrypt.c
68 +++ b/src/crypt/encrypt.c
69 @@ -16,6 +16,7 @@ static struct expanded_key __encrypt_key
70
71 void setkey(const char *key)
72 {
73 +#if 0
74 unsigned char bkey[8];
75 int i, j;
76
77 @@ -26,10 +27,12 @@ void setkey(const char *key)
78 }
79
80 __des_setkey(bkey, &__encrypt_key);
81 +#endif
82 }
83
84 void encrypt(char *block, int edflag)
85 {
86 +#if 0
87 struct expanded_key decrypt_key, *key;
88 uint32_t b[2];
89 int i, j;
90 @@ -57,4 +60,5 @@ void encrypt(char *block, int edflag)
91 for (i = 0; i < 2; i++)
92 for (j = 31; j >= 0; j--)
93 *p++ = b[i]>>j & 1;
94 +#endif
95 }
96 --- a/src/crypt/crypt_sha256.c
97 +++ b/src/crypt/crypt_sha256.c
98 @@ -13,6 +13,7 @@
99 #include <string.h>
100 #include <stdint.h>
101
102 +#if 0
103 /* public domain sha256 implementation based on fips180-3 */
104
105 struct sha256 {
106 @@ -320,3 +321,4 @@ char *__crypt_sha256(const char *key, co
107 return "*";
108 return p;
109 }
110 +#endif