Subversion Repositories pike

Compare Revisions

Ignore whitespace Rev 37 → Rev 48

/branches/7.6-stable/debian/patches/nettle_2.0.dpatch
0,0 → 1,133
#! /bin/sh /usr/share/dpatch/dpatch-run
## nettle_2.0.dpatch by <holmgren@debian.org>
##
## DP: Changes from CVS to make the Nettle module compile with Nettle 2.0
 
@DPATCH@
diff -urNad 7.6-stable~/src/post_modules/Nettle/cipher.cmod 7.6-stable/src/post_modules/Nettle/cipher.cmod
--- 7.6-stable~/src/post_modules/Nettle/cipher.cmod 2004-02-21 19:36:35.000000000 +0100
+++ 7.6-stable/src/post_modules/Nettle/cipher.cmod 2009-08-18 21:51:38.000000000 +0200
@@ -69,8 +69,8 @@
pike_nettle_set_key_func set_encrypt_key;
pike_nettle_set_key_func set_decrypt_key;
- nettle_crypt_func encrypt;
- nettle_crypt_func decrypt;
+ nettle_crypt_func *encrypt;
+ nettle_crypt_func *decrypt;
};
#define _PIKE_CIPHER(name, NAME) { \
@@ -80,8 +80,8 @@
NAME##_KEY_SIZE, \
pike_##name##_set_encrypt_key, \
pike_##name##_set_decrypt_key, \
- (nettle_crypt_func) name##_encrypt, \
- (nettle_crypt_func) name##_decrypt, \
+ (nettle_crypt_func*) name##_encrypt, \
+ (nettle_crypt_func*) name##_decrypt, \
}
/*! @class CipherInfo
@@ -165,7 +165,7 @@
PIKECLASS CipherState
{
INHERIT CipherInfo;
- CVAR nettle_crypt_func crypt;
+ CVAR nettle_crypt_func *crypt;
CVAR void *ctx;
CVAR int key_size;
diff -urNad 7.6-stable~/src/post_modules/Nettle/nettle.cmod 7.6-stable/src/post_modules/Nettle/nettle.cmod
--- 7.6-stable~/src/post_modules/Nettle/nettle.cmod 2005-12-11 19:01:46.000000000 +0100
+++ 7.6-stable/src/post_modules/Nettle/nettle.cmod 2009-08-18 21:51:38.000000000 +0200
@@ -46,6 +46,19 @@
CVAR struct yarrow256_ctx ctx;
CVAR struct yarrow_source *sources;
+ PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC;
+
+ static void pike_generate_seed_file(void)
+ {
+ struct pike_string *seed_file =
+ begin_shared_string(YARROW256_SEED_FILE_SIZE);
+ yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(seed_file));
+ if (THIS->seed_file) {
+ free_string(THIS->seed_file);
+ }
+ THIS->seed_file = end_shared_string(seed_file);
+ }
+
/*! @decl void create(void|int sources)
*! The number of entropy sources that will feed entropy to the
*! random number generator is given as an argument to Yarrow
@@ -93,6 +106,7 @@
NO_WIDE_STRING(data);
yarrow256_seed(&THIS->ctx, data->len, data->str);
+ pike_generate_seed_file();
RETURN this_object();
}
@@ -119,8 +133,12 @@
{
if( !yarrow256_is_seeded(&THIS->ctx) )
Pike_error("Random generator not seeded.\n");
- RETURN make_shared_binary_string(THIS->ctx.seed_file,
- YARROW256_SEED_FILE_SIZE);
+ if (THIS->seed_file) {
+ REF_RETURN THIS->seed_file;
+ } else {
+ struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE);
+ RETURN end_shared_string(s);
+ }
}
/*! @decl int(0..1) is_seeded()
@@ -143,7 +161,8 @@
PIKEFUN void force_reseed()
optflags OPT_SIDE_EFFECT;
{
- yarrow256_force_reseed(&THIS->ctx);
+ yarrow256_slow_reseed(&THIS->ctx);
+ pike_generate_seed_file();
}
/*! @decl int(0..1) update(string data, int source, int entropy)
@@ -156,6 +212,7 @@
PIKEFUN int(0..1) update(string data, int source, int entropy)
optflags OPT_SIDE_EFFECT;
{
+ int ret;
/* FIXME: Wide strings could actually be supported here */
NO_WIDE_STRING(data);
if( !THIS->sources )
@@ -165,7 +184,10 @@
Pike_error("Entropy must be positive.\n");
if( entropy>(data->len*8) )
Pike_error("Impossibly large entropy value.\n");
- RETURN yarrow256_update(&THIS->ctx, source, entropy, data->len, data->str);
+ ret = yarrow256_update(&THIS->ctx, source, entropy, data->len, data->str);
+ if (ret)
+ pike_generate_seed_file();
+ RETURN ret;
}
/*! @decl int(0..) needed_sources()
diff -urad 7.6-stable~/src/post_modules/Nettle/testsuite.in 7.6-stable/7.8/src/post_modules/Nettle/testsuite.in
--- 7.6-stable~/src/post_modules/Nettle/testsuite.in 2007-06-18 02:43:51.000000000 +0200
+++ 7.6-stable/src/post_modules/Nettle/testsuite.in 2009-08-05 12:01:45.000000000 +0200
@@ -193,4 +193,14 @@
}
)
]])
+
+cond_resolv( Nettle.Yarrow, [[
+ test_any_equal([[
+ object y = Nettle.Yarrow()->seed("What happen? Somebody set up us the bomb.");
+ return ({ y->get_seed(), y->random_string(20), y->get_seed(), y->random_string(20) });
+ ]], [[({String.hex2string("73a35b2f896a8061be0ad434a592a43a82b81b9ed6c018f1c5a51300bbc8d53d"),
+ String.hex2string("7847458e32fb789ff6b6cd6e1c8cc3712ba532a8"),
+ String.hex2string("73a35b2f896a8061be0ad434a592a43a82b81b9ed6c018f1c5a51300bbc8d53d"),
+ String.hex2string("49a090656a6d93782e169994f41005a3616d3cd7")})]])
+]])
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: 7.6-stable/debian/changelog
===================================================================
--- 7.6-stable/debian/changelog (revision 37)
+++ 7.6-stable/debian/changelog (revision 48)
@@ -1,3 +1,12 @@
+pike7.6 (7.6.112-5) unstable; urgency=low
+
+ * Switch to Nettle 2.0 (Build-Depend on nettle-dev instead of
+ libnettle-dev).
+ + nettle_2.0.dpatch: Changes from upstream CVS needed to accomodate the
+ API changes.
+
+ -- Magnus Holmgren <holmgren@debian.org> Tue, 18 Aug 2009 22:36:00 +0200
+
pike7.6 (7.6.112-4) unstable; urgency=low
* 12_perl_init.dpatch: Don't use .bak as filename extension for the