From 7aef18d3e4cbdbef1c24309475ae10f66e4456ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Wed, 9 Apr 2014 14:53:20 +0200 Subject: [PATCH] nettle_hash instances for sha512_224 and sha512_256. --- ChangeLog | 4 ++++ Makefile.in | 1 + nettle-meta.h | 2 ++ sha512-224-meta.c | 40 ++++++++++++++++++++++++++++++++++++++++ sha512-256-meta.c | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 sha512-224-meta.c create mode 100644 sha512-256-meta.c diff --git a/ChangeLog b/ChangeLog index dfa97ebc..27cec7ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2014-04-09 Niels Möller <nisse@lysator.liu.se> + * 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. diff --git a/Makefile.in b/Makefile.in index 5fbc1eee..c25cf190 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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\ diff --git a/nettle-meta.h b/nettle-meta.h index 15a5b22c..cd46ee46 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -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; diff --git a/sha512-224-meta.c b/sha512-224-meta.c new file mode 100644 index 00000000..eee1bd56 --- /dev/null +++ b/sha512-224-meta.c @@ -0,0 +1,40 @@ +/* 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 + }; + diff --git a/sha512-256-meta.c b/sha512-256-meta.c new file mode 100644 index 00000000..f3ff5485 --- /dev/null +++ b/sha512-256-meta.c @@ -0,0 +1,40 @@ +/* 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 + }; + -- GitLab