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