Files
calc/sha1.h
Landon Curt Noll d89ea78104 prep for calc version 2.14.1.4
Updated COPYING file to indicate that these files are now
covered under "The Unlicense" (see https://unlicense.org):

	sha1.c
	sha1.h
	cal/dotest.cal
	cal/screen.cal

Updated help/credit to match the above changes to COPYING.

Updated CONTRIB-CODE and calc.man to refer to using GitHub pull requests
for contributing to calc (instead of using Email).

Updated BUGS and calc.man to refer to using GitHub issues
for reporting calc bugs (instead of using Email).

Updated QUESTIONS and calc.man to refer to using GitHub issues
for asking calc questions (instead of using Email).

Fixed Makefile.local command example to refer to overriding the
Makefile variable DEBUG (instead of CDEBUG).

Fixed all make chk ASAN warnings under macOS 13.2.1 when calc is compiled
with the following uncommented lines in Makefile.local:

    DEBUG:= -O0 -g
    CFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
    LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
    CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1

Improved how pointers to functions are declared for the builtins
array in func.c to avoid function declarations without a prototype
that is now deprecated in C.

Improved how pointers to functions are declared for the opcodes
array in opcodes.c to avoid function declarations without a prototype

Replaced use of egrep with grep -E in Makefiles.

Fixed cases where variables were set but not used in symbol.c, calc.c,
and the main function in func.c as used by funclist.c.

Added rule name to "DO NOT EDIT -- generated by the Makefile" lines
in constructed files.

Test if <sys/vfs.h> exists and set HAVE_SYS_VFS_H accordingly
in have_sys_vfs.h.  Added HAVE_SYS_VFS_H to allow one to force
this value.

Test if <sys/param.h> exists and set HAVE_SYS_PARAM_H accordingly
in have_sys_param.h.  Added HAVE_SYS_PARAM_H to allow one to force
this value.

Test if <sys/mount.h> exists and set HAVE_SYS_MOUNT_H accordingly
in have_sys_mount.h.  Added HAVE_SYS_MOUNT_H to allow one to force
this value.

Test if the system as the statfs() system call and set HAVE_STATFS
accordingly in have_statfs.h.  Added HAVE_STATFS to allow one
to force this value.

The pseudo_seed() function will also try to call statfs() if
possible and permitted by the HAVE_STATFS value.
2023-03-06 02:17:40 -08:00

87 lines
2.9 KiB
C

/*
* sha1 - new NIST Secure Hash Standard-1 (SHA1)
*
* Written 2 September 1992, Peter C. Gutmann.
*
* This file is not covered under version 2.1 of the GNU LGPL.
* This file is covered under "The unlicense":
*
* https://unlicense.org
*
* In particular:
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
#if !defined(INCLUDE_SHA1_H)
#define INCLUDE_SHA1_H
/* SHA1_CHUNKSIZE must be a power of 2 - fixed value defined by the algorithm */
#define SHA1_CHUNKSIZE (1<<6)
#define SHA1_CHUNKWORDS (SHA1_CHUNKSIZE/sizeof(USB32))
/* SHA1_DIGESTSIZE is a the length of the digest as defined by the algorithm */
#define SHA1_DIGESTSIZE (20)
#define SHA1_DIGESTWORDS (SHA1_DIGESTSIZE/sizeof(USB32))
/* SHA1_LOW - where low 32 bits of 64 bit count is stored during final */
#define SHA1_LOW 15
/* SHA1_HIGH - where high 32 bits of 64 bit count is stored during final */
#define SHA1_HIGH 14
/*
* The structure for storing SHA1 info
*
* We will assume that bit count is a multiple of 8.
*/
typedef struct {
USB32 digest[SHA1_DIGESTWORDS]; /* message digest */
USB32 countLo; /* 64 bit count: bits 3-34 */
USB32 countHi; /* 64 bit count: bits 35-63 */
USB32 datalen; /* length of data in data */
USB32 data[SHA1_CHUNKWORDS]; /* SHA1 chunk buffer */
} SHA1_INFO;
/*
* SHA1COUNT(SHA1_INFO*, USB32) - update the 64 bit count in an SHA1_INFO
*
* We will count bytes and convert to bit count during the final
* transform.
*/
#define SHA1COUNT(sha1info, count) { \
USB32 tmp_countLo; \
tmp_countLo = (sha1info)->countLo; \
if (((sha1info)->countLo += (count)) < tmp_countLo) { \
(sha1info)->countHi++; \
} \
}
#endif /* !INCLUDE_SHA1_H */