-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsha512.cpp
36 lines (35 loc) · 2.3 KB
/
sha512.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://ru.wikipedia.org/wiki/SHA-2
// wrapper for SHA512 from http://ftp.gnu.org/gnu/coreutils/coreutils-8.21.tar.xz
// Alexey Potehin <[email protected]>, http://www.gnuplanet.ru/doc/cv
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include "sha512.hpp"
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// constructor
sha512_t::sha512_t()
{
this->psha512_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// open operation
void sha512_t::open(sha512_item_t *psha512_item)
{
sha512_init_ctx(&this->ctx);
this->psha512_item = psha512_item;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// update hash
void sha512_t::update(const void * const p, uint64_t size)
{
if (this->psha512_item == NULL) return;
sha512_process_bytes(p, size, &this->ctx);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// close operation
void sha512_t::close()
{
sha512_finish_ctx(&this->ctx, this->psha512_item);
this->psha512_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//