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.40 2005/01/27 19:15:01 nilsson Exp $ */ + /* $Id: nettle.cmod,v 1.41 2006/01/07 02:04:53 nilsson 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:86:    *! @seealso    *! @[min_seed_size], @[get_seed], @[is_seeded]    */    PIKEFUN object seed(string data)    optflags OPT_SIDE_EFFECT;    {    if(data->len < YARROW256_SEED_FILE_SIZE)    Pike_error( "Seed must be at least 32 characters.\n" );       NO_WIDE_STRING(data); -  yarrow256_seed(&THIS->ctx, data->len, data->str); +  yarrow256_seed(&THIS->ctx, data->len, (const uint8_t *)data->str);    RETURN this_object();    }       /*! @decl int(0..) min_seed_size()    *! Returns the minimal number of characters that the @[seed]    *! needs to properly seed the random number generator.    *! @seealso    *! @[seed]    */    PIKEFUN int(0..) min_seed_size()
pike.git/src/post_modules/Nettle/nettle.cmod:113:    *! Returns part of the internal state so that it can    *! be saved for later seeding.    *! @seealso    *! @[seed]    */    PIKEFUN string get_seed()    optflags OPT_EXTERNAL_DEPEND;    {    if( !yarrow256_is_seeded(&THIS->ctx) )    Pike_error("Random generator not seeded.\n"); -  RETURN make_shared_binary_string(THIS->ctx.seed_file, +  RETURN make_shared_binary_string((const char *)THIS->ctx.seed_file,    YARROW256_SEED_FILE_SIZE);    }       /*! @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()
pike.git/src/post_modules/Nettle/nettle.cmod:159:    /* FIXME: Wide strings could actually be supported here */    NO_WIDE_STRING(data);    if( !THIS->sources )    Pike_error("This random generator has no sources.\n");    if( source<0 || (unsigned)source>=THIS->ctx.nsources )    Pike_error("Invalid random source.\n");    if( entropy<0 )    Pike_error("Entropy must be positive.\n");    if( entropy>(data->len*8) )    Pike_error("Impossibly large entropy value.\n"); -  RETURN yarrow256_update(&THIS->ctx, source, entropy, data->len, data->str); +  RETURN yarrow256_update(&THIS->ctx, source, entropy, data->len, +  (const uint8_t *)data->str);    }       /*! @decl int(0..) needed_sources()    *! The number of sources that must reach the threshold before a    *! slow reseed will happen.    */    PIKEFUN int(0..) needed_sources()    optflags OPT_EXTERNAL_DEPEND;    {    RETURN yarrow256_needed_sources(&THIS->ctx);
pike.git/src/post_modules/Nettle/nettle.cmod:184:    */    PIKEFUN string random_string(int length)    optflags OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT;    {    struct pike_string *rnd;    if(length < 0)    Pike_error("Invalid length, must be positive.\n");    if( !yarrow256_is_seeded(&THIS->ctx) )    Pike_error("Random generator not seeded.\n");    rnd = begin_shared_string(length); -  yarrow256_random(&THIS->ctx, length, rnd->str); +  yarrow256_random(&THIS->ctx, length, (uint8_t *)rnd->str);    RETURN end_shared_string(rnd);    }       INIT    {    THIS->sources = NULL;    yarrow256_init(&THIS->ctx, 0, NULL);    }    EXIT    {