Main Menu
Who's Online
2 utilisateur(s) en ligne (dont 2 sur SAPHIR-Downloads)

Membre(s): 0
Invité(s): 2

WFDownloads is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)
SAPHIR-Downloads > Projet RNRT SAPHIR-Livrables > L4.2 Implémentation de fonctions de hachage (sphlib 1.0)


L4.2 Implémentation de fonctions de hachage (sphlib 1.0)

Description : 

sphlib 1.0


Sphlib is a set of implementations of various hash functions, both in C
and in Java. The C code is meant to be easily imported into other
projects, in particular embedded systems. The Java code implements
an API somewhat similar to that of java.security.MessageDigest.

The C source code provides also two standalone tools:
- sphspeed performs speed tests on various hash functions
- sphsum computes and verifies checksums over files


Licensing is specified in the LICENSE.txt file. This is an MIT-like,
BSD-like open-source license. Basically, we will get the fame but not
the blame. If you reuse our code in your own projects, and distribute
the result, then you should state that you used our code and that we
always disclaimed any kind of warranty, and will continue to do so in
the foreseeable future, and beyond. You have no other obligation such as
disclosing your own source code. See the LICENSE.txt file for the
details in a lawyer-compatible language.

The authors are the "Projet RNRT SAPHIR", which is a research project
sponsored by the French government; project members are public and
private organizations:
- Cryptolog
- Ecole Normale Superieure
- France Telecom
- Gemalto

Most of the actual code has been written by:

Thomas Pornin <thomas.pornin@cryptolog.com>

to whom technical questions may be addressed. Note that I do not claim
authorship: all writing was done on behalf of the Projet RNRT SAPHIR.


The programming interface for both the C code and the Java code can be found in the doc/ subdirectory. This documentation is in HTML format and was generated from the comments in the source code with, respectively, doxygen and javadoc.

Installation (C code)

The c/ subdirectory contain the C code. In that directory, there are two
Makefiles and a build shell script. The shell script, named "build.sh",
is for Unix-like systems.

sphlib does not feature a "proper" compilation and configuration systems such as those customarily found in open-source libraries for Unix systems. This should be corrected in a future version. Right now, I am not utterly convinced that the autoconf-generated scripts are the "way to go". Anyway, sphlib is meant for evaluation, research and import into other projects; a streamlined standalone compilation process is hardly relevant for those usages.

Unix systems

If you happen to have a Unix-like system (e.g. Linux), you may simply


which should:

- compile the library
- compile the tools
- compile the unit tests
- run the unit tests

The library and tools may be installed with:

c/build.sh -i

which will install sphspeed and sphsum in /usr/local/bin, libsph.a in
/usr/local/lib, and the header files (all the sph_*.h files) in

The installation directories and the compilation options can be altered
at will with appropriate options. Use:

c/build.sh --help

to access the list of options.

"build.sh" is only for Unix-like systems such as Linux. This script has
not been thoroughly tested, is very crude, and has only very limited
autodetection capabilities. If you are after getting the maximum hashing
speed, or if you want to use the library from a shared object, you will
probably have to specify other compile options. Use "--with-cflags" to
change the compilation options. For instance:

c/build.sh --with-cflags="-W -Wall -O2 -fPIC -mtune=athlon64"

This selects options for position-independant code, i.e. suitable for
a shared object, and tuned for maximum performance on Ahtlon64-type

"build.sh" is not mandatory; you may edit and use the Makefile.unix file

The "sphsum" binary can be used to hash files in a way similar to what
the "md5sum" Linux tool does. The first argument of sphsum must be the
name of a hash function; matching is not case sensitive. Recognized
names are:

