blob: 013d8fc16dea7c4698d533a0e57c017bd514b28d [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001/*
2 Copyright (C) 2010 Werner Dittmann
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU 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#ifndef MAC_SKEIN_H
20#define MAC_SKEIN_H
21
22#include <ccrtp/crypto/skeinApi.h>
23/**
24 * @file macSkein.h
25 * @brief Function that provide Skein MAC support
26 *
27 *
28 * Functions to compute Skein MAC.
29 *
30 * @ingroup GNU_ZRTP
31 * @{
32 */
33
34/**
35 * Compute Skein MAC.
36 *
37 * This functions takes one data chunk and computes its Skein MAC.
38 *
39 * @param key
40 * The MAC key.
41 * @param key_length
42 * Lneght of the MAC key in bytes
43 * @param data
44 * Points to the data chunk.
45 * @param data_length
46 * Length of the data in bytes
47 * @param mac
48 * Points to a buffer that receives the computed digest.
49 * @param mac_length
50 * Integer that contains the length of the MAC in bits (not bytes).
51 * @param skeinSize
52 * The Skein size to use.
53 */
54void macSkein( uint8_t* key, int32_t key_length,
55 const uint8_t* data, uint32_t data_length,
56 uint8_t* mac, int32_t mac_length, SkeinSize_t skeinSize );
57
58/**
59 * Compute Skein MAC over several data cunks.
60 *
61 * This functions takes several data chunk and computes the Skein MAC.
62 *
63 * @param key
64 * The MAC key.
65 * @param key_length
66 * Lneght of the MAC key in bytes
67 * @param data
68 * Points to an array of pointers that point to the data chunks. A NULL
69 * pointer in an array element terminates the data chunks.
70 * @param data_length
71 * Points to an array of integers that hold the length of each data chunk.
72 * @param mac
73 * Points to a buffer that receives the computed digest.
74 * @param mac_length
75 * Integer that contains the length of the MAC in bits (not bytes).
76 * @param skeinSize
77 * The Skein size to use.
78 */
79void macSkein( uint8_t* key, int32_t key_length,
80 const uint8_t* data[], uint32_t data_length[],
81 uint8_t* mac, int32_t mac_length, SkeinSize_t skeinSize);
82
83/**
84 * Create and initialize a Skein MAC context.
85 *
86 * An application uses this context to hash several data with on Skein MAC
87 * Context with the same key, key length and mac length
88 *
89 * @param key
90 * The MAC key.
91 * @param key_length
92 * Lenght of the MAC key in bytes
93 * @param mac_length
94 * Integer that contains the length of the MAC in bits (not bytes).
95 * @param skeinSize
96 * The Skein size to use.
97 * @return Returns a pointer to the initialized context
98 */
99void* createSkeinMacContext(uint8_t* key, int32_t key_length,
100 int32_t mac_length, SkeinSize_t skeinSize);
101
102/**
103 * Compute Skein MAC.
104 *
105 * This functions takes one data chunk and computes its Skein MAC.
106 *
107 * @param ctx
108 * Pointer to initialized Skein MAC context
109 * @param data
110 * Points to the data chunk.
111 * @param data_length
112 * Length of the data in bytes
113 * @param mac
114 * Points to a buffer that receives the computed digest.
115 */
116
117void macSkeinCtx(void* ctx, const uint8_t* data, uint32_t data_length,
118 uint8_t* mac);
119
120/**
121 * Compute Skein MAC over several data cunks.
122 *
123 * This functions takes several data chunk and computes the SHA1 HAMAC.
124 *
125 * @param ctx
126 * Pointer to initialized Skein MAC context
127 * @param data
128 * Points to an array of pointers that point to the data chunks. A NULL
129 * pointer in an array element terminates the data chunks.
130 * @param data_length
131 * Points to an array of integers that hold the length of each data chunk.
132 * @param mac
133 * Points to a buffer that receives the computed digest.
134 */
135void macSkeinCtx(void* ctx, const uint8_t* data[], uint32_t data_length[],
136 uint8_t* mac);
137
138/**
139 * Free Skein MAC context.
140 *
141 * @param ctx a pointer to Skein MAC context
142 */
143void freeSkeinMacContext(void* ctx);
144
145/**
146 * @}
147 */
148#endif