Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 1 | /* |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 2 | Copyright (C) 2013 Werner Dittmann |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library 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 GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | /** |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 21 | * Methods to compute a Skein256 HMAC. |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 22 | * |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 23 | * @author Werner Dittmann <Werner.Dittmann@t-online.de> |
| 24 | */ |
| 25 | |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 26 | #ifndef HMAC_SKEIN256_H |
| 27 | #define HMAC_SKEIN256_H |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 28 | |
| 29 | /** |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 30 | * @file skeinMac256.h |
| 31 | * @brief Function that provide Skein256 HMAC support |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 32 | * |
| 33 | * @ingroup GNU_ZRTP |
| 34 | * @{ |
| 35 | */ |
| 36 | |
| 37 | #include <stdint.h> |
| 38 | |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 39 | #ifndef SKEIN256_DIGEST_LENGTH |
| 40 | #define SKEIN256_DIGEST_LENGTH 32 |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 41 | #endif |
| 42 | |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 43 | #define SKEIN_SIZE Skein512 |
| 44 | |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 45 | /** |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 46 | * Compute Skein256 HMAC. |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 47 | * |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 48 | * This functions takes one data chunk and computes its Skein256 HMAC. |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 49 | * |
| 50 | * @param key |
| 51 | * The MAC key. |
| 52 | * @param key_length |
| 53 | * Lneght of the MAC key in bytes |
| 54 | * @param data |
| 55 | * Points to the data chunk. |
| 56 | * @param data_length |
| 57 | * Length of the data in bytes |
| 58 | * @param mac |
| 59 | * Points to a buffer that receives the computed digest. This |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 60 | * buffer must have a size of at least 32 bytes (SKEIN256_DIGEST_LENGTH). |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 61 | * @param mac_length |
| 62 | * Point to an integer that receives the length of the computed HMAC. |
| 63 | */ |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 64 | void macSkein256( uint8_t* key, uint32_t key_length, uint8_t* data, int32_t data_length, uint8_t* mac, uint32_t* mac_length ); |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 65 | |
| 66 | /** |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 67 | * Compute Skein256 HMAC over several data cunks. |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 68 | * |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 69 | * This functions takes several data chunk and computes the Skein256 HAMAC. |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 70 | * |
| 71 | * @param key |
| 72 | * The MAC key. |
| 73 | * @param key_length |
| 74 | * Lneght of the MAC key in bytes |
| 75 | * @param data |
| 76 | * Points to an array of pointers that point to the data chunks. A NULL |
| 77 | * pointer in an array element terminates the data chunks. |
| 78 | * @param data_length |
| 79 | * Points to an array of integers that hold the length of each data chunk. |
| 80 | * @param mac |
| 81 | * Points to a buffer that receives the computed digest. This |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 82 | * buffer must have a size of at least 32 bytes (SKEIN256_DIGEST_LENGTH). |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 83 | * @param mac_length |
| 84 | * Point to an integer that receives the length of the computed HMAC. |
| 85 | */ |
| 86 | |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 87 | void macSkein256( uint8_t* key, uint32_t key_length, uint8_t* data[], uint32_t data_length[], uint8_t* mac, uint32_t* mac_length ); |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 88 | /** |
| 89 | * @} |
| 90 | */ |
| 91 | #endif |