pike.git / src / post_modules / Nettle / nettle.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/nettle.cmod: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"   #include "svalue.h"   /* For this_object() */   #include "object.h"   #include "operators.h"   #include "module_support.h"   #include "threads.h"   
pike.git/src/post_modules/Nettle/nettle.cmod:103:    *! needs to properly seed the random number generator.    *! @seealso    *! @[seed]    */    PIKEFUN int(0..) min_seed_size()    optflags OPT_TRY_OPTIMIZE;    {    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;    {    struct pike_string *res;       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    *! to generator output. 0 otherwise.    *! @seealso    *! @[seed]    */    PIKEFUN int(0..1) is_seeded()    optflags OPT_EXTERNAL_DEPEND;    {