• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

sha1.h

Go to the documentation of this file.
00001 /* Declarations of functions and data types used for SHA1 sum
00002    library functions.
00003    Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009, 2010 Free Software
00004    Foundation, Inc.
00005 
00006    This program is free software; you can redistribute it and/or modify it
00007    under the terms of the GNU General Public License as published by the
00008    Free Software Foundation; either version 2, or (at your option) any
00009    later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software Foundation,
00018    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00019 
00020 #ifndef SHA1_H
00021 # define SHA1_H 1
00022 
00023 # include <stdio.h>
00024 
00025 #ifndef _MSC_VER
00026 # include <stdint.h>
00027 #else
00028 typedef unsigned int uint32_t;
00029 #define inline __inline
00030 #endif
00031 
00032 
00033 # ifdef __cplusplus
00034 extern "C" {
00035 # endif
00036 
00037 #define SHA1_DIGEST_SIZE 20
00038 
00039 /* Structure to save state of computation between the single steps.  */
00040 struct sha1_ctx
00041 {
00042   uint32_t A;
00043   uint32_t B;
00044   uint32_t C;
00045   uint32_t D;
00046   uint32_t E;
00047 
00048   uint32_t total[2];
00049   uint32_t buflen;
00050   uint32_t buffer[32];
00051 };
00052 
00053 
00054 /* Initialize structure containing state of computation. */
00055 extern void sha1_init_ctx (struct sha1_ctx *ctx);
00056 
00057 /* Starting with the result of former calls of this function (or the
00058    initialization function update the context for the next LEN bytes
00059    starting at BUFFER.
00060    It is necessary that LEN is a multiple of 64!!! */
00061 extern void sha1_process_block (const void *buffer, size_t len,
00062                                 struct sha1_ctx *ctx);
00063 
00064 /* Starting with the result of former calls of this function (or the
00065    initialization function update the context for the next LEN bytes
00066    starting at BUFFER.
00067    It is NOT required that LEN is a multiple of 64.  */
00068 extern void sha1_process_bytes (const void *buffer, size_t len,
00069                                 struct sha1_ctx *ctx);
00070 
00071 /* Process the remaining bytes in the buffer and put result from CTX
00072    in first 20 bytes following RESBUF.  The result is always in little
00073    endian byte order, so that a byte-wise output yields to the wanted
00074    ASCII representation of the message digest.  */
00075 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
00076 
00077 
00078 /* Put result from CTX in first 20 bytes following RESBUF.  The result is
00079    always in little endian byte order, so that a byte-wise output yields
00080    to the wanted ASCII representation of the message digest.  */
00081 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
00082 
00083 
00084 /* Compute SHA1 message digest for bytes read from STREAM.  The
00085    resulting message digest number will be written into the 20 bytes
00086    beginning at RESBLOCK.  */
00087 extern int sha1_stream (FILE *stream, void *resblock);
00088 
00089 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
00090    result is always in little endian byte order, so that a byte-wise
00091    output yields to the wanted ASCII representation of the message
00092    digest.  */
00093 extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
00094 
00095 # ifdef __cplusplus
00096 }
00097 # endif
00098 
00099 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1