Branch: Tag:

2009-07-02

2009-07-02 09:18:14 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Support for Nettle 2.0 mk II.
Added check for existence of struct yarrow256_ctx.seed_file.
Nettle.get_seed() now only exists for Nettles libraries prior to 2.0.
Conditioned checks for Nettle API functions on Nettle existence to reduce config cache contamination when bundles are enabled.

Rev: src/post_modules/Nettle/acconfig.h:1.2
Rev: src/post_modules/Nettle/configure.in:1.22
Rev: src/post_modules/Nettle/nettle.cmod:1.51

1:   /* nettle.cmod -*- c -*- */ - /* $Id: nettle.cmod,v 1.50 2009/07/01 19:07:25 grubba Exp $ */ + /* $Id: nettle.cmod,v 1.51 2009/07/02 09:18:14 grubba Exp $ */      #include "global.h"   #include "interpret.h"
110:    RETURN YARROW256_SEED_FILE_SIZE;    }    + #ifdef HAVE_STRUCT_YARROW256_CTX_SEED_FILE    /*! @decl string get_seed() -  *! Returns part of the internal state so that it can -  *! be saved for later seeding. +  *! Returns part of the internal state so that it can +  *! be saved for later seeding.    *!    *! @note -  *! Note that reseeding with the returned seed doesn't -  *! guarantee that the same sequence will be generated -  *! as with the current object. +  *! Note that this function may not exist when compiled with +  *! Nettle 2.0 or later. In that case you may want to fall back +  *! to using @expr{random_string(32)@}.    *! -  *! @note -  *! May affect the sequence generated by the current object. -  *! -  *! @note -  *! The implementation was changed due to issues with Nettle 2.0 -  *! in Pike 7.8.325. It is now equvivalent to @code{random_string(32)@}. -  *! +     *! @seealso -  *! @[seed] +  *! @[seed()], @[random_string()]    */    PIKEFUN string get_seed()    optflags OPT_EXTERNAL_DEPEND;
137:    if( !yarrow256_is_seeded(&THIS->ctx) )    Pike_error("Random generator not seeded.\n");    -  /* From change notes for Nettle 2.0: -  * -  * * Changes to the yarrow256 interface. The automatic seed file -  * generation, and the seed_file member in struct -  * yarrow256_ctx, has been removed. To generate a new seed -  * file, use yarrow256_random. -  */ -  res = begin_shared_string(YARROW256_SEED_FILE_SIZE); -  yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(res)); -  RETURN end_shared_string(res); +  RETURN make_shared_binary_string(THIS->ctx.seed_file, +  YARROW256_SEED_FILE_SIZE);    } -  + #endif /* HAVE_STRUCT_YARROW256_CTX_SEED_FILE */       /*! @decl int(0..1) is_seeded()    *! Returns 1 if the random generator is seeded and ready