Blame genisoimage/sha1.h

Packit 45fded
/* Declarations of functions and data types used for SHA1 sum
Packit 45fded
   library functions.
Packit 45fded
   Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
Packit 45fded
Packit 45fded
   This program is free software; you can redistribute it and/or modify it
Packit 45fded
   under the terms of the GNU General Public License as published by the
Packit 45fded
   Free Software Foundation; either version 2, or (at your option) any
Packit 45fded
   later version.
Packit 45fded
Packit 45fded
   This program is distributed in the hope that it will be useful,
Packit 45fded
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 45fded
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 45fded
   GNU General Public License for more details.
Packit 45fded
Packit 45fded
   You should have received a copy of the GNU General Public License
Packit 45fded
   along with this program; if not, write to the Free Software Foundation,
Packit 45fded
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
Packit 45fded
Packit 45fded
#ifndef SHA1_H
Packit 45fded
# define SHA1_H 1
Packit 45fded
Packit 45fded
# include <stdio.h>
Packit 45fded
Packit 45fded
typedef unsigned int md5_uint32;
Packit 45fded
Packit 45fded
/* Structure to save state of computation between the single steps.  */
Packit 45fded
struct sha1_ctx
Packit 45fded
{
Packit 45fded
  md5_uint32 A;
Packit 45fded
  md5_uint32 B;
Packit 45fded
  md5_uint32 C;
Packit 45fded
  md5_uint32 D;
Packit 45fded
  md5_uint32 E;
Packit 45fded
Packit 45fded
  md5_uint32 total[2];
Packit 45fded
  md5_uint32 buflen;
Packit 45fded
  char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
Packit 45fded
};
Packit 45fded
Packit 45fded
Packit 45fded
/* Initialize structure containing state of computation. */
Packit 45fded
extern void sha1_init_ctx (struct sha1_ctx *ctx);
Packit 45fded
Packit 45fded
/* Starting with the result of former calls of this function (or the
Packit 45fded
   initialization function update the context for the next LEN bytes
Packit 45fded
   starting at BUFFER.
Packit 45fded
   It is necessary that LEN is a multiple of 64!!! */
Packit 45fded
extern void sha1_process_block (const void *buffer, size_t len,
Packit 45fded
				struct sha1_ctx *ctx);
Packit 45fded
Packit 45fded
/* Starting with the result of former calls of this function (or the
Packit 45fded
   initialization function update the context for the next LEN bytes
Packit 45fded
   starting at BUFFER.
Packit 45fded
   It is NOT required that LEN is a multiple of 64.  */
Packit 45fded
extern void sha1_process_bytes (const void *buffer, size_t len,
Packit 45fded
				struct sha1_ctx *ctx);
Packit 45fded
Packit 45fded
/* Process the remaining bytes in the buffer and put result from CTX
Packit 45fded
   in first 20 bytes following RESBUF.  The result is always in little
Packit 45fded
   endian byte order, so that a byte-wise output yields to the wanted
Packit 45fded
   ASCII representation of the message digest.
Packit 45fded
Packit 45fded
   IMPORTANT: On some systems it is required that RESBUF be correctly
Packit 45fded
   aligned for a 32 bits value.  */
Packit 45fded
extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
Packit 45fded
Packit 45fded
Packit 45fded
/* Put result from CTX in first 20 bytes following RESBUF.  The result is
Packit 45fded
   always in little endian byte order, so that a byte-wise output yields
Packit 45fded
   to the wanted ASCII representation of the message digest.
Packit 45fded
Packit 45fded
   IMPORTANT: On some systems it is required that RESBUF is correctly
Packit 45fded
   aligned for a 32 bits value.  */
Packit 45fded
extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
Packit 45fded
Packit 45fded
Packit 45fded
/* Compute SHA1 message digest for bytes read from STREAM.  The
Packit 45fded
   resulting message digest number will be written into the 20 bytes
Packit 45fded
   beginning at RESBLOCK.  */
Packit 45fded
extern int sha1_stream (FILE *stream, void *resblock);
Packit 45fded
Packit 45fded
/* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
Packit 45fded
   result is always in little endian byte order, so that a byte-wise
Packit 45fded
   output yields to the wanted ASCII representation of the message
Packit 45fded
   digest.  */
Packit 45fded
extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
Packit 45fded
Packit 45fded
#endif