1,36 → 1,13 |
#! /bin/sh /usr/share/dpatch/dpatch-run |
## 02_smartlink_rpath.dpatch |
## |
## DP: Patch from CVS to make the Nettle module compile with Nettle 2.0 |
## DP: Changes from CVS to make the Nettle module compile with Nettle 2.0 |
|
@DPATCH@ |
|
diff -urad Pike-v7.8.316/src/post_modules/Nettle/acconfig.h pike-cvs/7.8/src/post_modules/Nettle/acconfig.h |
--- Pike-v7.8.316/src/post_modules/Nettle/acconfig.h 2004-02-21 06:07:35.000000000 +0100 |
+++ pike-cvs/7.8/src/post_modules/Nettle/acconfig.h 2009-07-02 18:35:38.000000000 +0200 |
@@ -1 +1,5 @@ |
+/* Define this if your struct yarrow256_ctx has the field seed_file. */ |
+#undef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
|
+/* Define this if the nettle_crypt_func typedef is a pointer type. */ |
+#undef HAVE_NETTLE_CRYPT_FUNC_IS_POINTER |
diff -urad Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod |
--- Pike-v7.8.316/src/post_modules/Nettle/cipher.cmod 2008-07-31 16:52:27.000000000 +0200 |
+++ pike-cvs/7.8/src/post_modules/Nettle/cipher.cmod 2009-07-02 18:35:38.000000000 +0200 |
@@ -65,6 +65,13 @@ |
/* Force means to use key even if it is weak */ |
int force); |
|
+#ifdef HAVE_NETTLE_CRYPT_FUNC_IS_POINTER |
+typedef nettle_crypt_func crypt_func; |
+#else |
+/* Nettle 2.0 */ |
+typedef nettle_crypt_func *crypt_func; |
+#endif |
+ |
struct pike_cipher |
{ |
const char *name; |
@@ -79,8 +86,8 @@ |
pike_nettle_set_key_func set_encrypt_key; |
pike_nettle_set_key_func set_decrypt_key; |
37,8 → 14,8 |
|
- nettle_crypt_func encrypt; |
- nettle_crypt_func decrypt; |
+ crypt_func encrypt; |
+ crypt_func decrypt; |
+ nettle_crypt_func *encrypt; |
+ nettle_crypt_func *decrypt; |
}; |
|
#define _PIKE_CIPHER(name, NAME) { \ |
48,8 → 25,8 |
pike_##name##_set_decrypt_key, \ |
- (nettle_crypt_func) name##_encrypt, \ |
- (nettle_crypt_func) name##_decrypt, \ |
+ (crypt_func) name##_encrypt, \ |
+ (crypt_func) name##_decrypt, \ |
+ (nettle_crypt_func*) name##_encrypt, \ |
+ (nettle_crypt_func*) name##_decrypt, \ |
} |
|
/*! @class CipherInfo |
58,100 → 35,21 |
{ |
INHERIT CipherInfo; |
- CVAR nettle_crypt_func crypt; |
+ CVAR crypt_func crypt; |
+ CVAR nettle_crypt_func *crypt; |
CVAR void *ctx; |
CVAR int key_size; |
|
diff -urad Pike-v7.8.316/src/post_modules/Nettle/configure.in pike-cvs/7.8/src/post_modules/Nettle/configure.in |
--- Pike-v7.8.316/src/post_modules/Nettle/configure.in 2008-07-17 12:53:20.000000000 +0200 |
+++ pike-cvs/7.8/src/post_modules/Nettle/configure.in 2009-07-02 23:27:56.000000000 +0200 |
@@ -54,6 +54,52 @@ |
AC_MSG_RESULT([no]) |
IDEA_OBJ="" |
fi |
+ |
+ # These might have been purged from the Nettle lib to avoid GPL |
+ # contamination. |
+ AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) |
+ |
+ # This is the recomended interface in Nettle 2.0. |
+ AC_CHECK_FUNCS(nettle_yarrow256_slow_reseed) |
+ |
+ AC_MSG_CHECKING([for struct yarrow256_ctx.seed_file]) |
+ AC_CACHE_VAL(pike_cv_nettle_struct_yarrow256_ctx_seed_file, [ |
+ pike_cv_nettle_struct_yarrow256_ctx_seed_file=no |
+ AC_TRY_COMPILE([ |
+#include <nettle/yarrow.h> |
+ ], [ |
+ struct yarrow256_ctx ctx; |
+ return !sizeof(ctx.seed_file); |
+ ], [ |
+ pike_cv_nettle_struct_yarrow256_ctx_seed_file=yes |
+ ]) |
+ ]) |
+ AC_MSG_RESULT($pike_cv_nettle_struct_yarrow256_ctx_seed_file); |
+ if test "x$pike_cv_nettle_struct_yarrow256_ctx_seed_file" = "xyes"; then |
+ AC_DEFINE(HAVE_STRUCT_YARROW256_CTX_SEED_FILE) |
+ fi |
+ |
+ AC_MSG_CHECKING([whether nettle_crypt_func is a pointer type]) |
+ AC_CACHE_VAL(pike_cv_nettle_crypt_func_is_pointer, [ |
+ pike_cv_nettle_crypt_func_is_pointer=no |
+ AC_TRY_COMPILE([ |
+/* Note: Old Nettles had the nettle_crypt_func typedef directly |
+ * in <nettle/nettle-meta.h> while more modern have it in |
+ * <nettle/nettle-types.h>. Since <nettle/nettle-meta.h> |
+ * pulls in <nettle/nettle-types.h> it should be sufficient. |
+ */ |
+#include <nettle/nettle-meta.h> |
+ ], [ |
+ nettle_crypt_func foo = (nettle_crypt_func)(void *)0; |
+ return (int)foo; |
+ ], [ |
+ pike_cv_nettle_crypt_func_is_pointer=yes |
+ ]) |
+ ]) |
+ AC_MSG_RESULT($pike_cv_nettle_crypt_func_is_pointer); |
+ if test "x$pike_cv_nettle_crypt_func_is_pointer" = "xyes"; then |
+ AC_DEFINE(HAVE_NETTLE_CRYPT_FUNC_IS_POINTER) |
+ fi |
else |
if test "$ac_cv_lib_gmp_mpz_init:$ac_cv_lib_gmp___mpz_init:$ac_cv_lib_gmp___gmpz_init" = "no:no:no"; then |
# No gmp found; enable it if possible. |
@@ -76,10 +122,6 @@ |
]) |
PIKE_FEATURE_NODEP(Nettle) |
fi |
- |
- # These might have been purged from the Nettle lib to avoid GPL |
- # contamination. |
- AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) |
fi |
|
AC_OUTPUT(Makefile,echo FOO >stamp-h ) |
diff -urad Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod |
--- Pike-v7.8.316/src/post_modules/Nettle/nettle.cmod 2008-06-29 00:57:14.000000000 +0200 |
+++ pike-cvs/7.8/src/post_modules/Nettle/nettle.cmod 2009-07-05 21:41:58.000000000 +0200 |
@@ -46,6 +46,36 @@ |
@@ -46,6 +46,21 @@ |
CVAR struct yarrow256_ctx ctx; |
CVAR struct yarrow_source *sources; |
|
+#ifndef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
+ /* NOTE: Nettle 2.0 does not have the automatic seed_file maintenance |
+ * that Nettle 1.x had. This stuff is needed since it affected |
+ * the state emitted by random_string(). When Nettle 2.0 is the |
+ * default, consider implementing this via overloading of the |
+ * various seeding functions instead, since it does have a bit |
+ * of overhead. |
+ * |
+ * /grubba 2009-07-05 |
+ */ |
+ PIKEVAR string seed_file flags ID_PRIVATE|ID_STATIC; |
+#endif |
+ |
+ DECLARE_STORAGE; |
+ |
+#ifndef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
+ static void pike_generate_seed_file(void) |
+ { |
+ struct pike_string *seed_file = |
162,9 → 60,6 |
+ } |
+ THIS->seed_file = end_shared_string(seed_file); |
+ } |
+#else |
+#define pike_generate_seed_file() |
+#endif |
+ |
/*! @decl void create(void|int sources) |
*! The number of entropy sources that will feed entropy to the |
184,7 → 79,7 |
RETURN this_object(); |
} |
|
@@ -109,19 +141,31 @@ |
@@ -109,19 +141,26 @@ |
RETURN YARROW256_SEED_FILE_SIZE; |
} |
|
208,10 → 103,6 |
- RETURN make_shared_binary_string((const char *)THIS->ctx.seed_file, |
- YARROW256_SEED_FILE_SIZE); |
+ |
+#ifdef HAVE_STRUCT_YARROW256_CTX_SEED_FILE |
+ RETURN make_shared_binary_string(THIS->ctx.seed_file, |
+ YARROW256_SEED_FILE_SIZE); |
+#else |
+ if (THIS->seed_file) { |
+ REF_RETURN THIS->seed_file; |
+ } else { |
218,26 → 109,15 |
+ struct pike_string *s = begin_shared_string(YARROW256_SEED_FILE_SIZE); |
+ RETURN end_shared_string(s); |
+ } |
+#endif /* HAVE_STRUCT_YARROW256_CTX_SEED_FILE */ |
} |
|
/*! @decl int(0..1) is_seeded() |
@@ -144,7 +188,19 @@ |
@@ -144,7 +188,8 @@ |
PIKEFUN void force_reseed() |
optflags OPT_SIDE_EFFECT; |
{ |
+#ifdef HAVE_NETTLE_YARROW256_SLOW_RESEED |
+ /* From change notes for Nettle 2.0: |
+ * |
+ * * Changes to the yarrow256 interface. The function |
+ * yarrow256_force_reseed has been replaced by the two |
+ * functions yarrow256_fast_reseed and yarrow256_slow_reseed, |
+ * which were previously static. |
+ */ |
- yarrow256_force_reseed(&THIS->ctx); |
+ yarrow256_slow_reseed(&THIS->ctx); |
+#else |
yarrow256_force_reseed(&THIS->ctx); |
+#endif |
+ pike_generate_seed_file(); |
} |
|