Commit graph

354 commits

Author SHA1 Message Date
ilammy
37d808e470 chibi.crypto: more tests for SHA-2
* Boundary cases

  Both SHA-224 and SHA-256 use 512-bit data chunks and have a special
  behavior when chunk size is near the 448-bit boundary.

* Source type support

  Basic smoke tests for accepting bytevectors and binary input ports
  as valid arguments.
2015-04-18 17:31:45 +03:00
ilammy
baff1af72d chibi.crypto: native SHA-2 implementation
The original Scheme implementation is astonishingly slow. Rewriting
SHA-2 in C yields around x10000 speed boost for premade strings and
bytevectors. For input ports this is alleviated to x100 boost.

The implementation is divided into two parts: native computational
backend and thin Scheme interface. It is tedious to properly do IO
from C, so the Scheme code handles reading data from an input port
and the C code performs actual computations on byte buffers (which
is also used to handle strings and bytevectors directly).

Scheme wrapper reads data in chunked manner with 'read-bytevector'.
Currently, the chunk size has insignificant impact on performance
as soon as it is bigger than 64. Also, using simply read-bytevector
turned out to be 33% faster than preallocating a buffer and filling
it with read-bytevector!

One tricky part is how to get exact 32-bit integers in C89. We have
no <inttypes.h> there, so instead we use <limits.h> to see whether
we have a standard type with suitable boundaries.

The other one is how to return a properly tagged sha_context from C.
Chibi FFI currently cannot handle the case when a procedure returns
either a C pointer (which needs to be boxed) or an exception (which
should be left as is). To workaround this sexp_start_sha() receives
a dummy argument of type sha_context; this makes Chibi FFI to put a
proper type tag into 'self', which is then extracted in the C code.

