Commit 51000521 authored by Paul Eggert's avatar Paul Eggert
Browse files

Merge from trunk.

parents b79e8648 ddb7ffee
2011-06-21 Leo Liu <sdl.web@gmail.com>
* m4/sha256.m4:
* m4/sha512.m4:
* m4/gl-comp.m4:
* lib/u64.h:
* lib/sha256.c:
* lib/sha256.h:
* lib/sha512.c:
* lib/sha512.h:
* lib/makefile.w32-in (GNULIBOBJS):
* lib/gnulib.mk:
* Makefile.in (GNULIB_MODULES): Add crypto/sha256 and
crypto/sha512 modules from gnulib.
2011-06-19 Paul Eggert <eggert@cs.ucla.edu>
* lib/unistd.in.h, m4/getloadavg.m4: Merge from gnulib.
......
......@@ -332,8 +332,8 @@ DOS_gnulib_comp.m4 = gl-comp.m4
# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
# as per $(gnulib_srcdir)/DEPENDENCIES.
GNULIB_MODULES = \
careadlinkat crypto/md5 crypto/sha1 dtoastr filemode getloadavg \
getopt-gnu ignore-value intprops lstat mktime readlink \
careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \
filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink \
socklen stdarg stdio strftime strtoumax symlink sys_stat
GNULIB_TOOL_FLAGS = \
--conditional-dependencies --import --no-changelog --no-vc-files \
......
......@@ -24,7 +24,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 crypto/sha1 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
......@@ -59,7 +59,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lstat.m4 \
$(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/mktime.m4 \
$(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/readlink.m4 \
$(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/socklen.m4 \
$(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/sha256.m4 \
$(top_srcdir)/m4/sha512.m4 $(top_srcdir)/m4/socklen.m4 \
$(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \
$(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \
$(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
......@@ -82,11 +83,12 @@ ARFLAGS = cru
libgnu_a_AR = $(AR) $(ARFLAGS)
am__DEPENDENCIES_1 =
am__libgnu_a_SOURCES_DIST = allocator.c careadlinkat.c md5.c sha1.c \
dtoastr.c filemode.c gettext.h strftime.c
sha256.c sha512.c dtoastr.c filemode.c gettext.h strftime.c
am__objects_1 =
am_libgnu_a_OBJECTS = allocator.$(OBJEXT) careadlinkat.$(OBJEXT) \
md5.$(OBJEXT) sha1.$(OBJEXT) dtoastr.$(OBJEXT) \
filemode.$(OBJEXT) $(am__objects_1) strftime.$(OBJEXT)
md5.$(OBJEXT) sha1.$(OBJEXT) sha256.$(OBJEXT) sha512.$(OBJEXT) \
dtoastr.$(OBJEXT) filemode.$(OBJEXT) $(am__objects_1) \
strftime.$(OBJEXT)
libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
......@@ -734,14 +736,14 @@ BUILT_SOURCES = arg-nonnull.h c++defs.h $(GETOPT_H) inttypes.h \
$(STDARG_H) $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h \
stdlib.h sys/stat.h time.h unistd.h warn-on-use.h
EXTRA_DIST = allocator.h $(top_srcdir)/./arg-nonnull.h \
$(top_srcdir)/./c++defs.h careadlinkat.h md5.h sha1.h \
dosname.h ftoastr.c ftoastr.h filemode.h getloadavg.c getopt.c \
getopt.in.h getopt1.c getopt_int.h ignore-value.h intprops.h \
inttypes.in.h lstat.c mktime-internal.h mktime.c readlink.c \
stat.c stdarg.in.h stdbool.in.h stddef.in.h stdint.in.h \
stdio.in.h stdlib.in.h strftime.h strtol.c strtoul.c \
strtoull.c strtoimax.c strtoumax.c symlink.c sys_stat.in.h \
time.in.h time_r.c unistd.in.h verify.h \
$(top_srcdir)/./c++defs.h careadlinkat.h md5.h sha1.h sha256.h \
sha512.h dosname.h ftoastr.c ftoastr.h filemode.h getloadavg.c \
getopt.c getopt.in.h getopt1.c getopt_int.h ignore-value.h \
intprops.h inttypes.in.h lstat.c mktime-internal.h mktime.c \
readlink.c stat.c stdarg.in.h stdbool.in.h stddef.in.h \
stdint.in.h stdio.in.h stdlib.in.h strftime.h strtol.c \
strtoul.c strtoull.c strtoimax.c strtoumax.c symlink.c \
sys_stat.in.h time.in.h time_r.c u64.h unistd.in.h verify.h \
$(top_srcdir)/./warn-on-use.h
MOSTLYCLEANDIRS = sys
MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
......@@ -752,8 +754,8 @@ MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
unistd.h unistd.h-t warn-on-use.h warn-on-use.h-t
noinst_LIBRARIES = libgnu.a
DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
libgnu_a_SOURCES = allocator.c careadlinkat.c md5.c sha1.c dtoastr.c \
filemode.c $(am__append_1) strftime.c
libgnu_a_SOURCES = allocator.c careadlinkat.c md5.c sha1.c sha256.c \
sha512.c dtoastr.c filemode.c $(am__append_1) strftime.c
libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES = ftoastr.c getloadavg.c getopt.c getopt1.c \
......@@ -824,6 +826,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlink.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha256.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha512.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strftime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoimax.Po@am__quote@
......
......@@ -1001,6 +1001,8 @@ m4_include([m4/mktime.m4])
m4_include([m4/multiarch.m4])
m4_include([m4/readlink.m4])
m4_include([m4/sha1.m4])
m4_include([m4/sha256.m4])
m4_include([m4/sha512.m4])
m4_include([m4/socklen.m4])
m4_include([m4/ssize_t.m4])
m4_include([m4/st_dm_mode.m4])
......
......@@ -6541,6 +6541,8 @@ esac
# Code from module careadlinkat:
# Code from module crypto/md5:
# Code from module crypto/sha1:
# Code from module crypto/sha256:
# Code from module crypto/sha512:
# Code from module dosname:
# Code from module dtoastr:
# Code from module extensions:
......@@ -6575,6 +6577,7 @@ esac
# Code from module sys_stat:
# Code from module time:
# Code from module time_r:
# Code from module u64:
# Code from module unistd:
# Code from module verify:
# Code from module warn-on-use:
......@@ -16695,6 +16698,14 @@ fi
 
 
 
# Persuade glibc <stdlib.h> to declare getloadavg().
 
 
......@@ -18575,6 +18586,7 @@ fi
 
 
 
if test $gl_cv_have_include_next = yes; then
gl_cv_next_unistd_h='<'unistd.h'>'
else
......
2011-06-21 Leo Liu <sdl.web@gmail.com>
* NEWS: Mention the new primtive secure-hash.
2011-06-14 Chong Yidong <cyd@stupidchicken.com>
* themes/dichromacy-theme.el: New theme.
......
......@@ -109,6 +109,26 @@ and pops down the *Completions* buffer accordingly.
** auto-mode-case-fold is now enabled by default.
** smtpmail changes
** smtpmail has been largely rewritten to upgrade to STARTTLS if
possible, and uses the auth-source framework for getting credentials.
The rewrite should be largely compatible with previous versions of
smtpmail, but there are two major incompatibilities:
** `smtpmail-auth-credentials' no longer exists. That variable could
be either ~/.authinfo (in which case you're fine -- you won't see any
difference), but if it were a direct list of user names and passwords,
you will be prompted for the user name and the password instead, and
they will then be saved to ~/.authinfo.
** Similarly, if you had `smtpmail-starttls-credentials' set, then
then you need to put
machine smtp.whatever.foo port 25 key "~/.my_smtp_tls.key" cert "~/.my_smtp_tls.cert"
in your ~/.authinfo file instead.
** Internationalization changes
+++
......@@ -305,10 +325,16 @@ If you need it, feedmail.el ought to provide a superset of the functionality.
** The variable `focus-follows-mouse' now always defaults to nil.
** Function `sha1' is now implemented in C for speed.
** New primitive `secure-hash' that supports many secure hash algorithms
including md5, sha-1 and sha-2 (sha-224, sha-256, sha-384 and sha-512).
The elisp implementation sha1.el is removed. Feature sha1 is provided
by default.
** Menu-bar changes
*** `menu-bar-select-buffer-function' lets you choose another operation
instead of `switch-to-buffer' when selecting an item in the Buffers menu.
* Editing Changes in Emacs 24.1
......
......@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 crypto/sha1 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat
MOSTLYCLEANFILES += core *.stackdump
......@@ -101,6 +101,22 @@ EXTRA_DIST += sha1.h
## end gnulib module crypto/sha1
## begin gnulib module crypto/sha256
libgnu_a_SOURCES += sha256.c
EXTRA_DIST += sha256.h
## end gnulib module crypto/sha256
## begin gnulib module crypto/sha512
libgnu_a_SOURCES += sha512.c
EXTRA_DIST += sha512.h
## end gnulib module crypto/sha512
## begin gnulib module dosname
if gl_GNULIB_ENABLED_dosname
......@@ -759,6 +775,13 @@ EXTRA_libgnu_a_SOURCES += time_r.c
## end gnulib module time_r
## begin gnulib module u64
EXTRA_DIST += u64.h
## end gnulib module u64
## begin gnulib module unistd
BUILT_SOURCES += unistd.h
......
......@@ -30,6 +30,8 @@ GNULIBOBJS = $(BLD)/dtoastr.$(O) \
$(BLD)/time_r.$(O) \
$(BLD)/md5.$(O) \
$(BLD)/sha1.$(O) \
$(BLD)/sha256.$(O) \
$(BLD)/sha512.$(O) \
$(BLD)/filemode.$(O)
#
......@@ -120,6 +122,24 @@ $(BLD)/sha1.$(O) : \
$(EMACS_ROOT)/src/m/intel386.h \
$(EMACS_ROOT)/src/config.h
$(BLD)/sha256.$(O) : \
$(SRC)/sha256.c \
$(SRC)/sha256.h \
$(EMACS_ROOT)/nt/inc/stdint.h \
$(EMACS_ROOT)/nt/inc/sys/stat.h \
$(EMACS_ROOT)/src/s/ms-w32.h \
$(EMACS_ROOT)/src/m/intel386.h \
$(EMACS_ROOT)/src/config.h
$(BLD)/sha512.$(O) : \
$(SRC)/sha512.c \
$(SRC)/sha512.h \
$(EMACS_ROOT)/nt/inc/stdint.h \
$(EMACS_ROOT)/nt/inc/sys/stat.h \
$(EMACS_ROOT)/src/s/ms-w32.h \
$(EMACS_ROOT)/src/m/intel386.h \
$(EMACS_ROOT)/src/config.h
$(BLD)/filemode.$(O) : \
$(SRC)/filemode.c \
$(SRC)/filemode.h \
......
/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
memory blocks according to the NIST specification FIPS-180-2.
Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by David Madore, considerably copypasting from
Scott G. Miller's sha1.c
*/
#include <config.h>
#include "sha256.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
#ifdef WORDS_BIGENDIAN
# define SWAP(n) (n)
#else
# define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
#endif
#define BLOCKSIZE 32768
#if BLOCKSIZE % 64 != 0
# error "invalid BLOCKSIZE"
#endif
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. */
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/*
Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
intializes it to the start constants of the SHA256 algorithm. This
must be called before using hash in the call to sha256_hash
*/
void
sha256_init_ctx (struct sha256_ctx *ctx)
{
ctx->state[0] = 0x6a09e667UL;
ctx->state[1] = 0xbb67ae85UL;
ctx->state[2] = 0x3c6ef372UL;
ctx->state[3] = 0xa54ff53aUL;
ctx->state[4] = 0x510e527fUL;
ctx->state[5] = 0x9b05688cUL;
ctx->state[6] = 0x1f83d9abUL;
ctx->state[7] = 0x5be0cd19UL;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
void
sha224_init_ctx (struct sha256_ctx *ctx)
{
ctx->state[0] = 0xc1059ed8UL;
ctx->state[1] = 0x367cd507UL;
ctx->state[2] = 0x3070dd17UL;
ctx->state[3] = 0xf70e5939UL;
ctx->state[4] = 0xffc00b31UL;
ctx->state[5] = 0x68581511UL;
ctx->state[6] = 0x64f98fa7UL;
ctx->state[7] = 0xbefa4fa4UL;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
/* Copy the value from v into the memory location pointed to by *cp,
If your architecture allows unaligned access this is equivalent to
* (uint32_t *) cp = v */
static inline void
set_uint32 (char *cp, uint32_t v)
{
memcpy (cp, &v, sizeof v);
}
/* Put result from CTX in first 32 bytes following RESBUF. The result
must be in little endian byte order. */
void *
sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 8; i++)
set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
}
void *
sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 7; i++)
set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF. */
static void
sha256_conclude_ctx (struct sha256_ctx *ctx)
{
/* Take yet unprocessed bytes into account. */
size_t bytes = ctx->buflen;
size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
/* Now count remaining bytes. */
ctx->total[0] += bytes;
if (ctx->total[0] < bytes)
++ctx->total[1];
/* Put the 64-bit file length in *bits* at the end of the buffer.
Use set_uint32 rather than a simple assignment, to avoid risk of
unaligned access. */
set_uint32 ((char *) &ctx->buffer[size - 2],
SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
set_uint32 ((char *) &ctx->buffer[size - 1],
SWAP (ctx->total[0] << 3));
memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
/* Process last bytes. */
sha256_process_block (ctx->buffer, size * 4, ctx);
}
void *
sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
{
sha256_conclude_ctx (ctx);
return sha256_read_ctx (ctx, resbuf);
}
void *
sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
{
sha256_conclude_ctx (ctx);
return sha224_read_ctx (ctx, resbuf);
}
/* Compute SHA256 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 32 bytes
beginning at RESBLOCK. */
int
sha256_stream (FILE *stream, void *resblock)
{
struct sha256_ctx ctx;
size_t sum;
char *buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
/* Initialize the computation context. */
sha256_init_ctx (&ctx);
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
while (1)
{
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
sum += n;
if (sum == BLOCKSIZE)
break;
if (n == 0)
{
/* Check for the error flag IFF N == 0, so that we don't
exit the loop after a partial read due to e.g., EAGAIN
or EWOULDBLOCK. */
if (ferror (stream))
{
free (buffer);
return 1;
}
goto process_partial_block;
}
/* We've read at least one byte, so ignore errors. But always
check for EOF, since feof may be true even though N > 0.
Otherwise, we could end up calling fread after EOF. */
if (feof (stream))
goto process_partial_block;
}
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
sha256_process_block (buffer, BLOCKSIZE, &ctx);
}
process_partial_block:;
/* Process any remaining bytes. */
if (sum > 0)
sha256_process_bytes (buffer, sum, &ctx);
/* Construct result in desired memory. */
sha256_finish_ctx (&ctx, resblock);
free (buffer);
return 0;
}
/* FIXME: Avoid code duplication */
int
sha224_stream (FILE *stream, void *resblock)
{
struct sha256_ctx ctx;
size_t sum;
char *buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
/* Initialize the computation context. */
sha224_init_ctx (&ctx);
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
computation function processes the whole buffer so that with the
next round of the loop another block can be read. */
size_t n;
sum = 0;
/* Read block. Take care for partial reads. */
while (1)
{
n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
sum += n;
if (sum == BLOCKSIZE)
break;
if (n == 0)
{
/* Check for the error flag IFF N == 0, so that we don't
exit the loop after a partial read due to e.g., EAGAIN
or EWOULDBLOCK. */
if (ferror (stream))
{
free (buffer);
return 1;
}
goto process_partial_block;
}
/* We've read at least one byte, so ignore errors. But always
check for EOF, since feof may be true even though N > 0.
Otherwise, we could end up calling fread after EOF. */
if (feof (stream))
goto process_partial_block;
}
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
sha256_process_block (buffer, BLOCKSIZE, &ctx);
}
process_partial_block:;
/* Process any remaining bytes. */
if (sum > 0)
sha256_process_bytes (buffer, sum, &ctx);
/* Construct result in desired memory. */
sha224_finish_ctx (&ctx, resblock);
free (buffer);
return 0;
}
/* Compute SHA512 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *
sha256_buffer (const char *buffer, size_t len, void *resblock)
{
struct sha256_ctx ctx;
/* Initialize the computation context. */
sha256_init_ctx (&ctx);
/* Process whole buffer but last len % 64 bytes. */
sha256_process_bytes (buffer, len, &ctx);
/* Put result in desired memory area. */
return sha256_finish_ctx (&ctx, resblock);
}
void *
sha224_buffer (const char *buffer, size_t len, void *resblock)
{
struct sha256_ctx ctx;
/* Initialize the computation context. */
sha224_init_ctx (&ctx);
/* Process whole buffer but last len % 64 bytes. */
sha256_process_bytes (buffer, len, &ctx);
/* Put result in desired memory area. */
return sha224_finish_ctx (&ctx, resblock);
}
void
sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
if (ctx->buflen != 0)
{
size_t left_over = ctx->buflen;
size_t add = 128 - left_over > len ? len : 128 - left_over;