forked from ANSSI-FR/libecc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sha3-384.c
71 lines (57 loc) · 1.57 KB
/
sha3-384.c
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
65
66
67
68
69
70
71
/*
* 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_SHA3_384
#include "sha3-384.h"
void sha3_384_init(sha3_384_context *ctx)
{
_sha3_init(ctx, SHA3_384_DIGEST_SIZE);
}
void sha3_384_update(sha3_384_context *ctx, const u8 *input, u32 ilen)
{
_sha3_update((sha3_context *)ctx, input, ilen);
}
void sha3_384_final(sha3_384_context *ctx, u8 output[SHA3_384_DIGEST_SIZE])
{
_sha3_finalize((sha3_context *)ctx, output);
}
void sha3_384_scattered(const u8 **inputs, const u32 *ilens,
u8 output[SHA3_384_DIGEST_SIZE])
{
sha3_384_context ctx;
int pos = 0;
sha3_384_init(&ctx);
while (inputs[pos] != NULL) {
const u8 *buf = inputs[pos];
u32 buflen = ilens[pos];
sha3_384_update(&ctx, buf, buflen);
pos += 1;
}
sha3_384_final(&ctx, output);
}
void sha3_384(const u8 *input, u32 ilen, u8 output[SHA3_384_DIGEST_SIZE])
{
sha3_384_context ctx;
sha3_384_init(&ctx);
sha3_384_update(&ctx, input, ilen);
sha3_384_final(&ctx, output);
}
#else /* WITH_HASH_SHA3_384 */
/*
* Dummy definition to avoid the empty translation unit ISO C warning
*/
typedef int dummy;
#endif /* WITH_HASH_SHA3_384 */