Rev 45 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 45 | Rev 46 | ||
---|---|---|---|
1 | #! /bin/sh /usr/share/dpatch/dpatch-run |
1 | #! /bin/sh /usr/share/dpatch/dpatch-run |
2 | ## nettle_2.0.dpatch by <holmgren@debian.org> |
2 | ## nettle_2.0.dpatch by <holmgren@debian.org> |
3 | ## |
3 | ## |
4 | ## All lines beginning with `## DP:' are a description of the patch. |
4 | ## All lines beginning with `## DP:' are a description of the patch. |
5 | ## DP: No description. |
5 | ## DP: No description. |
6 | 6 | ||
7 | @DPATCH@ |
7 | @DPATCH@ |
8 | diff -urNad 7.6-stable~/src/post_modules/Nettle/cipher.cmod 7.6-stable/src/post_modules/Nettle/cipher.cmod |
8 | diff -urNad 7.6-stable~/src/post_modules/Nettle/cipher.cmod 7.6-stable/src/post_modules/Nettle/cipher.cmod |
9 | --- 7.6-stable~/src/post_modules/Nettle/cipher.cmod 2004-02-21 19:36:35.000000000 +0100 |
9 | --- 7.6-stable~/src/post_modules/Nettle/cipher.cmod 2004-02-21 19:36:35.000000000 +0100 |
10 | +++ 7.6-stable/src/post_modules/Nettle/cipher.cmod 2009-08-18 21:51:38.000000000 +0200 |
10 | +++ 7.6-stable/src/post_modules/Nettle/cipher.cmod 2009-08-18 21:51:38.000000000 +0200 |
11 | @@ -69,8 +69,8 @@ |
11 | @@ -69,8 +69,8 @@ |
12 | pike_nettle_set_key_func set_encrypt_key; |
12 | pike_nettle_set_key_func set_encrypt_key; |
13 | pike_nettle_set_key_func set_decrypt_key; |
13 | pike_nettle_set_key_func set_decrypt_key; |
14 | 14 | ||
15 | - nettle_crypt_func encrypt; |
15 | - nettle_crypt_func encrypt; |
16 | - nettle_crypt_func decrypt; |
16 | - nettle_crypt_func decrypt; |
17 | + nettle_crypt_func *encrypt; |
17 | + nettle_crypt_func *encrypt; |
18 | + nettle_crypt_func *decrypt; |
18 | + nettle_crypt_func *decrypt; |
19 | }; |
19 | }; |
20 | 20 | ||
21 | #define _PIKE_CIPHER(name, NAME) { \ |
21 | #define _PIKE_CIPHER(name, NAME) { \ |
22 | @@ -80,8 +80,8 @@ |
22 | @@ -80,8 +80,8 @@ |
23 | NAME##_KEY_SIZE, \ |
23 | NAME##_KEY_SIZE, \ |
24 | pike_##name##_set_encrypt_key, \ |
24 | pike_##name##_set_encrypt_key, \ |
25 | pike_##name##_set_decrypt_key, \ |
25 | pike_##name##_set_decrypt_key, \ |
26 | - (nettle_crypt_func) name##_encrypt, \ |
26 | - (nettle_crypt_func) name##_encrypt, \ |
27 | - (nettle_crypt_func) name##_decrypt, \ |
27 | - (nettle_crypt_func) name##_decrypt, \ |
28 | + (nettle_crypt_func*) name##_encrypt, \ |
28 | + (nettle_crypt_func*) name##_encrypt, \ |
29 | + (nettle_crypt_func*) name##_decrypt, \ |
29 | + (nettle_crypt_func*) name##_decrypt, \ |
30 | } |
30 | } |
31 | 31 | ||
32 | /*! @class CipherInfo |
32 | /*! @class CipherInfo |
33 | @@ -165,7 +165,7 @@ |
33 | @@ -165,7 +165,7 @@ |
34 | PIKECLASS CipherState |
34 | PIKECLASS CipherState |
35 | { |
35 | { |
36 | INHERIT CipherInfo; |
36 | INHERIT CipherInfo; |
37 | - CVAR nettle_crypt_func crypt; |
37 | - CVAR nettle_crypt_func crypt; |
38 | + CVAR nettle_crypt_func *crypt; |
38 | + CVAR nettle_crypt_func *crypt; |
39 | CVAR void *ctx; |
39 | CVAR void *ctx; |
40 | CVAR int key_size; |
40 | CVAR int key_size; |
41 | 41 | ||
42 | diff -urNad 7.6-stable~/src/post_modules/Nettle/nettle.cmod 7.6-stable/src/post_modules/Nettle/nettle.cmod |
42 | diff -urNad 7.6-stable~/src/post_modules/Nettle/nettle.cmod 7.6-stable/src/post_modules/Nettle/nettle.cmod |
43 | --- 7.6-stable~/src/post_modules/Nettle/nettle.cmod 2005-12-11 19:01:46.000000000 +0100 |
43 | --- 7.6-stable~/src/post_modules/Nettle/nettle.cmod 2005-12-11 19:01:46.000000000 +0100 |
44 | +++ 7.6-stable/src/post_modules/Nettle/nettle.cmod 2009-08-18 21:51:38.000000000 +0200 |
44 | +++ 7.6-stable/src/post_modules/Nettle/nettle.cmod 2009-08-18 21:51:38.000000000 +0200 |
45 | @@ -46,6 +46,19 @@ |
45 | @@ -46,6 +46,19 @@ |
46 | CVAR struct yarrow256_ctx ctx; |
46 | CVAR struct yarrow256_ctx ctx; |
47 | CVAR struct yarrow_source *sources; |
47 | CVAR struct yarrow_source *sources; |
48 | 48 | ||
49 | + PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC; |
49 | + PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC; |
50 | + |
50 | + |
51 | + static void pike_generate_seed_file(void) |
51 | + static void pike_generate_seed_file(void) |
52 | + { |
52 | + { |
53 | + struct pike_string *seed_file = |
53 | + struct pike_string *seed_file = |
54 | + begin_shared_string(YARROW256_SEED_FILE_SIZE); |
54 | + begin_shared_string(YARROW256_SEED_FILE_SIZE); |
55 | + yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(seed_file)); |
55 | + yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(seed_file)); |
56 | + if (THIS->seed_file) { |
56 | + if (THIS->seed_file) { |
57 | + free_string(THIS->seed_file); |
57 | + free_string(THIS->seed_file); |
58 | + } |
58 | + } |
59 | + THIS->seed_file = end_shared_string(seed_file); |
59 | + THIS->seed_file = end_shared_string(seed_file); |
60 | + } |
60 | + } |
61 | + |
61 | + |
62 | /*! @decl void create(void|int sources) |
62 | /*! @decl void create(void|int sources) |
63 | *! The number of entropy sources that will feed entropy to the |
63 | *! The number of entropy sources that will feed entropy to the |
64 | *! random number generator is given as an argument to Yarrow |
64 | *! random number generator is given as an argument to Yarrow |
65 | @@ -93,6 +106,7 @@ |
65 | @@ -93,6 +106,7 @@ |
66 | 66 | ||
67 | NO_WIDE_STRING(data); |
67 | NO_WIDE_STRING(data); |
68 | yarrow256_seed(&THIS->ctx, data->len, data->str); |
68 | yarrow256_seed(&THIS->ctx, data->len, data->str); |
69 | + pike_generate_seed_file(); |
69 | + pike_generate_seed_file(); |
70 | RETURN this_object(); |
70 | RETURN this_object(); |
71 | } |
71 | } |
72 | 72 | ||
73 | @@ -119,8 +133,12 @@ |
73 | @@ -119,8 +133,12 @@ |
74 | { |
74 | { |
75 | if( !yarrow256_is_seeded(&THIS->ctx) ) |
75 | if( !yarrow256_is_seeded(&THIS->ctx) ) |
76 | Pike_error("Random generator not seeded.\n"); |
76 | Pike_error("Random generator not seeded.\n"); |
77 | - RETURN make_shared_binary_string(THIS->ctx.seed_file, |
77 | - RETURN make_shared_binary_string(THIS->ctx.seed_file, |
78 | - YARROW256_SEED_FILE_SIZE); |
78 | - YARROW256_SEED_FILE_SIZE); |
79 | + if (THIS->seed_file) { |
79 | + if (THIS->seed_file) { |
80 | + REF_RETURN THIS->seed_file; |
80 | + REF_RETURN THIS->seed_file; |
81 | + } else { |
81 | + } else { |
82 | + struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE); |
82 | + struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE); |
83 | + RETURN end_shared_string(s); |
83 | + RETURN end_shared_string(s); |
84 | + } |
84 | + } |
85 | } |
85 | } |
86 | 86 | ||
87 | /*! @decl int(0..1) is_seeded() |
87 | /*! @decl int(0..1) is_seeded() |
88 | @@ -143,7 +161,8 @@ |
88 | @@ -143,7 +161,8 @@ |
89 | PIKEFUN void force_reseed() |
89 | PIKEFUN void force_reseed() |
90 | optflags OPT_SIDE_EFFECT; |
90 | optflags OPT_SIDE_EFFECT; |
91 | { |
91 | { |
92 | - yarrow256_force_reseed(&THIS->ctx); |
92 | - yarrow256_force_reseed(&THIS->ctx); |
93 | + yarrow256_slow_reseed(&THIS->ctx); |
93 | + yarrow256_slow_reseed(&THIS->ctx); |
94 | + pike_generate_seed_file(); |
94 | + pike_generate_seed_file(); |
95 | } |
95 | } |
96 | 96 | ||
97 | /*! @decl int(0..1) update(string data, int source, int entropy) |
97 | /*! @decl int(0..1) update(string data, int source, int entropy) |
98 | @@ -156,6 +212,7 @@ |
98 | @@ -156,6 +212,7 @@ |
99 | PIKEFUN int(0..1) update(string data, int source, int entropy) |
99 | PIKEFUN int(0..1) update(string data, int source, int entropy) |
100 | optflags OPT_SIDE_EFFECT; |
100 | optflags OPT_SIDE_EFFECT; |
101 | { |
101 | { |
102 | + int ret; |
102 | + int ret; |
103 | /* FIXME: Wide strings could actually be supported here */ |
103 | /* FIXME: Wide strings could actually be supported here */ |
104 | NO_WIDE_STRING(data); |
104 | NO_WIDE_STRING(data); |
105 | if( !THIS->sources ) |
105 | if( !THIS->sources ) |
106 | @@ -165,7 +184,11 @@ |
106 | @@ -165,7 +184,11 @@ |
107 | Pike_error("Entropy must be positive.\n"); |
107 | Pike_error("Entropy must be positive.\n"); |
108 | if( entropy>(data->len*8) ) |
108 | if( entropy>(data->len*8) ) |
109 | Pike_error("Impossibly large entropy value.\n"); |
109 | Pike_error("Impossibly large entropy value.\n"); |
110 | - RETURN yarrow256_update(&THIS->ctx, source, entropy, data->len, data->str); |
110 | - RETURN yarrow256_update(&THIS->ctx, source, entropy, data->len, data->str); |
111 | + ret = yarrow256_update(&THIS->ctx, source, entropy, data->len, |
111 | + ret = yarrow256_update(&THIS->ctx, source, entropy, data->len, |
112 | + (const uint8_t *)data->str); |
112 | + (const uint8_t *)data->str); |
113 | + if (ret) |
113 | + if (ret) |
114 | + pike_generate_seed_file(); |
114 | + pike_generate_seed_file(); |
115 | + RETURN ret; |
115 | + RETURN ret; |
116 | } |
116 | } |
117 | 117 | ||
118 | /*! @decl int(0..) needed_sources() |
118 | /*! @decl int(0..) needed_sources() |
- | 119 | diff -urad 7.6-stable~/src/post_modules/Nettle/testsuite.in 7.6-stable/7.8/src/post_modules/Nettle/testsuite.in |
|
- | 120 | --- 7.6-stable~/src/post_modules/Nettle/testsuite.in 2007-06-18 02:43:51.000000000 +0200 |
|
- | 121 | +++ 7.6-stable/src/post_modules/Nettle/testsuite.in 2009-08-05 12:01:45.000000000 +0200 |
|
- | 122 | @@ -193,4 +193,14 @@ |
|
- | 123 | } |
|
- | 124 | ) |
|
- | 125 | ]]) |
|
- | 126 | + |
|
- | 127 | +cond_resolv( Nettle.Yarrow, [[ |
|
- | 128 | + test_any_equal([[ |
|
- | 129 | + object y = Nettle.Yarrow()->seed("What happen? Somebody set up us the bomb."); |
|
- | 130 | + return ({ y->get_seed(), y->random_string(20), y->get_seed(), y->random_string(20) }); |
|
- | 131 | + ]], [[({String.hex2string("73a35b2f896a8061be0ad434a592a43a82b81b9ed6c018f1c5a51300bbc8d53d"), |
|
- | 132 | + String.hex2string("7847458e32fb789ff6b6cd6e1c8cc3712ba532a8"), |
|
- | 133 | + String.hex2string("73a35b2f896a8061be0ad434a592a43a82b81b9ed6c018f1c5a51300bbc8d53d"), |
|
- | 134 | + String.hex2string("49a090656a6d93782e169994f41005a3616d3cd7")})]]) |
|
- | 135 | +]]) |