blob: 61fd64eaea8f4cdb428a4d5a9d6cf1d728250fef [file] [log] [blame]
Alexandre Lision907ed2e2014-02-04 10:33:09 -05001/*
2 Copyright (C) 2013 Werner Dittmann
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/**
19 * Functions to compute Skein384 digest.
20 *
21 * @author: Werner Dittmann <Werner.Dittmann@t-online.de>
22 */
23
24#ifndef _SKEIN384_H
25#define _SKEIN384_H
26
27/**
28 * @file skein384.h
29 * @brief Functions that provide Skein384 support
30 *
31 * @ingroup GNU_ZRTP
32 * @{
33 */
34
35#include <stdint.h>
36
37#ifndef SKEIN384_DIGEST_LENGTH
38#define SKEIN384_DIGEST_LENGTH 48
39#endif
40#define SKEIN_SIZE Skein512
41
42
43/**
44 * Compute Skein384 digest.
45 *
46 * This functions takes one data chunk and computes its Skein384 digest. This
47 * function creates and deletes an own Skein384 context to perform the Skein384
48 * operations.
49 *
50 * @param data
51 * Points to the data chunk.
52 * @param data_length
53 * Length of the data in bytes
54 * @param digest
55 * Points to a buffer that receives the computed digest. This
56 * buffer must have a size of at least 48 bytes (Skein384_DIGEST_LENGTH).
57 */
58void skein384(unsigned char *data,
59 unsigned int data_length,
60 unsigned char *digest);
61
62/**
63 * Compute Skein384 digest over several data cunks.
64 *
65 * This functions takes several data chunks and computes the Skein384 digest.
66 * This function creates and deletes an own Skein384 context to perform the
67 * Skein384 operations.
68 *
69 * @param data
70 * Points to an array of pointers that point to the data chunks. A NULL
71 * pointer in an array element terminates the data chunks.
72 * @param data_length
73 * Points to an array of integers that hold the length of each data chunk.
74 * @param digest
75 * Points to a buffer that receives the computed digest. This
76 * buffer must have a size of at least 48 bytes (Skein384_DIGEST_LENGTH).
77 */
78void skein384(unsigned char *data[],
79 unsigned int data_length[],
80 unsigned char *digest);
81/**
82 * Create and initialize a Skein384 context.
83 *
84 * An application uses this context to hash several data into one Skein384
85 * digest. See also skein384Ctx(...) and closeSha384Context(...).
86 *
87 * @return Returns a pointer to the initialized Skein384 context
88 */
89void* createSkein384Context();
90
91/**
92 * Compute a digest and close the SHa384 digest.
93 *
94 * An application uses this function to compute the Skein384 digest and to
95 * close the Skein384 context.
96 *
97 * @param ctx
98 * Points to the Skein384 context.
99 * @param digest
100 * If this pointer is not NULL then it must point to a byte array that
101 * is big enough to hold the Skein384 digest (384 bit = 48 Bytes). If this
102 * pointer is NULL then the functions does not compute the digest but
103 * closes the context only. The context cannot be used anymore.
104 */
105void closeSkein384Context(void* ctx,
106 unsigned char* digest);
107
108/**
109 * Update the Skein384 context with data.
110 *
111 * This functions updates the Skein384 context with some data.
112 * See also CloseSha384Context(...) how to get the digest.
113 *
114 * @param ctx
115 * Points to the Skein384 context.
116 * @param data
117 * Points to the data to update the context.
118 * @param dataLength
119 * The length of the data in bytes.
120 */
121void skein384Ctx(void* ctx, unsigned char* data,
122 unsigned int dataLength);
123
124/**
125 * Update the Skein384 context with several data chunks.
126 *
127 * This functions updates the Skein384 context with some data.
128 * See also CloseSha384Context(...) how to get the digest.
129 *
130 * @param ctx
131 * Points to the Skein384 context.
132 * @param dataChunks
133 * Points to an array of pointers that point to the data chunks. A NULL
134 * pointer in an array element terminates the data chunks.
135 * @param dataChunkLength
136 * Points to an array of integers that hold the length of each data chunk.
137 *
138 */
139void skein384Ctx(void* ctx, unsigned char* dataChunks[],
140 unsigned int dataChunkLength[]);
141
142/**
143 * @}
144 */
145#endif
146