-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsha3_384.cpp
36 lines (35 loc) · 2.4 KB
/
sha3_384.cpp
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
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// http://en.wikipedia.org/wiki/SHA-3
// wrapper for SHA3_384 for module of GNU/Linux kernel written by Jeff Garzik <[email protected]> from https://lwn.net/Articles/518415/
// Alexey Potehin <[email protected]>, http://www.gnuplanet.ru/doc/cv
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include "sha3_384.hpp"
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// constructor
sha3_384_t::sha3_384_t()
{
this->psha3_384_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// open operation
void sha3_384_t::open(sha3_384_item_t *psha3_384_item)
{
sha3_init(&this->ctx, SHA3_384_DIGEST_SIZE);
this->psha3_384_item = psha3_384_item;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// update hash
void sha3_384_t::update(const void * const p, uint64_t size)
{
if (this->psha3_384_item == NULL) return;
sha3_update(&this->ctx, (uint8_t *)p, size);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// close operation
void sha3_384_t::close()
{
sha3_final(&this->ctx, (uint8_t *)this->psha3_384_item);
this->psha3_384_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//