summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorallanjude <allanjude@FreeBSD.org>2015-12-27 17:33:59 +0000
committerallanjude <allanjude@FreeBSD.org>2015-12-27 17:33:59 +0000
commitc7c2f2dfabee24fac29d13375d8c29a7f766746c (patch)
tree8a9bc5399c16c0f637716b176f3f95c32c001a0f /sbin
parente7bdbef72941799b684fb8a542f52b0fbafd254d (diff)
downloadFreeBSD-src-c7c2f2dfabee24fac29d13375d8c29a7f766746c.zip
FreeBSD-src-c7c2f2dfabee24fac29d13375d8c29a7f766746c.tar.gz
Replace sys/crypto/sha2/sha2.c with lib/libmd/sha512c.c
cperciva's libmd implementation is 5-30% faster The same was done for SHA256 previously in r263218 cperciva's implementation was lacking SHA-384 which I implemented, validated against OpenSSL and the NIST documentation Extend sbin/md5 to create sha384(1) Chase dependancies on sys/crypto/sha2/sha2.{c,h} and replace them with sha512{c.c,.h} Reviewed by: cperciva, des, delphij Approved by: secteam, bapt (mentor) MFC after: 2 weeks Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D3929
Diffstat (limited to 'sbin')
-rw-r--r--sbin/gbde/Makefile2
-rw-r--r--sbin/gbde/gbde.c2
-rw-r--r--sbin/geom/class/eli/Makefile3
-rw-r--r--sbin/md5/Makefile2
-rw-r--r--sbin/md5/md5.114
-rw-r--r--sbin/md5/md5.c17
6 files changed, 33 insertions, 7 deletions
diff --git a/sbin/gbde/Makefile b/sbin/gbde/Makefile
index c33136b..f80f8cd 100644
--- a/sbin/gbde/Makefile
+++ b/sbin/gbde/Makefile
@@ -4,7 +4,7 @@ PROG= gbde
SRCS= gbde.c template.c
SRCS+= rijndael-alg-fst.c
SRCS+= rijndael-api-fst.c
-SRCS+= sha2.c
+SRCS+= sha512c.c
SRCS+= g_bde_lock.c
# rijndael-fst.c does evil casting things which can results in warnings,
diff --git a/sbin/gbde/gbde.c b/sbin/gbde/gbde.c
index 3dca212..710ae2c 100644
--- a/sbin/gbde/gbde.c
+++ b/sbin/gbde/gbde.c
@@ -84,7 +84,7 @@
#include <sys/disk.h>
#include <sys/stat.h>
#include <crypto/rijndael/rijndael-api-fst.h>
-#include <crypto/sha2/sha2.h>
+#include <crypto/sha2/sha512.h>
#include <sys/param.h>
#include <sys/linker.h>
diff --git a/sbin/geom/class/eli/Makefile b/sbin/geom/class/eli/Makefile
index f8e453d..50de651 100644
--- a/sbin/geom/class/eli/Makefile
+++ b/sbin/geom/class/eli/Makefile
@@ -6,7 +6,8 @@ GEOM_CLASS= eli
SRCS= g_eli_crypto.c
SRCS+= g_eli_key.c
SRCS+= pkcs5v2.c
-SRCS+= sha2.c
+SRCS+= sha256c.c
+SRCS+= sha512c.c
LIBADD= md crypto
diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile
index b6afe4e..5f927c4 100644
--- a/sbin/md5/Makefile
+++ b/sbin/md5/Makefile
@@ -6,11 +6,13 @@ PROG= md5
LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \
${BINDIR}/md5 ${BINDIR}/sha1 \
${BINDIR}/md5 ${BINDIR}/sha256 \
+ ${BINDIR}/md5 ${BINDIR}/sha384 \
${BINDIR}/md5 ${BINDIR}/sha512
MLINKS= md5.1 rmd160.1 \
md5.1 sha1.1 \
md5.1 sha256.1 \
+ md5.1 sha384.1 \
md5.1 sha512.1
LIBADD= md
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index e191cd1..94cdf84 100644
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -1,9 +1,9 @@
.\" $FreeBSD$
-.Dd May 17, 2014
+.Dd October 17, 2015
.Dt MD5 1
.Os
.Sh NAME
-.Nm md5 , sha1 , sha256 , sha512, rmd160
+.Nm md5 , sha1 , sha256 , sha384 , sha512, rmd160
.Nd calculate a message-digest fingerprint (checksum) for a file
.Sh SYNOPSIS
.Nm md5
@@ -21,6 +21,11 @@
.Op Fl c Ar string
.Op Fl s Ar string
.Op Ar
+.Nm sha384
+.Op Fl pqrtx
+.Op Fl c Ar string
+.Op Fl s Ar string
+.Op Ar
.Nm sha512
.Op Fl pqrtx
.Op Fl c Ar string
@@ -33,7 +38,7 @@
.Op Ar
.Sh DESCRIPTION
The
-.Nm md5 , sha1 , sha256 , sha512
+.Nm md5 , sha1 , sha256 , sha384 , sha512
and
.Nm rmd160
utilities take as input a message of arbitrary length and produce as
@@ -46,7 +51,7 @@ It is conjectured that it is computationally infeasible to
produce two messages having the same message digest, or to produce any
message having a given prespecified target message digest.
The
-.Tn MD5 , SHA-1 , SHA-256 , SHA-512
+.Tn MD5 , SHA-1 , SHA-256 , SHA-384 , SHA-512
and
.Tn RIPEMD-160
algorithms are intended for digital signature applications, where a
@@ -123,6 +128,7 @@ option.
.Xr ripemd 3 ,
.Xr sha 3 ,
.Xr sha256 3 ,
+.Xr sha384 3 ,
.Xr sha512 3
.Rs
.%A R. Rivest
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index f4c56ac..1172f25 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$");
#include <ripemd.h>
#include <sha.h>
#include <sha256.h>
+#include <sha384.h>
#include <sha512.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,6 +56,7 @@ typedef char *(DIGEST_End)(void *, char *);
extern const char *MD5TestOutput[MDTESTCOUNT];
extern const char *SHA1_TestOutput[MDTESTCOUNT];
extern const char *SHA256_TestOutput[MDTESTCOUNT];
+extern const char *SHA384_TestOutput[MDTESTCOUNT];
extern const char *SHA512_TestOutput[MDTESTCOUNT];
extern const char *RIPEMD160_TestOutput[MDTESTCOUNT];
@@ -80,6 +82,7 @@ typedef union {
MD5_CTX md5;
SHA1_CTX sha1;
SHA256_CTX sha256;
+ SHA384_CTX sha384;
SHA512_CTX sha512;
RIPEMD160_CTX ripemd160;
} DIGEST_CTX;
@@ -101,6 +104,9 @@ static const struct Algorithm_t Algorithm[] = {
{ "sha256", "SHA256", &SHA256_TestOutput, (DIGEST_Init*)&SHA256_Init,
(DIGEST_Update*)&SHA256_Update, (DIGEST_End*)&SHA256_End,
&SHA256_Data, &SHA256_File },
+ { "sha384", "SHA384", &SHA384_TestOutput, (DIGEST_Init*)&SHA384_Init,
+ (DIGEST_Update*)&SHA384_Update, (DIGEST_End*)&SHA384_End,
+ &SHA384_Data, &SHA384_File },
{ "sha512", "SHA512", &SHA512_TestOutput, (DIGEST_Init*)&SHA512_Init,
(DIGEST_Update*)&SHA512_Update, (DIGEST_End*)&SHA512_End,
&SHA512_Data, &SHA512_File },
@@ -327,6 +333,17 @@ const char *SHA256_TestOutput[MDTESTCOUNT] = {
"e6eae09f10ad4122a0e2a4075761d185a272ebd9f5aa489e998ff2f09cbfdd9f"
};
+const char *SHA384_TestOutput[MDTESTCOUNT] = {
+ "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b",
+ "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31",
+ "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7",
+ "473ed35167ec1f5d8e550368a3db39be54639f828868e9454c239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5",
+ "feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4",
+ "1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84",
+ "b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026",
+ "99428d401bf4abcd4ee0695248c9858b7503853acfae21a9cffa7855f46d1395ef38596fcd06d5a8c32d41a839cc5dfb"
+};
+
const char *SHA512_TestOutput[MDTESTCOUNT] = {
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75",
OpenPOWER on IntegriCloud