diff options
| author | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
|---|---|---|
| committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
| commit | 3b8f08459569bf0faa21473e5cec2491e95c9349 (patch) | |
| tree | 80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /lib/libmd | |
| parent | 9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff) | |
| parent | b2ba55951383498f252746f618d513139da06e8e (diff) | |
Notes
Diffstat (limited to 'lib/libmd')
| -rw-r--r-- | lib/libmd/Makefile | 2 | ||||
| -rw-r--r-- | lib/libmd/ripemd.3 | 3 | ||||
| -rw-r--r-- | lib/libmd/sha.3 | 3 | ||||
| -rw-r--r-- | lib/libmd/sha256.3 | 3 | ||||
| -rw-r--r-- | lib/libmd/sha256.h | 2 | ||||
| -rw-r--r-- | lib/libmd/sha256c.c | 17 | ||||
| -rw-r--r-- | lib/libmd/sha512.3 | 3 |
7 files changed, 13 insertions, 20 deletions
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile index d0fe7054fa4db..727fd86217169 100644 --- a/lib/libmd/Makefile +++ b/lib/libmd/Makefile @@ -43,7 +43,7 @@ CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \ sha256.ref sha256hl.c sha512.ref sha512hl.c CFLAGS+= -I${.CURDIR} -.PATH: ${.CURDIR}/${MACHINE_ARCH} +.PATH: ${.CURDIR}/${MACHINE_ARCH} ${.CURDIR}/../../sys/crypto/sha2 .if exists(${MACHINE_ARCH}/sha.S) SRCS+= sha.S diff --git a/lib/libmd/ripemd.3 b/lib/libmd/ripemd.3 index 6c2f21c79ae3c..2c9d2d3c8cc3a 100644 --- a/lib/libmd/ripemd.3 +++ b/lib/libmd/ripemd.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd February 26, 1999 +.Dd March 28, 2014 .Dt RIPEMD 3 .Os .Sh NAME @@ -123,7 +123,6 @@ If the .Fa buf argument is non-null it must point to at least 41 characters of buffer space. .Sh SEE ALSO -.Xr md2 3 , .Xr md4 3 , .Xr md5 3 , .Xr sha 3 diff --git a/lib/libmd/sha.3 b/lib/libmd/sha.3 index f4e2f192b5395..fe5c339d15db6 100644 --- a/lib/libmd/sha.3 +++ b/lib/libmd/sha.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd February 25, 1999 +.Dd March 28, 2014 .Dt SHA 3 .Os .Sh NAME @@ -154,7 +154,6 @@ If the .Fa buf argument is non-null it must point to at least 41 characters of buffer space. .Sh SEE ALSO -.Xr md2 3 , .Xr md4 3 , .Xr md5 3 , .Xr ripemd 3 , diff --git a/lib/libmd/sha256.3 b/lib/libmd/sha256.3 index f40e6dfd8b4c8..6117e70987b50 100644 --- a/lib/libmd/sha256.3 +++ b/lib/libmd/sha256.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd September 14, 2005 +.Dd March 28, 2014 .Dt SHA256 3 .Os .Sh NAME @@ -120,7 +120,6 @@ If the .Fa buf argument is non-null it must point to at least 65 characters of buffer space. .Sh SEE ALSO -.Xr md2 3 , .Xr md4 3 , .Xr md5 3 , .Xr ripemd 3 , diff --git a/lib/libmd/sha256.h b/lib/libmd/sha256.h index ce51787a737ea..1b6a4f4c57557 100644 --- a/lib/libmd/sha256.h +++ b/lib/libmd/sha256.h @@ -33,7 +33,7 @@ typedef struct SHA256Context { uint32_t state[8]; - uint32_t count[2]; + uint64_t count; unsigned char buf[64]; } SHA256_CTX; diff --git a/lib/libmd/sha256c.c b/lib/libmd/sha256c.c index c95fd318a5aa5..76cec8ec3815e 100644 --- a/lib/libmd/sha256c.c +++ b/lib/libmd/sha256c.c @@ -208,10 +208,10 @@ SHA256_Pad(SHA256_CTX * ctx) * Convert length to a vector of bytes -- we do this now rather * than later because the length will change after we pad. */ - be32enc_vect(len, ctx->count, 8); + be64enc(len, ctx->count); /* Add 1--64 bytes so that the resulting length is 56 mod 64 */ - r = (ctx->count[1] >> 3) & 0x3f; + r = (ctx->count >> 3) & 0x3f; plen = (r < 56) ? (56 - r) : (120 - r); SHA256_Update(ctx, PAD, (size_t)plen); @@ -225,7 +225,7 @@ SHA256_Init(SHA256_CTX * ctx) { /* Zero bits processed so far */ - ctx->count[0] = ctx->count[1] = 0; + ctx->count = 0; /* Magic initialization constants */ ctx->state[0] = 0x6A09E667; @@ -242,21 +242,18 @@ SHA256_Init(SHA256_CTX * ctx) void SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len) { - uint32_t bitlen[2]; + uint64_t bitlen; uint32_t r; const unsigned char *src = in; /* Number of bytes left in the buffer from previous updates */ - r = (ctx->count[1] >> 3) & 0x3f; + r = (ctx->count >> 3) & 0x3f; /* Convert the length into a number of bits */ - bitlen[1] = ((uint32_t)len) << 3; - bitlen[0] = (uint32_t)(len >> 29); + bitlen = len << 3; /* Update number of bits */ - if ((ctx->count[1] += bitlen[1]) < bitlen[1]) - ctx->count[0]++; - ctx->count[0] += bitlen[0]; + ctx->count += bitlen; /* Handle the case where we don't need to perform any transforms */ if (len < 64 - r) { diff --git a/lib/libmd/sha512.3 b/lib/libmd/sha512.3 index 953ee25539a70..bcb52522088a0 100644 --- a/lib/libmd/sha512.3 +++ b/lib/libmd/sha512.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd April 1, 2011 +.Dd March 28, 2014 .Dt SHA512 3 .Os .Sh NAME @@ -120,7 +120,6 @@ If the .Fa buf argument is non-null it must point to at least 65 characters of buffer space. .Sh SEE ALSO -.Xr md2 3 , .Xr md4 3 , .Xr md5 3 , .Xr ripemd 3 , |
