blake2s.h
Go to the documentation of this file.
1 /**
2  * @file blake2s.h
3  * @brief BLAKE2 cryptographic hash and MAC (BLAKE2s variant)
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 _BLAKE2S_H
30 #define _BLAKE2S_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //BLAKE2s block size
36 #define BLAKE2S_BLOCK_SIZE 64
37 
38 //C++ guard
39 #ifdef __cplusplus
40  extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief BLAKE2s algorithm context
46  **/
47 
48 typedef struct
49 {
50  union
51  {
52  uint32_t h[8];
53  uint8_t digest[32];
54  };
55  union
56  {
57  uint32_t m[16];
58  uint8_t buffer[64];
59  };
60  size_t size;
61  uint32_t totalSize[2];
62  size_t digestSize;
64 
65 
66 //BLAKE2s related functions
67 error_t blake2sCompute(const void *key, size_t keyLen, const void *data,
68  size_t dataLen, uint8_t *digest, size_t digestLen);
69 
70 error_t blake2sInit(Blake2sContext *context, const void *key,
71  size_t keyLen, size_t digestLen);
72 
73 void blake2sUpdate(Blake2sContext *context, const void *data, size_t length);
74 void blake2sFinal(Blake2sContext *context, uint8_t *digest);
76 
77 //C++ guard
78 #ifdef __cplusplus
79  }
80 #endif
81 
82 #endif
void blake2sUpdate(Blake2sContext *context, const void *data, size_t length)
Update the BLAKE2s context with a portion of the message being hashed.
Definition: blake2s.c:203
General definitions for cryptographic algorithms.
uint8_t m
Definition: ndp.h:299
uint32_t totalSize
size_t digestSize
Definition: blake2s.h:62
void blake2sFinal(Blake2sContext *context, uint8_t *digest)
Finish the BLAKE2s message digest.
Definition: blake2s.c:241
void blake2sProcessBlock(Blake2sContext *context, bool_t last)
Compression function F.
Definition: blake2s.c:274
uint16_t last
Definition: ipv4_frag.h:94
size_t size
Definition: blake2s.h:60
error_t
Error codes.
Definition: error.h:40
BLAKE2s algorithm context.
Definition: blake2s.h:48
uint8_t data[]
Definition: dtls_misc.h:167
error_t blake2sCompute(const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *digest, size_t digestLen)
Digest a message using BLAKE2s.
Definition: blake2s.c:96
error_t blake2sInit(Blake2sContext *context, const void *key, size_t keyLen, size_t digestLen)
Initialize BLAKE2s message digest context.
Definition: blake2s.c:143
uint8_t length
Definition: dtls_misc.h:140
uint8_t h
Definition: ndp.h:297
int bool_t
Definition: compiler_port.h:47