"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/libjte/sha512.h" (30 Jan 2021, 2326 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sha512.h" see the Fossies "Dox" file reference documentation.

    1 /* Declaration of functions and data types used for SHA512 sum computing
    2    library functions.
    3    Copyright (C) 2007 Free Software Foundation, Inc.
    4 
    5    Copied here from the GNU C Library version 2.7 on the 10 May 2009
    6    by Steve McIntyre <93sam@debian.org>. This code was under GPL v2.1
    7    in glibc, and that license gives us the option to use and
    8    distribute the code under the terms of the GPL v2 instead. I'm
    9    taking that option.
   10 
   11    This program is free software; you can redistribute it and/or modify it
   12    under the terms of the GNU General Public License as published by the
   13    Free Software Foundation; either version 2, or (at your option) any
   14    later version.
   15 
   16    This program is distributed in the hope that it will be useful,
   17    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19    GNU General Public License for more details.
   20 
   21    You should have received a copy of the GNU General Public License
   22    along with this program; if not, write to the Free Software Foundation,
   23    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
   24 
   25 #ifndef _SHA512_H
   26 #define _SHA512_H 1
   27 
   28 #include <limits.h>
   29 
   30 #ifdef HAVE_STDINT_H
   31 #include <stdint.h>
   32 #else
   33 #ifdef HAVE_INTTYPES_H
   34 #include <inttypes.h>
   35 #endif
   36 #endif
   37 
   38 #include <stdio.h>
   39 
   40 
   41 /* Structure to save state of computation between the single steps.  */
   42 struct sha512_ctx
   43 {
   44   uint64_t H[8];
   45 
   46   uint64_t total[2];
   47   uint64_t buflen;
   48   char buffer[256] __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
   49 };
   50 
   51 /* Initialize structure containing state of computation.
   52    (FIPS 180-2: 5.3.3)  */
   53 extern void sha512_init_ctx (struct sha512_ctx *ctx);
   54 
   55 /* Starting with the result of former calls of this function (or the
   56    initialization function update the context for the next LEN bytes
   57    starting at BUFFER.
   58    It is NOT required that LEN is a multiple of 128.  */
   59 extern void sha512_process_bytes (const void *buffer, size_t len,
   60                     struct sha512_ctx *ctx);
   61 
   62 /* Process the remaining bytes in the buffer and put result from CTX
   63    in first 64 bytes following RESBUF.
   64 
   65    IMPORTANT: On some systems it is required that RESBUF is correctly
   66    aligned for a 64 bits value.  */
   67 extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
   68 
   69 #endif /* sha512.h */