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

version» Context lines:

pike.git/src/post_modules/Nettle/hash.cmod:1:   /* hash.cmod -*- c -*- */      #include "global.h" - RCSID("$Id: hash.cmod,v 1.11 2003/08/01 20:23:05 nilsson Exp $"); + RCSID("$Id: hash.cmod,v 1.12 2003/08/05 18:15:41 nilsson Exp $");   #include "interpret.h"   #include "svalue.h"      /* For this_object() */   #include "object.h"   #include "module_support.h"      #include "nettle_config.h"      #ifdef HAVE_LIBNETTLE
pike.git/src/post_modules/Nettle/hash.cmod:51:   {    CVAR const struct nettle_hash *meta;       /*! @decl string name(void)    *!    *! Returns a human readable name for the algorithm.    */    PIKEFUN string name()    {    if (!THIS->meta) -  Pike_error("HashInfo not properly initialized."); +  Pike_error("HashInfo not properly initialized.\n");       push_string(make_shared_string(THIS->meta->name));    }       /*! @decl string digest_size(void)    *!    *! Returns the size of a hash digests.    */    PIKEFUN int digest_size()    {    if (!THIS->meta) -  Pike_error("HashInfo not properly initialized."); +  Pike_error("HashInfo not properly initialized.\n");       push_int(THIS->meta->digest_size);    }       /*! @decl string block_size(void)    *! -  *! REturns the internal block size of the hash algorithm. +  *! Returns the internal block size of the hash algorithm.    */    PIKEFUN int block_size()    {    if (!THIS->meta) -  Pike_error("HashInfo not properly initialized."); +  Pike_error("HashInfo not properly initialized.\n");       push_int(THIS->meta->block_size);    }    INIT    {    werror("HashInfo->INIT\n");    THIS->meta = NULL;    }   }   
pike.git/src/post_modules/Nettle/hash.cmod:116:    /*! @decl HashState update(string data)    *!    *! Hashes more data.    */    PIKEFUN object update(string data)    {    const struct nettle_hash *meta =    GET_META(Pike_fp->current_object);       if (!THIS->ctx || !meta) -  Pike_error("hash_state not properly initialized."); +  Pike_error("HashState not properly initialized.\n");       NO_WIDE_STRING(data);    meta->update(THIS->ctx, data->len, data->str);       push_object(this_object());    }       /*! @decl string digest(int|void length)    *!    *! Generates a digests, and resets the hashing contents.
pike.git/src/post_modules/Nettle/hash.cmod:142:    *! @returns    *! The digest.    */    PIKEFUN string digest(int|void arg)    {    const struct nettle_hash *meta;    struct pike_string *digest;    unsigned length;       if (! THIS->ctx) -  Pike_error("hash_state not properly initialized."); +  Pike_error("HashState not properly initialized.\n");       meta = GET_META(Pike_fp->current_object);    assert(meta);       if (!arg)    length = meta->digest_size;    else    {    if (arg->type != PIKE_T_INT) -  Pike_error("Bad argument type"); -  if (arg->u.integer <= 0) -  Pike_error("Invalid argument, must be positive.\n"); +  Pike_error("Bad argument type.\n"); +  if (arg->u.integer < 0) +  Pike_error("Invalid length, must be positive.\n");    if (arg->u.integer > meta->digest_size) -  Pike_error("Unsupported digest length"); +  Pike_error("Unsupported digest length.\n");       length = arg->u.integer;    }       digest = begin_shared_string(length);    meta->digest(THIS->ctx, length, digest->str);    push_string(end_shared_string(digest));    }       INIT