Blame lib/md5.h

Packit Service a2489d
/* Declaration of functions and data types used for MD5 sum computing
Packit Service a2489d
   library functions.
Packit Service a2489d
   Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2018 Free Software
Packit Service a2489d
   Foundation, Inc.
Packit Service a2489d
   This file is part of the GNU C Library.
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 _MD5_H
Packit Service a2489d
#define _MD5_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_MD5
Packit Service a2489d
#  include <openssl/md5.h>
Packit Service a2489d
# endif
Packit Service a2489d
Packit Service a2489d
#define MD5_DIGEST_SIZE 16
Packit Service a2489d
#define MD5_BLOCK_SIZE 64
Packit Service a2489d
Packit Service a2489d
#ifndef __GNUC_PREREQ
Packit Service a2489d
# if defined __GNUC__ && defined __GNUC_MINOR__
Packit Service a2489d
#  define __GNUC_PREREQ(maj, min)                                       \
Packit Service a2489d
  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
Packit Service a2489d
# else
Packit Service a2489d
#  define __GNUC_PREREQ(maj, min) 0
Packit Service a2489d
# endif
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
#ifndef __THROW
Packit Service a2489d
# if defined __cplusplus && __GNUC_PREREQ (2,8)
Packit Service a2489d
#  define __THROW       throw ()
Packit Service a2489d
# else
Packit Service a2489d
#  define __THROW
Packit Service a2489d
# endif
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
#ifndef _LIBC
Packit Service a2489d
# define __md5_buffer md5_buffer
Packit Service a2489d
# define __md5_finish_ctx md5_finish_ctx
Packit Service a2489d
# define __md5_init_ctx md5_init_ctx
Packit Service a2489d
# define __md5_process_block md5_process_block
Packit Service a2489d
# define __md5_process_bytes md5_process_bytes
Packit Service a2489d
# define __md5_read_ctx md5_read_ctx
Packit Service a2489d
# define __md5_stream md5_stream
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
# if HAVE_OPENSSL_MD5
Packit Service a2489d
#  define GL_OPENSSL_NAME 5
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 md5_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
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
/*
Packit Service a2489d
 * The following three functions are build up the low level used in
Packit Service a2489d
 * the functions 'md5_stream' and 'md5_buffer'.
Packit Service a2489d
 */
Packit Service a2489d
Packit Service a2489d
/* Initialize structure containing state of computation.
Packit Service a2489d
   (RFC 1321, 3.3: Step 3)  */
Packit Service a2489d
extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
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 __md5_process_block (const void *buffer, size_t len,
Packit Service a2489d
                                 struct md5_ctx *ctx) __THROW;
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 __md5_process_bytes (const void *buffer, size_t len,
Packit Service a2489d
                                 struct md5_ctx *ctx) __THROW;
Packit Service a2489d
Packit Service a2489d
/* Process the remaining bytes in the buffer and put result from CTX
Packit Service a2489d
   in first 16 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 *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/* Put result from CTX in first 16 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 *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/* Compute MD5 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 *__md5_buffer (const char *buffer, size_t len,
Packit Service a2489d
                           void *resblock) __THROW;
Packit Service a2489d
Packit Service a2489d
# endif
Packit Service a2489d
/* Compute MD5 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 16 bytes
Packit Service a2489d
   beginning at RESBLOCK.  */
Packit Service a2489d
extern int __md5_stream (FILE *stream, void *resblock) __THROW;
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 /* md5.h */
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
 */