Blame lib/sha1.h

Packit 8f70b4
/* Declarations of functions and data types used for SHA1 sum
Packit 8f70b4
   library functions.
Packit 8f70b4
   Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2018 Free Software
Packit 8f70b4
   Foundation, Inc.
Packit 8f70b4
Packit 8f70b4
   This program is free software; you can redistribute it and/or modify it
Packit 8f70b4
   under the terms of the GNU General Public License as published by the
Packit 8f70b4
   Free Software Foundation; either version 3, or (at your option) any
Packit 8f70b4
   later version.
Packit 8f70b4
Packit 8f70b4
   This program is distributed in the hope that it will be useful,
Packit 8f70b4
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
   GNU General Public License for more details.
Packit 8f70b4
Packit 8f70b4
   You should have received a copy of the GNU General Public License
Packit 8f70b4
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit 8f70b4
Packit 8f70b4
#ifndef SHA1_H
Packit 8f70b4
# define SHA1_H 1
Packit 8f70b4
Packit 8f70b4
# include <stdio.h>
Packit 8f70b4
# include <stdint.h>
Packit 8f70b4
Packit 8f70b4
# if HAVE_OPENSSL_SHA1
Packit 8f70b4
#  include <openssl/sha.h>
Packit 8f70b4
# endif
Packit 8f70b4
Packit 8f70b4
# ifdef __cplusplus
Packit 8f70b4
extern "C" {
Packit 8f70b4
# endif
Packit 8f70b4
Packit 8f70b4
#define SHA1_DIGEST_SIZE 20
Packit 8f70b4
Packit 8f70b4
# if HAVE_OPENSSL_SHA1
Packit 8f70b4
#  define GL_OPENSSL_NAME 1
Packit 8f70b4
#  include "gl_openssl.h"
Packit 8f70b4
# else
Packit 8f70b4
/* Structure to save state of computation between the single steps.  */
Packit 8f70b4
struct sha1_ctx
Packit 8f70b4
{
Packit 8f70b4
  uint32_t A;
Packit 8f70b4
  uint32_t B;
Packit 8f70b4
  uint32_t C;
Packit 8f70b4
  uint32_t D;
Packit 8f70b4
  uint32_t E;
Packit 8f70b4
Packit 8f70b4
  uint32_t total[2];
Packit 8f70b4
  uint32_t buflen;     /* ≥ 0, ≤ 128 */
Packit 8f70b4
  uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
/* Initialize structure containing state of computation. */
Packit 8f70b4
extern void sha1_init_ctx (struct sha1_ctx *ctx);
Packit 8f70b4
Packit 8f70b4
/* Starting with the result of former calls of this function (or the
Packit 8f70b4
   initialization function update the context for the next LEN bytes
Packit 8f70b4
   starting at BUFFER.
Packit 8f70b4
   It is necessary that LEN is a multiple of 64!!! */
Packit 8f70b4
extern void sha1_process_block (const void *buffer, size_t len,
Packit 8f70b4
                                struct sha1_ctx *ctx);
Packit 8f70b4
Packit 8f70b4
/* Starting with the result of former calls of this function (or the
Packit 8f70b4
   initialization function update the context for the next LEN bytes
Packit 8f70b4
   starting at BUFFER.
Packit 8f70b4
   It is NOT required that LEN is a multiple of 64.  */
Packit 8f70b4
extern void sha1_process_bytes (const void *buffer, size_t len,
Packit 8f70b4
                                struct sha1_ctx *ctx);
Packit 8f70b4
Packit 8f70b4
/* Process the remaining bytes in the buffer and put result from CTX
Packit 8f70b4
   in first 20 bytes following RESBUF.  The result is always in little
Packit 8f70b4
   endian byte order, so that a byte-wise output yields to the wanted
Packit 8f70b4
   ASCII representation of the message digest.  */
Packit 8f70b4
extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
/* Put result from CTX in first 20 bytes following RESBUF.  The result is
Packit 8f70b4
   always in little endian byte order, so that a byte-wise output yields
Packit 8f70b4
   to the wanted ASCII representation of the message digest.  */
Packit 8f70b4
extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
/* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
Packit 8f70b4
   result is always in little endian byte order, so that a byte-wise
Packit 8f70b4
   output yields to the wanted ASCII representation of the message
Packit 8f70b4
   digest.  */
Packit 8f70b4
extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
Packit 8f70b4
Packit 8f70b4
# endif
Packit 8f70b4
/* Compute SHA1 message digest for bytes read from STREAM.
Packit 8f70b4
   STREAM is an open file stream.  Regular files are handled more efficiently.
Packit 8f70b4
   The contents of STREAM from its current position to its end will be read.
Packit 8f70b4
   The case that the last operation on STREAM was an 'ungetc' is not supported.
Packit 8f70b4
   The resulting message digest number will be written into the 20 bytes
Packit 8f70b4
   beginning at RESBLOCK.  */
Packit 8f70b4
extern int sha1_stream (FILE *stream, void *resblock);
Packit 8f70b4
Packit 8f70b4
Packit 8f70b4
# ifdef __cplusplus
Packit 8f70b4
}
Packit 8f70b4
# endif
Packit 8f70b4
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/*
Packit 8f70b4
 * Hey Emacs!
Packit 8f70b4
 * Local Variables:
Packit 8f70b4
 * coding: utf-8
Packit 8f70b4
 * End:
Packit 8f70b4
 */