Skip to content
Snippets Groups Projects
Select Git revision
  • a8e38bdf161ecd67cecc30c255775ad261aaae9f
  • master default protected
  • hpke
  • ppc-chacha-4core
  • delete-internal-name-mangling
  • master-updates
  • ppc-gcm
  • ppc-chacha-2core
  • refactor-ecc-mod
  • ppc-chacha-core
  • use-mpn_cnd-functions
  • optimize-ecc-invert
  • default-m4-quote-char
  • power-asm-wip
  • test-fat
  • chacha-3core-neon
  • x86_64-salsa20-2core
  • salsa20-2core-neon
  • bcrypt
  • arm-salsa20-chacha-vsra
  • test-shlib-dir
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
41 results

der-iterator.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    • Niels Möller's avatar
      5c5e545d
      (asn1_der_iterator_init): Initialize length and · 5c5e545d
      Niels Möller authored
      data.
      (asn1_der_iterator_next): Support for lengths >= 0x80.
      (asn1_der_decode_constructed_last, asn1_der_decode_bitstring)
      (asn1_der_decode_bitstring_last): New functions.
      (asn1_der_get_bignum): Check for non-mininal encodings.
      
      Rev: src/nettle/der-iterator.c:1.2
      5c5e545d
      History
      (asn1_der_iterator_init): Initialize length and
      Niels Möller authored
      data.
      (asn1_der_iterator_next): Support for lengths >= 0x80.
      (asn1_der_decode_constructed_last, asn1_der_decode_bitstring)
      (asn1_der_decode_bitstring_last): New functions.
      (asn1_der_get_bignum): Check for non-mininal encodings.
      
      Rev: src/nettle/der-iterator.c:1.2
    Array.pmod 2.70 KiB
    #define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) )
    
    mixed map(mixed arr, mixed fun, mixed ... args)
    {
      int e;
      mixed *ret;
    
      if(mappingp(arr))
        return mkmapping(indices(arr),map(values(arr),fun,@args));
    
      switch(sprintf("%t",fun))
      {
      case "int":
        return arr(@args);
    
      case "string":
        return column(arr, fun)(@args);
    
      case "function":
      case "program":
      case "object":
        ret=allocate(sizeof(arr));
        for(e=0;e<sizeof(arr);e++)
          ret[e]=fun(arr[e],@args);
        return ret;
    
      default:
        error("Bad argument 2 to map_array().\n");
      }
    }
    
    mixed filter(mixed arr, mixed fun, mixed ... args)
    {
      int e;
      mixed *ret;
    
      if(mappingp(arr))
      {
        mixed *i, *v, r;
        i=indices(arr);
        ret=map(v=values(arr),fun,@args);
        r=([]);
        for(e=0;e<sizeof(ret);e++) if(ret[e]) r[i[e]]=v[e];
    
        return ret;
      }else{
        int d;
        ret=map(arr,fun,@args);
        for(e=0;e<sizeof(arr);e++) if(ret[e]) ret[d++]=arr[e];
        
        return ret[..d-1];
      }
    }
    
    
    int search_array(mixed *arr, mixed fun, mixed ... args)
    {
      int e;
    
      if(stringp(fun))
      {
        for(e=0;e<sizeof(arr);e++)
          if(arr[e][fun](@args))
    	return e;
        return -1;
      }
      else if(functionp(fun))
      {
        for(e=0;e<sizeof(arr);e++)
          if(fun(arr[e],@args))
    	return e;
        return -1;
      }
      else if(intp(fun))
      {
        for(e=0;e<sizeof(arr);e++)
          if(arr[e](@args))
    	return e;
        return -1;
      }
      else
      {
        error("Bad argument 2 to filter().\n");
      }
    }
    
    mixed *sum_arrays(function foo, mixed * ... args)
    {
      mixed *ret;
      int e,d;
      ret=allocate(sizeof(args[0]));
      for(e=0;e<sizeof(args[0]);e++)
        ret[e]=foo(@ column(args, e));
      return ret;
    }
    
    varargs mixed *sort_array(array foo,function cmp, mixed ... args)
    {
      array bar,tmp;
      int len,start;
      int length;
      int foop, fooend, barp, barend;
    
      if(!cmp || cmp==`>)
      {
        foo+=({});
        sort(foo);
        return foo;
      }
    
      if(cmp == `<)
      {
        foo+=({});
        sort(foo);
        return reverse(foo);
      }
    
      length=sizeof(foo);
    
      foo+=({});
      bar=allocate(length);
    
      for(len=1;len<length;len*=2)
      {
        start=0;
        while(start+len < length)
        {
          foop=start;
          barp=start+len;
          fooend=barp;
          barend=barp+len;
          if(barend > length) barend=length;
          
          while(1)
          {
    	if(cmp(foo[foop],foo[barp],@args) <= 0)
    	{
    	  bar[start++]=foo[foop++];
    	  if(foop == fooend)
    	  {
    	    while(barp < barend) bar[start++]=foo[barp++];
    	    break;
    	  }
    	}else{
    	  bar[start++]=foo[barp++];
    	  if(barp == barend)
    	  {
    	    while(foop < fooend) bar[start++]=foo[foop++];
    	    break;
    	  }
    	}
          }
        }
        while(start < length) bar[start]=foo[start++];
    
        tmp=foo;
        foo=bar;
        bar=tmp;
      }
    
      return foo;
    }
    
    array uniq(array a)
    {
      return indices(mkmapping(a,a));
    }