This commits adds a new shared library 'crypto$(SO)' with intent to
keep there all native code of (chibi crypto) libraries. This allows
to simply put any future native implementation of SHA-512 or MD5 in
some md5.c and just include those files into crypto.stub.
2015-04-18 17:31:45 +03:00
ilammy
78a57dfe83 chibi.crypto: documentation for (chibi crypto sha-2)
Clearly state what kind of arguments sha-224 and sha-256 can handle
and what they return as a result.
2015-04-18 17:31:44 +03:00
Alex Shinn
b6bbc1cae5 Enabling chicken snow installs, and adding to tests.
Smarter handling of requested vs. available impl installs.
2015-04-15 15:19:44 +09:00
Alex Shinn
4267164e92 Interleave reading/writing to subprocess in process-pipe-bytevector,
using u8-ready? to avoid blocking.  Fixes issue #253.
2015-04-15 11:24:56 +09:00
Alex Shinn
579fcf95ae Fixing kawa install rules and adding to tests. 2015-04-11 01:21:38 +09:00
Alex Shinn
d1537fec79 Fixing library rewriting and test-depends bug. 2015-04-11 01:01:07 +09:00
Alex Shinn
2af0685012 Adding cross-implementation installation tests. 2015-04-09 11:05:33 +09:00
Alex Shinn
c9a9fc0070 Noting some simple char-set utilities are public domain. 2015-04-09 01:43:17 +09:00
Alex Shinn
30453bdb32 Fixing snow tests requiring file renaming.
Adding support for test dependencies.
Allowing testing from a local repository.
Adding a snow index command.
Various bugfixes and config improvements.
2015-04-09 01:14:14 +09:00
Alex Shinn
55329e39fb Making uri-resolve work with bare local paths. 2015-04-08 23:04:48 +09:00
Alex Shinn
4e5cdedc03 Converting tests to modules instead of separate programs.
By convention, a library meant for testing exports "run-tests".
Also by convention, assume the test for (foo bar) is (foo bar-test),
keeping the test in the same directory and avoiding confusion since
(chibi test) is not a test for (chibi).
- Avoids the hack of "load"ing test, with resulting namespace complications.
- Allows keeping tests together with the libraries.
- Allows setting up test hooks before running.
- Allows implicit inference of test locations when using above conventions.
2015-04-05 23:38:51 +09:00
Alex Shinn
71dc6ef42f Flattening submodule. 2015-04-04 23:16:31 +09:00
Alex Shinn
f52a13524c Removing submodule. 2015-04-04 23:14:31 +09:00
Alex Shinn
59a4e56df5 Fixing error messages for unknown options. 2015-04-03 14:11:33 +09:00
Alex Shinn
443dd1bc3f Adding process->output+error+status. 2015-04-03 07:13:33 +09:00
Alex Shinn
3700b86470 Updating submodule. 2015-03-22 23:17:14 +09:00
Alex Shinn
d08ce6e925 regexp-search can terminate early if a match is found and all remaining possible matches start to the right of it 2015-03-22 22:45:36 +09:00
Alex Shinn
87761001aa Adding (time [<name>] <expr>) macro for easy benchmarking. 2015-03-22 22:44:38 +09:00
Alex Shinn
9dcf11056c Updating submodule. 2015-03-22 17:16:58 +09:00
Alex Shinn
ce7ab08e1e Updating submodule. 2015-03-22 16:17:53 +09:00
Alex Shinn
2576183b48 Updating submodule. 2015-03-22 16:06:08 +09:00
Alex Shinn
dba883c687 added submodule for removed chibi-snow 2015-03-17 21:53:47 +09:00
Alex Shinn
96e3c8f06f removing lib/chibi/snow dir to make it a submodule 2015-03-17 21:52:09 +09:00
Alex Shinn
3000523427 Bugfix in hash-table-copy which didn't copy hash function.
Patch from Alexei Lozovsky.
2015-03-13 07:10:41 +09:00
Alex Shinn
9b3529b0e6 Hacky C++ fixes. 2015-03-06 17:43:23 +09:00
Alex Shinn
64c148c9ce C++ fixes. 2015-03-06 17:35:06 +09:00
Alex Shinn
c16f36ceee Fixing typo in non-chibi regexp code.
The second %char-set:punctuation should have been %char-set:symbol.
2015-03-03 08:17:13 +09:00
Alex Shinn
390308fe0b Fixing SRFI 115 bug reports from Will Clinger.
Adding regexp-partition.
2015-03-02 23:47:32 +09:00
Alex Shinn
327685359c Fixing implicit package name from libraries. 2015-02-25 23:51:43 +09:00
Alex Shinn
f7be2d452e Adding missing emscripten files.
Fixes issue #247.
2015-02-25 07:43:35 +09:00
Alex Shinn
dc5e7e397d Emscripten support by default. Patch from Marc Nieper-Wi?kirchen. 2015-02-22 16:10:30 +09:00
Alex Shinn
692a231091 merge 2015-02-13 19:04:59 +09:00
Alex Shinn
1f08bd90c1 Support integer/real options with better error handling. 2015-02-13 19:03:54 +09:00
Alex Shinn
b6fb51f1f2 Adding include-shared-optionally. 2015-02-13 19:02:48 +09:00
Alex Shinn
695b845b11 for http uris with empty hosts, omit the scheme in the string repr 2015-02-11 20:27:27 +09:00
Alex Shinn
57e657a48d forgot to pass config to rewrite rules 2015-02-11 20:20:40 +09:00
Alex Shinn
7d897bbf15 request-with-uri should reparse request params 2015-02-11 20:19:49 +09:00
Alex Shinn
ed458469a7 Fixing index file handling to take the index relative to the url, not the search path. 2015-02-11 19:05:35 +09:00
Alex Shinn
6319d11291 Fixing bug in conf-get-multi. 2015-02-11 16:35:09 +09:00
Alex Shinn
64b4d7b2fe Exporting html-tag->string. 2015-02-11 14:11:54 +09:00
Alex Shinn
49cc343e15 Exporting html-escape. 2015-02-11 14:09:19 +09:00
Alex Shinn
8dc6f6c34e Exporting call-with-input-file and call-with-output-file from (chibi io). 2015-02-11 14:04:33 +09:00
Alex Shinn
8d13dad49b Adding file->string and file->bytevector. 2015-02-11 10:41:16 +09:00
Alex Shinn
5e9dea5c50 fixing bug in http server 2015-02-08 16:04:55 +09:00
Alex Shinn
e658a29e16 snow package updates 2015-02-08 16:04:29 +09:00
Alex Shinn
f54e40547d Adding an abort facility to exit the vm without any exception handling. 2015-02-05 22:09:45 +09:00
Alex Shinn
2922ed591d Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00
Alex Shinn
70cc1344ab Optimizing string-cursor-copy!. 2015-01-24 13:37:12 +09:00
Alex Shinn
f24eef289c Optimizing string-offset->index. 2015-01-24 12:46:44 +09:00