Rev 47 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 47 | Rev 50 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #! /bin/sh /usr/share/dpatch/dpatch-run |
1 | #! /bin/sh /usr/share/dpatch/dpatch-run |
2 | ## 02_smartlink_rpath.dpatch |
2 | ## 02_smartlink_rpath.dpatch |
3 | ## |
3 | ## |
4 | ## DP: Patch from CVS to make the Nettle module compile with Nettle 2.0 |
4 | ## DP: Changes from CVS to make the Nettle module compile with Nettle 2.0 |
5 | 5 | ||
6 | @DPATCH@ |
6 | @DPATCH@ |
7 | 7 | ||
8 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/acconfig.h pike-cvs/7.8/src/post_modules/Nettle/acconfig.h |
- | |
9 | --- Pike-v7.8.316/src/post_modules/Nettle/acconfig.h 2004-02-21 06:07:35.000000000 +0100 |
- | |
10 | +++ pike-cvs/7.8/src/post_modules/Nettle/acconfig.h 2009-07-02 18:35:38.000000000 +0200 |
- | |
11 | @@ -1 +1,5 @@ |
- | |
12 | +/* Define this if your struct yarrow256_ctx has the field seed_file. */ |
- | |
13 | +#undef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
- | |
14 | - | ||
15 | +/* Define this if the nettle_crypt_func typedef is a pointer type. */ |
- | |
16 | +#undef HAVE_NETTLE_CRYPT_FUNC_IS_POINTER |
- | |
17 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod |
8 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod |
18 | --- Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod 2008-07-31 16:52:27.000000000 +0200 |
9 | --- Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod 2008-07-31 16:52:27.000000000 +0200 |
19 | +++ pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod 2009-07-02 18:35:38.000000000 +0200 |
10 | +++ pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod 2009-07-02 18:35:38.000000000 +0200 |
20 | @@ -65,6 +65,13 @@ |
- | |
21 | /* Force means to use key even if it is weak */ |
- | |
22 | int force); |
- | |
23 | - | ||
24 | +#ifdef HAVE_NETTLE_CRYPT_FUNC_IS_POINTER |
- | |
25 | +typedef nettle_crypt_func crypt_func; |
- | |
26 | +#else |
- | |
27 | +/* Nettle 2.0 */ |
- | |
28 | +typedef nettle_crypt_func *crypt_func; |
- | |
29 | +#endif |
- | |
30 | + |
- | |
31 | struct pike_cipher |
- | |
32 | { |
- | |
33 | const char *name; |
- | |
34 | @@ -79,8 +86,8 @@ |
11 | @@ -79,8 +86,8 @@ |
35 | pike_nettle_set_key_func set_encrypt_key; |
12 | pike_nettle_set_key_func set_encrypt_key; |
36 | pike_nettle_set_key_func set_decrypt_key; |
13 | pike_nettle_set_key_func set_decrypt_key; |
37 | 14 | ||
38 | - nettle_crypt_func encrypt; |
15 | - nettle_crypt_func encrypt; |
39 | - nettle_crypt_func decrypt; |
16 | - nettle_crypt_func decrypt; |
40 | + crypt_func encrypt; |
17 | + nettle_crypt_func *encrypt; |
41 | + crypt_func decrypt; |
18 | + nettle_crypt_func *decrypt; |
42 | }; |
19 | }; |
43 | 20 | ||
44 | #define _PIKE_CIPHER(name, NAME) { \ |
21 | #define _PIKE_CIPHER(name, NAME) { \ |
45 | @@ -90,8 +97,8 @@ |
22 | @@ -90,8 +97,8 @@ |
46 | NAME##_KEY_SIZE, \ |
23 | NAME##_KEY_SIZE, \ |
47 | pike_##name##_set_encrypt_key, \ |
24 | pike_##name##_set_encrypt_key, \ |
48 | pike_##name##_set_decrypt_key, \ |
25 | pike_##name##_set_decrypt_key, \ |
49 | - (nettle_crypt_func) name##_encrypt, \ |
26 | - (nettle_crypt_func) name##_encrypt, \ |
50 | - (nettle_crypt_func) name##_decrypt, \ |
27 | - (nettle_crypt_func) name##_decrypt, \ |
51 | + (crypt_func) name##_encrypt, \ |
28 | + (nettle_crypt_func*) name##_encrypt, \ |
52 | + (crypt_func) name##_decrypt, \ |
29 | + (nettle_crypt_func*) name##_decrypt, \ |
53 | } |
30 | } |
54 | 31 | ||
55 | /*! @class CipherInfo |
32 | /*! @class CipherInfo |
56 | @@ -175,7 +182,7 @@ |
33 | @@ -175,7 +182,7 @@ |
57 | PIKECLASS CipherState |
34 | PIKECLASS CipherState |
58 | { |
35 | { |
59 | INHERIT CipherInfo; |
36 | INHERIT CipherInfo; |
60 | - CVAR nettle_crypt_func crypt; |
37 | - CVAR nettle_crypt_func crypt; |
61 | + CVAR crypt_func crypt; |
38 | + CVAR nettle_crypt_func *crypt; |
62 | CVAR void *ctx; |
39 | CVAR void *ctx; |
63 | CVAR int key_size; |
40 | CVAR int key_size; |
64 | 41 | ||
65 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/configure.in pike-cvs/7.8/src/post_modules/Nettle/configure.in |
- | |
66 | --- Pike-v7.8.316/src/post_modules/Nettle/configure.in 2008-07-17 12:53:20.000000000 +0200 |
- | |
67 | +++ pike-cvs/7.8/src/post_modules/Nettle/configure.in 2009-07-02 23:27:56.000000000 +0200 |
- | |
68 | @@ -54,6 +54,52 @@ |
- | |
69 | AC_MSG_RESULT([no]) |
- | |
70 | IDEA_OBJ="" |
- | |
71 | fi |
- | |
72 | + |
- | |
73 | + # These might have been purged from the Nettle lib to avoid GPL |
- | |
74 | + # contamination. |
- | |
75 | + AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) |
- | |
76 | + |
- | |
77 | + # This is the recomended interface in Nettle 2.0. |
- | |
78 | + AC_CHECK_FUNCS(nettle_yarrow256_slow_reseed) |
- | |
79 | + |
- | |
80 | + AC_MSG_CHECKING([for struct yarrow256_ctx.seed_file]) |
- | |
81 | + AC_CACHE_VAL(pike_cv_nettle_struct_yarrow256_ctx_seed_file, [ |
- | |
82 | + pike_cv_nettle_struct_yarrow256_ctx_seed_file=no |
- | |
83 | + AC_TRY_COMPILE([ |
- | |
84 | +#include <nettle/yarrow.h> |
- | |
85 | + ], [ |
- | |
86 | + struct yarrow256_ctx ctx; |
- | |
87 | + return !sizeof(ctx.seed_file); |
- | |
88 | + ], [ |
- | |
89 | + pike_cv_nettle_struct_yarrow256_ctx_seed_file=yes |
- | |
90 | + ]) |
- | |
91 | + ]) |
- | |
92 | + AC_MSG_RESULT($pike_cv_nettle_struct_yarrow256_ctx_seed_file); |
- | |
93 | + if test "x$pike_cv_nettle_struct_yarrow256_ctx_seed_file" = "xyes"; then |
- | |
94 | + AC_DEFINE(HAVE_STRUCT_YARROW256_CTX_SEED_FILE) |
- | |
95 | + fi |
- | |
96 | + |
- | |
97 | + AC_MSG_CHECKING([whether nettle_crypt_func is a pointer type]) |
- | |
98 | + AC_CACHE_VAL(pike_cv_nettle_crypt_func_is_pointer, [ |
- | |
99 | + pike_cv_nettle_crypt_func_is_pointer=no |
- | |
100 | + AC_TRY_COMPILE([ |
- | |
101 | +/* Note: Old Nettles had the nettle_crypt_func typedef directly |
- | |
102 | + * in <nettle/nettle-meta.h> while more modern have it in |
- | |
103 | + * <nettle/nettle-types.h>. Since <nettle/nettle-meta.h> |
- | |
104 | + * pulls in <nettle/nettle-types.h> it should be sufficient. |
- | |
105 | + */ |
- | |
106 | +#include <nettle/nettle-meta.h> |
- | |
107 | + ], [ |
- | |
108 | + nettle_crypt_func foo = (nettle_crypt_func)(void *)0; |
- | |
109 | + return (int)foo; |
- | |
110 | + ], [ |
- | |
111 | + pike_cv_nettle_crypt_func_is_pointer=yes |
- | |
112 | + ]) |
- | |
113 | + ]) |
- | |
114 | + AC_MSG_RESULT($pike_cv_nettle_crypt_func_is_pointer); |
- | |
115 | + if test "x$pike_cv_nettle_crypt_func_is_pointer" = "xyes"; then |
- | |
116 | + AC_DEFINE(HAVE_NETTLE_CRYPT_FUNC_IS_POINTER) |
- | |
117 | + fi |
- | |
118 | else |
- | |
119 | if test "$ac_cv_lib_gmp_mpz_init:$ac_cv_lib_gmp___mpz_init:$ac_cv_lib_gmp___gmpz_init" = "no:no:no"; then |
- | |
120 | # No gmp found; enable it if possible. |
- | |
121 | @@ -76,10 +122,6 @@ |
- | |
122 | ]) |
- | |
123 | PIKE_FEATURE_NODEP(Nettle) |
- | |
124 | fi |
- | |
125 | - |
- | |
126 | - # These might have been purged from the Nettle lib to avoid GPL |
- | |
127 | - # contamination. |
- | |
128 | - AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) |
- | |
129 | fi |
- | |
130 | - | ||
131 | AC_OUTPUT(Makefile,echo FOO >stamp-h ) |
- | |
132 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod |
42 | diff -urad Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod |
133 | --- Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod 2008-06-29 00:57:14.000000000 +0200 |
43 | --- Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod 2008-06-29 00:57:14.000000000 +0200 |
134 | +++ pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod 2009-07-05 21:41:58.000000000 +0200 |
44 | +++ pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod 2009-07-05 21:41:58.000000000 +0200 |
135 | @@ -46,6 +46,36 @@ |
45 | @@ -46,6 +46,21 @@ |
136 | CVAR struct yarrow256_ctx ctx; |
46 | CVAR struct yarrow256_ctx ctx; |
137 | CVAR struct yarrow_source *sources; |
47 | CVAR struct yarrow_source *sources; |
138 | 48 | ||
139 | +#ifndef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
- | |
140 | + /* NOTE: Nettle 2.0 does not have the automatic seed_file maintenance |
- | |
141 | + * that Nettle 1.x had. This stuff is needed since it affected |
- | |
142 | + * the state emitted by random_string(). When Nettle 2.0 is the |
- | |
143 | + * default, consider implementing this via overloading of the |
- | |
144 | + * various seeding functions instead, since it does have a bit |
- | |
145 | + * of overhead. |
- | |
146 | + * |
- | |
147 | + * /grubba 2009-07-05 |
- | |
148 | + */ |
- | |
149 | + PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC; |
49 | + PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC; |
150 | +#endif |
- | |
151 | + |
50 | + |
152 | + DECLARE_STORAGE; |
51 | + DECLARE_STORAGE; |
153 | + |
52 | + |
154 | +#ifndef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
- | |
155 | + static void pike_generate_seed_file(void) |
53 | + static void pike_generate_seed_file(void) |
156 | + { |
54 | + { |
157 | + struct pike_string *seed_file = |
55 | + struct pike_string *seed_file = |
158 | + begin_shared_string(YARROW256_SEED_FILE_SIZE); |
56 | + begin_shared_string(YARROW256_SEED_FILE_SIZE); |
159 | + yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(seed_file)); |
57 | + yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(seed_file)); |
160 | + if (THIS->seed_file) { |
58 | + if (THIS->seed_file) { |
161 | + free_string(THIS->seed_file); |
59 | + free_string(THIS->seed_file); |
162 | + } |
60 | + } |
163 | + THIS->seed_file = end_shared_string(seed_file); |
61 | + THIS->seed_file = end_shared_string(seed_file); |
164 | + } |
62 | + } |
165 | +#else |
- | |
166 | +#define pike_generate_seed_file() |
- | |
167 | +#endif |
- | |
168 | + |
63 | + |
169 | /*! @decl void create(void|int sources) |
64 | /*! @decl void create(void|int sources) |
170 | *! The number of entropy sources that will feed entropy to the |
65 | *! The number of entropy sources that will feed entropy to the |
171 | *! random number generator is given as an argument to Yarrow |
66 | *! random number generator is given as an argument to Yarrow |
172 | @@ -90,10 +120,12 @@ |
67 | @@ -90,10 +120,12 @@ |
Line 182... | Line 77... | ||
182 | + yarrow256_seed(&THIS->ctx, data->len, STR0(data)); |
77 | + yarrow256_seed(&THIS->ctx, data->len, STR0(data)); |
183 | + pike_generate_seed_file(); |
78 | + pike_generate_seed_file(); |
184 | RETURN this_object(); |
79 | RETURN this_object(); |
185 | } |
80 | } |
186 | 81 | ||
187 | @@ -109,19 +141,31 @@ |
82 | @@ -109,19 +141,26 @@ |
188 | RETURN YARROW256_SEED_FILE_SIZE; |
83 | RETURN YARROW256_SEED_FILE_SIZE; |
189 | } |
84 | } |
190 | 85 | ||
191 | - /*! @decl string get_seed() |
86 | - /*! @decl string get_seed() |
192 | - *! Returns part of the internal state so that it can |
87 | - *! Returns part of the internal state so that it can |
Line 206... | Line 101... | ||
206 | if( !yarrow256_is_seeded(&THIS->ctx) ) |
101 | if( !yarrow256_is_seeded(&THIS->ctx) ) |
207 | Pike_error("Random generator not seeded.\n"); |
102 | Pike_error("Random generator not seeded.\n"); |
208 | - RETURN make_shared_binary_string((const char *)THIS->ctx.seed_file, |
103 | - RETURN make_shared_binary_string((const char *)THIS->ctx.seed_file, |
209 | - YARROW256_SEED_FILE_SIZE); |
104 | - YARROW256_SEED_FILE_SIZE); |
210 | + |
105 | + |
211 | +#ifdef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
- | |
212 | + RETURN make_shared_binary_string(THIS->ctx.seed_file, |
- | |
213 | + YARROW256_SEED_FILE_SIZE); |
- | |
214 | +#else |
- | |
215 | + if (THIS->seed_file) { |
106 | + if (THIS->seed_file) { |
216 | + REF_RETURN THIS->seed_file; |
107 | + REF_RETURN THIS->seed_file; |
217 | + } else { |
108 | + } else { |
218 | + struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE); |
109 | + struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE); |
219 | + RETURN end_shared_string(s); |
110 | + RETURN end_shared_string(s); |
220 | + } |
111 | + } |
221 | +#endif /* HAVE_STRUCT_YARROW256_CTX_SEED_FILE */ |
- | |
222 | } |
112 | } |
223 | 113 | ||
224 | /*! @decl int(0..1) is_seeded() |
114 | /*! @decl int(0..1) is_seeded() |
225 | @@ -144,7 +188,19 @@ |
115 | @@ -144,7 +188,8 @@ |
226 | PIKEFUN void force_reseed() |
116 | PIKEFUN void force_reseed() |
227 | optflags OPT_SIDE_EFFECT; |
117 | optflags OPT_SIDE_EFFECT; |
228 | { |
118 | { |
229 | +#ifdef HAVE_NETTLE_YARROW256_SLOW_RESEED |
- | |
230 | + /* From change notes for Nettle 2.0: |
- | |
231 | + * |
- | |
232 | + * * Changes to the yarrow256 interface. The function |
- | |
233 | + * yarrow256_force_reseed has been replaced by the two |
119 | - yarrow256_force_reseed(&THIS->ctx); |
234 | + * functions yarrow256_fast_reseed and yarrow256_slow_reseed, |
- | |
235 | + * which were previously static. |
- | |
236 | + */ |
- | |
237 | + yarrow256_slow_reseed(&THIS->ctx); |
120 | + yarrow256_slow_reseed(&THIS->ctx); |
238 | +#else |
- | |
239 | yarrow256_force_reseed(&THIS->ctx); |
- | |
240 | +#endif |
- | |
241 | + pike_generate_seed_file(); |
121 | + pike_generate_seed_file(); |
242 | } |
122 | } |
243 | 123 | ||
244 | /*! @decl int(0..1) update(string data, int source, int entropy) |
124 | /*! @decl int(0..1) update(string data, int source, int entropy) |
245 | @@ -156,6 +212,7 @@ |
125 | @@ -156,6 +212,7 @@ |