2
* Copyright (C) 2001 Niels Moller
4
* The nettle library is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; either version 2.1 of the License, or (at your
7
* option) any later version.
9
* The nettle library is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with the nettle library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25
#define SHA256_DIGEST_SIZE 32
26
#define SHA256_DATA_SIZE 64
28
/* Digest is kept internally as 8 32-bit words. */
29
#define _SHA256_DIGEST_LENGTH 8
31
typedef struct sha256_ctx
33
uint32_t state[_SHA256_DIGEST_LENGTH]; /* State variables */
34
uint32_t count_low, count_high; /* 64-bit block count */
35
unsigned char block[SHA256_DATA_SIZE]; /* SHA256 data buffer */
36
uint32_t index; /* index into buffer */
40
sha256_init(struct sha256_ctx *ctx);
43
sha256_update(struct sha256_ctx *ctx, const unsigned char *data, uint32_t length);
46
sha256_final(struct sha256_ctx *ctx);
49
sha256_digest(const struct sha256_ctx *ctx, unsigned char *digest);