forked from ANSSI-FR/libecc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sha224.h
64 lines (56 loc) · 1.75 KB
/
sha224.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <[email protected]>
* Arnaud EBALARD <[email protected]>
* Jean-Pierre FLORI <[email protected]>
*
* Contributors:
* Nicolas VIVET <[email protected]>
* Karim KHALFALLAH <[email protected]>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#include "../lib_ecc_config.h"
#ifdef WITH_HASH_SHA224
#ifndef __SHA224_H__
#define __SHA224_H__
#include "../words/words.h"
#include "../utils/utils.h"
#include "sha2.h"
#define SHA224_STATE_SIZE 8
#define SHA224_BLOCK_SIZE 64
#define SHA224_DIGEST_SIZE 28
/* Compute max hash digest and block sizes */
#ifndef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE 0
#endif
#if (MAX_DIGEST_SIZE < SHA224_DIGEST_SIZE)
#undef MAX_DIGEST_SIZE
#define MAX_DIGEST_SIZE SHA224_DIGEST_SIZE
#endif
#ifndef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE 0
#endif
#if (MAX_BLOCK_SIZE < SHA224_BLOCK_SIZE)
#undef MAX_BLOCK_SIZE
#define MAX_BLOCK_SIZE SHA224_BLOCK_SIZE
#endif
typedef struct {
/* Number of bytes processed */
u64 sha224_total;
/* Internal state */
u32 sha224_state[SHA224_STATE_SIZE];
/* Internal buffer to handle updates in a block */
u8 sha224_buffer[SHA224_BLOCK_SIZE];
} sha224_context;
void sha224_init(sha224_context *ctx);
void sha224_update(sha224_context *ctx, const u8 *input, u32 ilen);
void sha224_final(sha224_context *ctx, u8 output[SHA224_DIGEST_SIZE]);
void sha224_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA224_DIGEST_SIZE]);
void sha224(const u8 *input, u32 ilen, u8 output[SHA224_DIGEST_SIZE]);
#endif /* __SHA224_H__ */
#endif /* WITH_HASH_SHA224 */