Blame lib/sha1.h

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