siphash /

Filename Size Date modified Message
tests
1.4 KB
9 B
2.3 KB
660 B
159 B
147 B
3.7 KB
363 B

siphash

A Scheme implementation of the SipHash family of hash functions.

Description

SipHash is a cryptographically strong family of hash functions designed by Jean-Philippe Aumasson and Daniel J. Bernstein.

This library provides an implementation of these functions for CHICKEN Scheme.

Installation

When installing for CHICKEN Scheme, the numbers extension is required.

$ git clone git://bitbucket.org/evhan/siphash.git
$ cd siphash
$ chicken-install -test

Usage

Three functions are provided:

  • make-siphash
  • siphash-2-4
  • siphash-4-8

make-siphash constructs a hashing function.

It takes two positive integer arguments c and d and returns a hashing procedure of that number of compression and finalization rounds, respectively.

(make-siphash c d) => (procedure key) => (procedure message) => integer

siphash-2-4 and siphash-4-8 are predefined hashing procedures.

Each takes one or two arguments, the key and message to hash, and returns a positive integer. key and message may be strings or bytevectors, and key should have a length of 16 while message may be any length. If message isn't given, a prekeyed hashing function is returned.

The SipHash specification recommends SipHash-2-4 for performance and SipHash-4-8 for cryptographic security.

(siphash-2-4 key) => (procedure message) => integer
(siphash-2-4 key message) => integer
(siphash-4-8 key) => (procedure message) => integer
(siphash-4-8 key message) => integer

Examples

> (define key (bytevector 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
> (define msg (string->utf8 "The rain in Spain falls mainly on the plain."))

> (siphash-2-4 key msg)
; => 8751579407287093977

> ((siphash-4-8 key) msg)
; => 13472556437817646137

> ((make-siphash 8 16)
   key
   (string->utf8
    "In Hertford, Hereford and Hampshire, hurricanes hardly ever happen."))
; => 9275736844991428064

Author

Evan Hanson evhan@foldling.org

License

Copyright (c) 2013, Evan Hanson under a BSD-style license.

See LICENSE for full license information.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.