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.37 2005/12/11 18:01:46 nilsson Exp $ */      #include "global.h" - RCSID("$Id: nettle.cmod,v 1.36 2004/03/24 00:08:30 nilsson Exp $"); +    #include "interpret.h"   #include "svalue.h"   /* For this_object() */   #include "object.h"   #include "operators.h"   #include "module_support.h"   #include "threads.h"      #include "nettle_config.h"   
pike.git/src/post_modules/Nettle/nettle.cmod:228:      static const char *crypto_functions[] = {    "block_size",    "key_size",    "set_encrypt_key",    "set_decrypt_key",    "crypt",    0   };    - static const char * assert_is_crypto_object(struct program *p, -  const char **required) { + static const char *assert_is_crypto_object(struct program *p, +  const char *const *required) {    while (*required) {    if (find_identifier( (char *) *required, p) < 0)    return *required;    required++;    }    return 0;   }      static struct object *make_cipher_object(INT32 args) {    ptrdiff_t fun;
pike.git/src/post_modules/Nettle/nettle.cmod:322:    EXIT    {    if(THIS->object) free_object(THIS->object);    if(THIS->iv) {    MEMSET(THIS->iv, 0, THIS->block_size);    free(THIS->iv);    }    THIS->iv = 0;    }    -  INLINE static void cbc_encrypt_step(const unsigned INT8 *source, +  INLINE static void cbc_encrypt_step(const unsigned INT8 *const source,    unsigned INT8 *dest)    {    INT32 block_size = THIS->block_size;    INT32 i;       for(i=0; i < block_size; i++)    THIS->iv[i] ^= source[i];       push_string(make_shared_binary_string((INT8 *)THIS->iv, block_size));    safe_apply(THIS->object, "crypt", 1);
pike.git/src/post_modules/Nettle/nettle.cmod:346:       if(Pike_sp[-1].u.string->len != block_size) {    Pike_error("Bad string length %ld returned from crypt()\n",    DO_NOT_WARN((long)Pike_sp[-1].u.string->len));    }    MEMCPY(THIS->iv, Pike_sp[-1].u.string->str, block_size);    MEMCPY(dest, Pike_sp[-1].u.string->str, block_size);    pop_stack();    }    -  INLINE static void cbc_decrypt_step(const unsigned INT8 *source, +  INLINE static void cbc_decrypt_step(const unsigned INT8 *const source,    unsigned INT8 *dest)    {    INT32 block_size = THIS->block_size;    INT32 i;       push_string(make_shared_binary_string((const INT8 *)source, block_size));    safe_apply(THIS->object, "crypt", 1);       if(Pike_sp[-1].type != T_STRING)    Pike_error("Expected string from crypt()\n");
pike.git/src/post_modules/Nettle/nettle.cmod:490:    */    PIKEFUN string crypt(string data) {    unsigned INT8 *result;    INT32 offset = 0;       NO_WIDE_STRING(data);       if(data->len % THIS->block_size)    Pike_error("Data length not multiple of block size.\n");    if(!(result = alloca(data->len))) -  Pike_error("Out of memory.\n"); +  SIMPLE_OUT_OF_MEMORY_ERROR("crypt", data->len);       if(THIS->mode == 0) {    while (offset < data->len) {    cbc_encrypt_step((const unsigned INT8 *)data->str + offset,    result + offset);    offset += THIS->block_size;    }    }    else {    while (offset < data->len) {
pike.git/src/post_modules/Nettle/nettle.cmod:653:    *! data to en/decrypt a block, that will be done, and the result    *! returned. Any uncrypted data will be left in the buffer.    */    PIKEFUN string crypt(string data) {    unsigned char *result;    ptrdiff_t roffset = 0;    ptrdiff_t soffset = 0;    ptrdiff_t len;       if (!(result = alloca(data->len + THIS->block_size))) -  Pike_error("Out of memory\n"); +  SIMPLE_OUT_OF_MEMORY_ERROR("crypt", data->len + THIS->block_size);       if (THIS->backlog_len) {    if (data->len >= (THIS->block_size - THIS->backlog_len)) {    MEMCPY(THIS->backlog + THIS->backlog_len, data->str,    (THIS->block_size - THIS->backlog_len));    soffset += (THIS->block_size - THIS->backlog_len);    THIS->backlog_len = 0;    push_string(make_shared_binary_string((char *)THIS->backlog,    THIS->block_size));    safe_apply(THIS->object, "crypt", 1);