Branch: Tag:

2009-07-01

2009-07-01 19:07:25 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Changed and documented behaviour of Nettle.Yarrow()->get_seed().

Rev: lib/modules/Crypto.pmod/testsuite.in:1.42
Rev: src/post_modules/Nettle/nettle.cmod:1.50

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"
113:    /*! @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
131:    * 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