Commit d8eb745b authored by Niels Möller's avatar Niels Möller

* Makefile.in (nettle_SOURCES): Added sha512.c and sha512-meta.c.

* sha.h: Added SHA-512-related declarations.
* nettle-meta.h: Likewise.

* sha512-meta.c: New file.
* sha512.c: New file.

Rev: nettle/Makefile.in:1.14
Rev: nettle/nettle-meta.h:1.3
Rev: nettle/sha.h:1.2
Rev: nettle/sha512-meta.c:1.1
Rev: nettle/sha512.c:1.1
parent 03bdd346
......@@ -65,6 +65,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
md2.c md2-meta.c md4.c md4-meta.c \
md5.c md5-compress.c md5-compat.c md5-meta.c \
sha1.c sha1-compress.c sha1-meta.c sha256.c sha256-meta.c \
sha512.c sha512-meta.c \
serpent.c serpent-meta.c \
twofish.c twofish-meta.c \
yarrow256.c yarrow_key_event.c \
......
......@@ -138,6 +138,7 @@ extern const struct nettle_hash nettle_md4;
extern const struct nettle_hash nettle_md5;
extern const struct nettle_hash nettle_sha1;
extern const struct nettle_hash nettle_sha256;
extern const struct nettle_hash nettle_sha512;
struct nettle_armor
{
......
......@@ -39,6 +39,9 @@ extern "C" {
#define sha256_init nettle_sha256_init
#define sha256_update nettle_sha256_update
#define sha256_digest nettle_sha256_digest
#define sha512_init nettle_sha512_init
#define sha512_update nettle_sha512_update
#define sha512_digest nettle_sha512_digest
/* SHA1 */
......@@ -103,6 +106,35 @@ sha256_digest(struct sha256_ctx *ctx,
unsigned length,
uint8_t *digest);
/* SHA512 */
#define SHA512_DIGEST_SIZE 64
#define SHA512_DATA_SIZE 128
/* Digest is kept internally as 8 64-bit words. */
#define _SHA512_DIGEST_LENGTH 8
struct sha512_ctx
{
uint64_t state[_SHA512_DIGEST_LENGTH]; /* State variables */
uint64_t count_low, count_high; /* 128-bit block count */
uint8_t block[SHA512_DATA_SIZE]; /* SHA512 data buffer */
unsigned int index; /* index into buffer */
};
void
sha512_init(struct sha512_ctx *ctx);
void
sha512_update(struct sha512_ctx *ctx,
unsigned length,
const uint8_t *data);
void
sha512_digest(struct sha512_ctx *ctx,
unsigned length,
uint8_t *digest);
#ifdef __cplusplus
}
#endif
......
/* sha512-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2002, 2010 Niels Möller
*
* The nettle 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.
*
* The nettle 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "nettle-meta.h"
#include "sha.h"
const struct nettle_hash nettle_sha512
= _NETTLE_HASH(sha512, SHA512);
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment