Skip to content

Commit 8be96ac

Browse files
committed
Update docs
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent d11758e commit 8be96ac

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

doc/crypt.tex

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,7 @@ \subsection{Hash Registration}
28772877

28782878
Example of using SHAKE256 with an arbitrary length output.
28792879

2880+
\begin{small}
28802881
\begin{verbatim}
28812882
#include <tomcrypt.h>
28822883
int main(void)
@@ -2901,14 +2902,76 @@ \subsection{Hash Registration}
29012902
return EXIT_SUCCESS;
29022903
}
29032904
\end{verbatim}
2905+
\end{small}
2906+
2907+
\mysection{Extended Tiger API}
2908+
2909+
The Tiger and Tiger2 hash algorithms \url{http://www.cs.technion.ac.il/~biham/Reports/Tiger/} specify the possibility to run the algorithm with
2910+
a configurable number of passes. The default and minimum is 3 passes, there is a second more or less widely used version with 4 passes,
2911+
which has been introduced by PHP. Its utilization is mostly limited to PHP, so we don't provide descriptors by default.
2912+
2913+
An example of how to use the 4-pass version of Tiger in a libtomcrypt-style way is shown below.
2914+
2915+
\index{tiger\_init\_ex()}
2916+
\begin{small}
2917+
\begin{verbatim}
2918+
#include <tomcrypt.h>
2919+
2920+
static const char *tiger_4passes_name = "tiger-4passes";
2921+
2922+
static int tiger_4passes_init(hash_state *md)
2923+
{
2924+
return tiger_init_ex(md, 4);
2925+
}
2926+
2927+
static struct ltc_hash_descriptor tiger_4passes_desc;
2928+
2929+
int main(void)
2930+
{
2931+
int err = 0;
2932+
unsigned char hash[MAXBLOCKSIZE], *p;
2933+
unsigned long hashlen = sizeof(hash);
2934+
2935+
memcpy(&tiger_4passes_desc, &tiger_desc, sizeof(tiger_4passes_desc));
2936+
tiger_4passes_desc.init = tiger_4passes_init;
2937+
/* Make sure to have a different name, ID and OID than standard Tiger */
2938+
tiger_4passes_desc.name = tiger_4passes_name;
2939+
tiger_4passes_desc.ID |= 0x80u;
2940+
memset(tiger_4passes_desc.OID, 0, sizeof(tiger_4passes_desc.OID));
2941+
tiger_4passes_desc.OIDlen = 0;
2942+
2943+
if ((err = register_hash(&tiger_4passes_desc)) == CRYPT_OK) {
2944+
err = hash_memory(find_hash(tiger_4passes_name), (unsigned char*)"abc", 3, hash, &hashlen);
2945+
}
2946+
2947+
if (err != 0) {
2948+
fprintf(stderr, "Error %s (%d)", error_to_string(err), err);
2949+
} else {
2950+
p = hash;
2951+
printf("Resulting hash: ");
2952+
while(hashlen--) {
2953+
printf("%02x", *p++);
2954+
}
2955+
printf("\n");
2956+
}
2957+
return err;
2958+
}
2959+
\end{verbatim}
2960+
\end{small}
2961+
2962+
When compiling and running this, the output should be:
2963+
2964+
\begin{verbatim}
2965+
Resulting hash: 538883c8fc5f28250299018e66bdf4fdb5ef7b65f2e91753
2966+
\end{verbatim}
29042967

29052968
\mysection{Notice}
29062969
It is highly recommended that you \textbf{not} use the MD2, MD4, MD5, or SHA-1 hashes for the purposes of digital signatures or authentication codes.
29072970
These hashes are provided for completeness and they still can be used for the purposes of password hashing or one-way accumulators
29082971
(e.g. Yarrow).
29092972

2910-
The other hashes such as the SHA-2 (that includes SHA-512, SHA-512/384, SHA-384, SHA-512/256, SHA-256 and SHA-224) and TIGER-192 are still considered secure
2911-
for all purposes you would normally use a hash for.
2973+
The other hashes such as the SHA-2 (that includes SHA-512, SHA-512/384, SHA-384, SHA-512/256, SHA-256 and SHA-224), TIGER-192 and TIGER2-192 are still
2974+
considered secure for all purposes you would normally use a hash for.
29122975

29132976
\chapter{Checksum Functions}
29142977

0 commit comments

Comments
 (0)