whirlpool.h
Go to the documentation of this file.
1 /**
2  * @file whirlpool.h
3  * @brief Whirlpool hash function
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCrypto Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _WHIRLPOOL_H
32 #define _WHIRLPOOL_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Whirlpool block size
38 #define WHIRLPOOL_BLOCK_SIZE 64
39 //Whirlpool digest size
40 #define WHIRLPOOL_DIGEST_SIZE 64
41 //Minimum length of the padding string
42 #define WHIRLPOOL_MIN_PAD_SIZE 33
43 //Whirlpool algorithm object identifier
44 #define WHIRLPOOL_OID whirlpoolOid
45 //Common interface for hash algorithms
46 #define WHIRLPOOL_HASH_ALGO (&whirlpoolHashAlgo)
47 
48 //C++ guard
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 
54 /**
55  * @brief Whirlpool algorithm context
56  **/
57 
58 typedef struct
59 {
60  union
61  {
62  uint64_t h[8];
63  uint8_t digest[64];
64  };
65  union
66  {
67  uint64_t x[8];
68  uint8_t buffer[64];
69  };
70 
71  uint64_t k[8];
72  uint64_t l[8];
73  uint64_t state[8];
74 
75  size_t size;
76  uint64_t totalSize;
78 
79 
80 //Whirlpool related constants
81 extern const uint8_t whirlpoolOid[6];
82 extern const HashAlgo whirlpoolHashAlgo;
83 
84 //Whirlpool related functions
85 error_t whirlpoolCompute(const void *data, size_t length, uint8_t *digest);
86 void whirlpoolInit(WhirlpoolContext *context);
87 void whirlpoolUpdate(WhirlpoolContext *context, const void *data, size_t length);
88 void whirlpoolFinal(WhirlpoolContext *context, uint8_t *digest);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
uint8_t length
Definition: dtls_misc.h:149
const uint8_t whirlpoolOid[6]
Definition: whirlpool.c:154
uint64_t totalSize
Definition: whirlpool.h:76
void whirlpoolProcessBlock(WhirlpoolContext *context)
Process message in 16-word blocks.
Definition: whirlpool.c:317
uint8_t h
Definition: ndp.h:300
error_t whirlpoolCompute(const void *data, size_t length, uint8_t *digest)
Digest a message using Whirlpool.
Definition: whirlpool.c:183
error_t
Error codes.
Definition: error.h:42
void whirlpoolFinal(WhirlpoolContext *context, uint8_t *digest)
Finish the Whirlpool message digest.
Definition: whirlpool.c:273
General definitions for cryptographic algorithms.
void whirlpoolUpdate(WhirlpoolContext *context, const void *data, size_t length)
Update the Whirlpool context with a portion of the message being hashed.
Definition: whirlpool.c:234
Whirlpool algorithm context.
Definition: whirlpool.h:58
uint8_t l
Definition: ndp.h:411
void whirlpoolInit(WhirlpoolContext *context)
Initialize Whirlpool message digest context.
Definition: whirlpool.c:210
const HashAlgo whirlpoolHashAlgo
Definition: whirlpool.c:157
Common interface for hash algorithms.
Definition: crypto.h:1128
uint8_t data[]
Definition: dtls_misc.h:176