Commit 0802f01a authored by Niels Möller's avatar Niels Möller

Trivial merge.

parents 12e33e1e 3035fa2a
2014-04-09 Niels Möller <nisse@lysator.liu.se>
* examples/nettle-benchmark.c (main): Benchmark sha512_224 and
sha512_256.
* testsuite/sha512-224-test.c: New file.
* testsuite/sha512-256-test.c: New file.
* testsuite/Makefile.in (TS_NETTLE_SOURCES): Added new files.
* nettle-meta.h (nettle_sha512_224, nettle_sha512_256): Declare.
* sha512-224-meta.c (nettle_sha512_224): New file, new nettle_hash.
* sha512-256-meta.c (nettle_sha512_256): New file, new nettle_hash.
* sha2.h (SHA512_224_DIGEST_SIZE, SHA512_224_DATA_SIZE)
(SHA512_256_DIGEST_SIZE, SHA512_256_DATA_SIZE): New constants.
* sha512.c (sha512_256_digest): Typo fix, call sha512_256_init.
* testsuite/testutils.c (test_hash): Removed redundant init call.
Tests that digest implies init.
2014-03-28 Niels Möller <nisse@lysator.liu.se>
* testsuite/dsa-keygen-test.c (test_main): Explicitly use
......
......@@ -119,6 +119,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
sha1.c sha1-compress.c sha1-meta.c \
sha256.c sha256-compress.c sha224-meta.c sha256-meta.c \
sha512.c sha512-compress.c sha384-meta.c sha512-meta.c \
sha512-224-meta.c sha512-256-meta.c \
sha3.c sha3-permute.c \
sha3-224.c sha3-224-meta.c sha3-256.c sha3-256-meta.c \
sha3-384.c sha3-384-meta.c sha3-512.c sha3-512-meta.c\
......
......@@ -723,6 +723,7 @@ main(int argc, char **argv)
&nettle_sha1, OPENSSL(&nettle_openssl_sha1)
&nettle_sha224, &nettle_sha256,
&nettle_sha384, &nettle_sha512,
&nettle_sha512_224, &nettle_sha512_256,
&nettle_sha3_224, &nettle_sha3_256,
&nettle_sha3_384, &nettle_sha3_512,
&nettle_ripemd160, &nettle_gosthash94,
......
......@@ -119,6 +119,8 @@ extern const struct nettle_hash nettle_sha224;
extern const struct nettle_hash nettle_sha256;
extern const struct nettle_hash nettle_sha384;
extern const struct nettle_hash nettle_sha512;
extern const struct nettle_hash nettle_sha512_224;
extern const struct nettle_hash nettle_sha512_256;
extern const struct nettle_hash nettle_sha3_224;
extern const struct nettle_hash nettle_sha3_256;
extern const struct nettle_hash nettle_sha3_384;
......
......@@ -156,6 +156,9 @@ sha384_digest(struct sha512_ctx *ctx,
/* SHA512_224 and SHA512_256, two truncated versions of SHA512
with different initial states. */
#define SHA512_224_DIGEST_SIZE 28
#define SHA512_224_DATA_SIZE SHA512_DATA_SIZE
void
sha512_224_init(struct sha512_ctx *ctx);
......@@ -166,6 +169,8 @@ sha512_224_digest(struct sha512_ctx *ctx,
size_t length,
uint8_t *digest);
#define SHA512_256_DIGEST_SIZE 32
#define SHA512_256_DATA_SIZE SHA512_DATA_SIZE
void
sha512_256_init(struct sha512_ctx *ctx);
......
/* sha512-224-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02111-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "nettle-meta.h"
#include "sha2.h"
const struct nettle_hash nettle_sha512_224 =
{
"sha512-224", sizeof(struct sha512_ctx),
SHA512_224_DIGEST_SIZE,
SHA512_224_DATA_SIZE,
(nettle_hash_init_func *) sha512_224_init,
(nettle_hash_update_func *) sha512_224_update,
(nettle_hash_digest_func *) sha512_224_digest
};
/* sha512-256-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston,
* MA 02111-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "nettle-meta.h"
#include "sha2.h"
const struct nettle_hash nettle_sha512_256 =
{
"sha512-256", sizeof(struct sha512_ctx),
SHA512_256_DIGEST_SIZE,
SHA512_256_DATA_SIZE,
(nettle_hash_init_func *) sha512_256_init,
(nettle_hash_update_func *) sha512_256_update,
(nettle_hash_digest_func *) sha512_256_digest
};
......@@ -302,5 +302,5 @@ sha512_256_digest(struct sha512_ctx *ctx,
assert(length <= SHA256_DIGEST_SIZE);
sha512_write_digest(ctx, length, digest);
sha512_224_init(ctx);
sha512_256_init(ctx);
}
......@@ -73,6 +73,12 @@ sha384-test$(EXEEXT): sha384-test.$(OBJEXT)
sha512-test$(EXEEXT): sha512-test.$(OBJEXT)
$(LINK) sha512-test.$(OBJEXT) $(TEST_OBJS) -o sha512-test$(EXEEXT)
sha512-224-test$(EXEEXT): sha512-224-test.$(OBJEXT)
$(LINK) sha512-224-test.$(OBJEXT) $(TEST_OBJS) -o sha512-224-test$(EXEEXT)
sha512-256-test$(EXEEXT): sha512-256-test.$(OBJEXT)
$(LINK) sha512-256-test.$(OBJEXT) $(TEST_OBJS) -o sha512-256-test$(EXEEXT)
sha3-permute-test$(EXEEXT): sha3-permute-test.$(OBJEXT)
$(LINK) sha3-permute-test.$(OBJEXT) $(TEST_OBJS) -o sha3-permute-test$(EXEEXT)
......@@ -100,9 +106,6 @@ knuth-lfib-test$(EXEEXT): knuth-lfib-test.$(OBJEXT)
cbc-test$(EXEEXT): cbc-test.$(OBJEXT)
$(LINK) cbc-test.$(OBJEXT) $(TEST_OBJS) -o cbc-test$(EXEEXT)
ccm-test$(EXEEXT): ccm-test.$(OBJEXT)
$(LINK) ccm-test.$(OBJEXT) $(TEST_OBJS) -o ccm-test$(EXEEXT)
ctr-test$(EXEEXT): ctr-test.$(OBJEXT)
$(LINK) ctr-test.$(OBJEXT) $(TEST_OBJS) -o ctr-test$(EXEEXT)
......@@ -112,6 +115,9 @@ gcm-test$(EXEEXT): gcm-test.$(OBJEXT)
eax-test$(EXEEXT): eax-test.$(OBJEXT)
$(LINK) eax-test.$(OBJEXT) $(TEST_OBJS) -o eax-test$(EXEEXT)
ccm-test$(EXEEXT): ccm-test.$(OBJEXT)
$(LINK) ccm-test.$(OBJEXT) $(TEST_OBJS) -o ccm-test$(EXEEXT)
poly1305-test$(EXEEXT): poly1305-test.$(OBJEXT)
$(LINK) poly1305-test.$(OBJEXT) $(TEST_OBJS) -o poly1305-test$(EXEEXT)
......
......@@ -20,7 +20,7 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
ripemd160-test.c \
salsa20-test.c \
sha1-test.c sha224-test.c sha256-test.c \
sha384-test.c sha512-test.c \
sha384-test.c sha512-test.c sha512-224-test.c sha512-256-test.c \
sha3-permute-test.c sha3-224-test.c sha3-256-test.c \
sha3-384-test.c sha3-512-test.c \
serpent-test.c twofish-test.c \
......
#include "testutils.h"
void
test_main(void)
{
/* From http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf */
test_hash(&nettle_sha512_224, SDATA("abc"),
SHEX("4634270F 707B6A54 DAAE7530 460842E2"
"0E37ED26 5CEEE9A4 3E8924AA"));
test_hash(&nettle_sha512_224, SDATA("abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno"
"ijklmnopjklmnopqklmnopqrlmnopqrs"
"mnopqrstnopqrstu"),
SHEX("23FEC5BB 94D60B23 30819264 0B0C4533"
"35D66473 4FE40E72 68674AF9"));
}
#include "testutils.h"
void
test_main(void)
{
/* From http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf */
test_hash(&nettle_sha512_256, SDATA("abc"),
SHEX("53048E26 81941EF9 9B2E29B7 6B4C7DAB"
"E4C2D0C6 34FC6D46 E0E2F131 07E7AF23"));
test_hash(&nettle_sha512_256, SDATA("abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno"
"ijklmnopjklmnopqklmnopqrlmnopqrs"
"mnopqrstnopqrstu"),
SHEX("3928E184 FB8690F8 40DA3988 121D31BE"
"65CB9D3E F83EE614 6FEAC861 E19B563A"));
}
......@@ -568,7 +568,6 @@ test_hash(const struct nettle_hash *hash,
memset(buffer, 0, hash->digest_size);
hash->init(ctx);
hash->update(ctx, msg->length, msg->data);
hash->digest(ctx, hash->digest_size - 1, buffer);
......
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