tiger.h
Go to the documentation of this file.
1 /**
2  * @file tiger.h
3  * @brief Tiger 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 _TIGER_H
32 #define _TIGER_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Tiger block size
38 #define TIGER_BLOCK_SIZE 64
39 //Tiger digest size
40 #define TIGER_DIGEST_SIZE 24
41 //Minimum length of the padding string
42 #define TIGER_MIN_PAD_SIZE 9
43 //Tiger algorithm object identifier
44 #define TIGER_OID tigerOid
45 //Common interface for hash algorithms
46 #define TIGER_HASH_ALGO (&tigerHashAlgo)
47 
48 //C++ guard
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 
54 /**
55  * @brief Tiger algorithm context
56  **/
57 
58 typedef struct
59 {
60  union
61  {
62  uint64_t h[3];
63  uint8_t digest[24];
64  };
65  union
66  {
67  uint64_t x[8];
68  uint8_t buffer[64];
69  };
70  size_t size;
71  uint64_t totalSize;
72 } TigerContext;
73 
74 
75 //Tiger related constants
76 extern const uint8_t tigerOid[9];
77 extern const HashAlgo tigerHashAlgo;
78 
79 //Tiger related functions
80 error_t tigerCompute(const void *data, size_t length, uint8_t *digest);
81 void tigerInit(TigerContext *context);
82 void tigerUpdate(TigerContext *context, const void *data, size_t length);
83 void tigerFinal(TigerContext *context, uint8_t *digest);
84 void tigerProcessBlock(TigerContext *context);
85 
86 //C++ guard
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif
uint8_t length
Definition: dtls_misc.h:149
size_t size
Definition: tiger.h:70
uint64_t totalSize
Definition: tiger.h:71
error_t tigerCompute(const void *data, size_t length, uint8_t *digest)
Digest a message using Tiger.
Definition: tiger.c:386
uint8_t h
Definition: ndp.h:300
error_t
Error codes.
Definition: error.h:42
void tigerInit(TigerContext *context)
Initialize Tiger message digest context.
Definition: tiger.c:413
const uint8_t tigerOid[9]
Definition: tiger.c:357
General definitions for cryptographic algorithms.
void tigerUpdate(TigerContext *context, const void *data, size_t length)
Update the Tiger context with a portion of the message being hashed.
Definition: tiger.c:434
Tiger algorithm context.
Definition: tiger.h:58
const HashAlgo tigerHashAlgo
Definition: tiger.c:360
void tigerProcessBlock(TigerContext *context)
Process message in 16-word blocks.
Definition: tiger.c:514
Common interface for hash algorithms.
Definition: crypto.h:1128
void tigerFinal(TigerContext *context, uint8_t *digest)
Finish the Tiger message digest.
Definition: tiger.c:473
uint8_t data[]
Definition: dtls_misc.h:176