/
sha1.h
71 lines (64 loc) · 1.8 KB
/
sha1.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
65
66
67
68
69
70
71
/**
* @file hash/sha1.h
*
* @section License
* Copyright (C) 2015-2016, Erik Moqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* This file is part of the Simba project.
*/
#ifndef __HASH_SHA1_H__
#define __HASH_SHA1_H__
#include "simba.h"
struct sha1_t {
struct {
uint8_t buf[64];
uint32_t size;
} block;
uint32_t h[5];
uint64_t size;
};
/**
* Initialize given SHA1 object.
*
* @param[in,out] self_p SHA1 object.
*
* @return zero(0) or negative error code.
*/
int sha1_init(struct sha1_t *self_p);
/**
* Update the sha object with the given buffer. Repeated calls are
* equivalent to a single call with the concatenation of all the
* arguments.
*
* @param[in] self_p SHA1 object.
* @param[in] buf_p Buffer to update the sha object with.
* @param[in] size Size of the buffer.
*
* @return zero(0) or negative error code.
*/
int sha1_update(struct sha1_t *self_p,
void *buf_p,
size_t size);
/**
* Return the digest of the strings passed to the sha1_update()
* method so far. This is a 20-byte value which may contain non-ASCII
* characters, including null bytes.
*
* @param[in] self_p SHA1 object.
* @param[in] hash_p Hash sum.
*
* @return zero(0) or negative error code.
*/
int sha1_digest(struct sha1_t *self_p,
uint8_t *hash_p);
#endif