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.49 2009/07/01 17:46:43 grubba Exp $ */ + /* $Id: nettle.cmod,v 1.50 2009/07/01 19:07:25 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:106:    */    PIKEFUN int(0..) min_seed_size()    optflags OPT_TRY_OPTIMIZE;    {    RETURN YARROW256_SEED_FILE_SIZE;    }       /*! @decl string get_seed()    *! 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 +  *! 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]    */    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");    - #ifdef HAVE_NETTLE_YARROW256_RANDOM -  { +     /* 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.    */ -  struct pike_string *res = begin_shared_string(YARROW256_SEED_FILE_SIZE); +  res = begin_shared_string(YARROW256_SEED_FILE_SIZE);    yarrow256_random(&THIS->ctx, YARROW256_SEED_FILE_SIZE, STR0(res));    RETURN end_shared_string(res);    } - #else -  RETURN make_shared_binary_string((const char *)THIS->ctx.seed_file, -  YARROW256_SEED_FILE_SIZE); - #endif -  } +        /*! @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;    {