Branch: Tag:

2014-12-04

2014-12-04 19:23:25 by Martin Nilsson <nilsson@opera.com>

Stronger types, and various other type fixes.

62:   {    CVAR const struct nettle_hash *meta;    -  /*! @decl string name(void) +  /*! @decl string(0..255) name(void)    *!    *! Returns a human readable name for the algorithm.    */ -  PIKEFUN string name() +  PIKEFUN string(0..255) name()    optflags OPT_TRY_OPTIMIZE;    {    if (!THIS->meta)
75:    push_text(THIS->meta->name);    }    -  /*! @decl string digest_size(void) +  /*! @decl int(0..) digest_size(void)    *!    *! Returns the size of a hash digests.    */ -  PIKEFUN int digest_size() +  PIKEFUN int(0..) digest_size()    optflags OPT_TRY_OPTIMIZE;    {    if (!THIS->meta)
88:    push_int(THIS->meta->digest_size);    }    -  /*! @decl string block_size(void) +  /*! @decl int(0..) block_size(void)    *!    *! Returns the internal block size of the hash algorithm.    */ -  PIKEFUN int block_size() +  PIKEFUN int(0..) block_size()    optflags OPT_TRY_OPTIMIZE;    {    if (!THIS->meta)
102:    }       -  /*! @decl string hash(string data) +  /*! @decl string(0..255) hash(string data)    *!    *! Works as a (faster) shortcut for    *! @expr{HashState()->update(data)->digest()@}, where HashState is
111:    *! @seealso    *! @[HashState()->update()] and @[HashState()->digest()].    */ -  PIKEFUN string hash(string in) +  PIKEFUN string(0..255) hash(string in)    optflags OPT_TRY_OPTIMIZE;    {    void *ctx;
146:    push_string(end_shared_string(out));    }    -  /*! @decl string hash(Stdio.File file, void|int bytes) +  /*! @decl string(0..255) hash(Stdio.File file, void|int bytes)    *!    *! Works as a (faster) shortcut for    *! @expr{HashState()->update(Stdio.read_file(file))->digest()@},
162:    *! @[Stdio.File], @[HashState()->update()] and    *! @[HashState()->digest()].    */ -  PIKEFUN string hash(object in, void|int bytes) +  PIKEFUN string(0..255) hash(object in, void|int bytes)    optflags OPT_EXTERNAL_DEPEND;    {    void *ctx;
260:    }    }    -  /*! @decl string crypt_hash(string password, string salt, int rounds) +  /*! @decl string(0..255) crypt_hash(string password, string salt, rounds)    *!    *! Password hashing function in @[crypt_md5()]-style.    *!
273:    *! @seealso    *! @[crypt_md5()]    */ -  PIKEFUN string crypt_hash(string password, string salt, int rounds) +  PIKEFUN string(0..255) crypt_hash(string password, string salt, int rounds)    {    struct pike_string *res;    const struct nettle_hash *meta = THIS->meta;
282:    uint8_t *dpbuf;    uint8_t *dsbuf;    -  char *p; -  char *s; +  unsigned char *p; +  unsigned char *s;    int plen;    int slen;    int dsz = meta->digest_size;
314:    /* NB: We use these to allow the compiler to    * avoid dereferencing at every step.    */ -  p = password->str; +  p = (unsigned char*)password->str;    plen = password->len; -  s = salt->str; +  s = (unsigned char*)salt->str;    slen = salt->len;    if (slen > 16) slen = 16;    dsz = meta->digest_size;
509:    push_object(this_object());    }    -  /*! @decl string digest(int|void length) +  /*! @decl string(0..255) digest(int|void length)    *!    *! Generates a digests, and resets the hashing contents.    *!
520:    *! @returns    *! The digest.    */ -  PIKEFUN string digest(int|void arg) +  PIKEFUN string(0..255) digest(int|void arg)    {    const struct nettle_hash *meta;    struct pike_string *digest;