Skip to content
Snippets Groups Projects
Select Git revision
  • 9c6f7d6bc06a399f9f3d7b5c3b90c1abfdb43c22
  • master default protected
  • 8.0
  • 9.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
41 results

callback.c

Blame
    • Fredrik Hübinette (Hubbe)'s avatar
      9c6f7d6b
      tons of warnings fixed · 9c6f7d6b
      Fredrik Hübinette (Hubbe) authored
      Rev: src/array.c:1.8
      Rev: src/builtin_functions.c:1.35
      Rev: src/callback.c:1.8
      Rev: src/configure.in:1.84
      Rev: src/constants.c:1.10
      Rev: src/encode.c:1.9
      Rev: src/fd_control.c:1.6
      Rev: src/gc.c:1.8
      Rev: src/interpret.c:1.42
      Rev: src/las.c:1.31
      Rev: src/lex.c:1.21
      Rev: src/main.c:1.21
      Rev: src/mapping.c:1.17
      Rev: src/memory.h:1.3
      Rev: src/module_support.c:1.7
      Rev: src/modules/Gmp/mpz_glue.c:1.11
      Rev: src/modules/Image/font.c:1.7
      Rev: src/modules/Pipe/pipe.c:1.6
      Rev: src/modules/Regexp/glue.c:1.5
      Rev: src/modules/Yp/yp.c:1.6
      Rev: src/modules/_Crypto/Makefile.in:1.9
      Rev: src/modules/_Crypto/lib/Makefile.in:1.5
      Rev: src/modules/dynamic_module_makefile.in:1.7
      Rev: src/modules/files/efuns.c:1.22
      Rev: src/modules/files/file.c:1.36
      Rev: src/modules/math/math.c:1.4
      Rev: src/modules/spider/accesseddb.c:1.7
      Rev: src/modules/spider/discdate.c:1.4
      Rev: src/modules/spider/dumudp.c:1.8
      Rev: src/modules/spider/spider.c:1.29
      Rev: src/modules/spider/streamed_parser.c:1.5
      Rev: src/modules/sprintf/sprintf.c:1.10
      Rev: src/modules/static_module_makefile.in:1.5
      Rev: src/modules/system/passwords.c:1.2
      Rev: src/modules/system/syslog.c:1.3
      Rev: src/modules/system/system.c:1.16
      Rev: src/object.c:1.17
      Rev: src/opcodes.c:1.6
      Rev: src/operators.c:1.13
      Rev: src/peep.c:1.10
      Rev: src/pike_types.c:1.21
      Rev: src/port.c:1.11
      Rev: src/port.h:1.16
      Rev: src/program.c:1.33
      Rev: src/signal_handler.c:1.11
      Rev: src/stralloc.c:1.14
      Rev: src/stuff.c:1.2
      Rev: src/svalue.c:1.9
      Rev: src/threads.c:1.21
      9c6f7d6b
      History
      tons of warnings fixed
      Fredrik Hübinette (Hubbe) authored
      Rev: src/array.c:1.8
      Rev: src/builtin_functions.c:1.35
      Rev: src/callback.c:1.8
      Rev: src/configure.in:1.84
      Rev: src/constants.c:1.10
      Rev: src/encode.c:1.9
      Rev: src/fd_control.c:1.6
      Rev: src/gc.c:1.8
      Rev: src/interpret.c:1.42
      Rev: src/las.c:1.31
      Rev: src/lex.c:1.21
      Rev: src/main.c:1.21
      Rev: src/mapping.c:1.17
      Rev: src/memory.h:1.3
      Rev: src/module_support.c:1.7
      Rev: src/modules/Gmp/mpz_glue.c:1.11
      Rev: src/modules/Image/font.c:1.7
      Rev: src/modules/Pipe/pipe.c:1.6
      Rev: src/modules/Regexp/glue.c:1.5
      Rev: src/modules/Yp/yp.c:1.6
      Rev: src/modules/_Crypto/Makefile.in:1.9
      Rev: src/modules/_Crypto/lib/Makefile.in:1.5
      Rev: src/modules/dynamic_module_makefile.in:1.7
      Rev: src/modules/files/efuns.c:1.22
      Rev: src/modules/files/file.c:1.36
      Rev: src/modules/math/math.c:1.4
      Rev: src/modules/spider/accesseddb.c:1.7
      Rev: src/modules/spider/discdate.c:1.4
      Rev: src/modules/spider/dumudp.c:1.8
      Rev: src/modules/spider/spider.c:1.29
      Rev: src/modules/spider/streamed_parser.c:1.5
      Rev: src/modules/sprintf/sprintf.c:1.10
      Rev: src/modules/static_module_makefile.in:1.5
      Rev: src/modules/system/passwords.c:1.2
      Rev: src/modules/system/syslog.c:1.3
      Rev: src/modules/system/system.c:1.16
      Rev: src/object.c:1.17
      Rev: src/opcodes.c:1.6
      Rev: src/operators.c:1.13
      Rev: src/peep.c:1.10
      Rev: src/pike_types.c:1.21
      Rev: src/port.c:1.11
      Rev: src/port.h:1.16
      Rev: src/program.c:1.33
      Rev: src/signal_handler.c:1.11
      Rev: src/stralloc.c:1.14
      Rev: src/stuff.c:1.2
      Rev: src/svalue.c:1.9
      Rev: src/threads.c:1.21
    arcfour.c 2.18 KiB
    /* arcfour.c
     *
     * The arcfour/rc4 stream cipher.
     */
    
    /* nettle, low-level cryptographics library
     *
     * Copyright (C) 2001 Niels Mller
     *  
     * The nettle library is free software; you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License as published by
     * the Free Software Foundation; either version 2.1 of the License, or (at your
     * option) any later version.
     * 
     * The nettle library is distributed in the hope that it will be useful, but
     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
     * License for more details.
     * 
     * You should have received a copy of the GNU Lesser General Public License
     * along with the nettle library; see the file COPYING.LIB.  If not, write to
     * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
     * MA 02111-1307, USA.
     */
    
    #include "arcfour.h"
    
    #include <assert.h>
    
    #define SWAP(a,b) do { int _t = a; a = b; b = _t; } while(0)
    
    void
    arcfour_set_key(struct arcfour_ctx *ctx,
    		unsigned length, const uint8_t *key)
    {
      unsigned i, j, k;
      
      assert(length >= ARCFOUR_MIN_KEY_SIZE);
      assert(length <= ARCFOUR_MAX_KEY_SIZE);
    
      /* Initialize context */
      for (i = 0; i<256; i++)
        ctx->S[i] = i;
    
      for (i = j = k = 0; i<256; i++)
        {
          j += ctx->S[i] + key[k]; j &= 0xff;
          SWAP(ctx->S[i], ctx->S[j]);
          /* Repeat key as needed */
          k = (k + 1) % length;
        }
      ctx->i = ctx->j = 0;
    }
    
    
    void
    arcfour_crypt(struct arcfour_ctx *ctx,
    	      unsigned length, uint8_t *dst,
    	      const uint8_t *src)
    {
      register uint8_t i, j;
    
      i = ctx->i; j = ctx->j;
      while(length--)
        {
          i++; i &= 0xff;
          j += ctx->S[i]; j &= 0xff;
          SWAP(ctx->S[i], ctx->S[j]);
          *dst++ = *src++ ^ ctx->S[ (ctx->S[i] + ctx->S[j]) & 0xff ];
        }
      ctx->i = i; ctx->j = j;
    }
    
    void
    arcfour_stream(struct arcfour_ctx *ctx,
    	       unsigned length, uint8_t *dst)
    {
      register uint8_t i, j;
    
      i = ctx->i; j = ctx->j;
      while(length--)
        {
          i++; i &= 0xff;
          j += ctx->S[i]; j &= 0xff;
          SWAP(ctx->S[i], ctx->S[j]);
          *dst++ = ctx->S[ (ctx->S[i] + ctx->S[j]) & 0xff ];
        }
      ctx->i = i; ctx->j = j;
    }