name function
haval128_3 HAVAL, 128-bit output, 3 passes
haval128_4 HAVAL, 128-bit output, 4 passes
haval128_5 HAVAL, 128-bit output, 5 passes
haval160_3 HAVAL, 160-bit output, 3 passes
haval160_4 HAVAL, 160-bit output, 4 passes
haval160_5 HAVAL, 160-bit output, 5 passes
haval192_3 HAVAL, 192-bit output, 3 passes
haval192_4 HAVAL, 192-bit output, 4 passes
haval192_5 HAVAL, 192-bit output, 5 passes
haval224_3 HAVAL, 224-bit output, 3 passes
haval224_4 HAVAL, 224-bit output, 4 passes
haval224_5 HAVAL, 224-bit output, 5 passes
haval256_3 HAVAL, 256-bit output, 3 passes
haval256_4 HAVAL, 256-bit output, 4 passes
haval256_5 HAVAL, 256-bit output, 5 passes
md2 MD2
md4 MD4
md5 MD5
panama Panama
ripemd RIPEMD (original function)
ripemd128 RIPEMD-128 (revised function, 128-bit output)
ripemd160 RIPEMD-160 (revised function, 160-bit output)
rmd RIPEMD (original function)
rmd128 RIPEMD-128 (revised function, 128-bit output)
rmd160 RIPEMD-160 (revised function, 160-bit output)
sha0 SHA-0 (original SHA, withdrawn)
sha1 SHA-1
sha224 SHA-224
sha256 SHA-256
sha384 SHA-384
sha512 SHA-512
tiger Tiger
tiger2 Tiger2 (Tiger with a modified padding)
whirlpool Whirlpool (2003, current version)
whirlpool0 Whirlpool-0 (2000)
whirlpool1 Whirlpool-1 (2001)

Alternatively, the "sphsum" executable file can be named after one of
these functions, in which case the function name needs not be specified.
Hence, if you install "sphsum" and create a link (either symbolic or
not) to "sphsum" named "md5sum", then you may use that link as a drop-in
replacement for the standard Linux tool "md5sum". This function name
recognition process ignores the ".exe", "sum" and "sum.exe" suffixes.


On Windows systems, you may use the Makefile.win32 file. This is meant
for Visual C (command-line compiler). Open a "Visual C console" from the
start menu (this is a standard text console with the environment set up
for using cl.exe). Type:

nmake /f makefile.win32

which should compile the code, the unit tests and the standalone
binaries. There is no library per se, only a collection of object files.

Other C compilers exist for Windows (e.g. MinGW or the cygwin system).

Other systems

If you wish to include sphlib C code in your own projects, then you must
copy the following files:
- all the sph_*.h header files
- the following C files:
The other source code files are for the standalone tools, and the unit

Most of the "magic" happens in sph_types.h. This is where one may find
such things as inline assembly for faster little/big-endian word access.

Installation (Java code)

Java code is in the java/ directory. Hash function implementations are
located in the "fr.cryptohash" package; there is one specific class for
each hash function, a common interface called "Digest", and some
non-public helper classes.

The "fr.cryptohash.test" package contains two standalone applications
(classes with a main() method). The "TestDigest" application runs the
unit tests. The "Speed" application runs speed tests, with an output
similar to that provided by the "sphspeed" tool from the C code. Note
that these tests cannot access the CPU usage by the test process; hence,
speed tests should be performed on an otherwise idle machine.

The Java code should be compatible both with older virtual machine
(e.g. Java 1.1) and with J2ME platforms.

Future work

Future versions of sphlib will feature:
- other hash functions
- options for better conditional inclusion (e.g. not compiling RIPEMD if
you only want RIPEMD-160)
- optimized versions for footprint-constrained environments (which should
also help platforms with a small L1 cache)
- a better compilation and installation procedure for the library and
standalone tools
- man pages for the standalone tools
- a building process for sphlib as a shared library

Proposé par: admin
Editeur: SAPHIR
Proposé le : Fri, 09-Mar-2007

Version: 1.0
Téléchargé(s) : 887
Taille du Fichier (en Octets): 667.31 KB

Note :   (0 votes)

Révisions :  (0)

Miroirs disponibles: 0

Temps de téléchargements :
Modem(56k) : 1.8min
ISDN(64k) : 1.6min
DSL(768k) : 8s
LAN(10M) : 0.61s
Prix: Libre | Plateformes Supportées: None | License: None | Restrictions: None

Projet RNRT SAPHIR Révisions d'utilisateur

Autres fichiers de : admin

L4.2 Implémentation de fonctions de hachage (sphlib 1.0) © copyright 2017 http://www.crypto-hash.fr

Les commentaires appartiennent à leurs auteurs. Nous ne sommes pas responsables de leur contenu.
Fichiers récents