Blame crypt/sha256.h

Packit 6c4009
/* Declaration of functions and data types used for SHA256 sum computing
Packit 6c4009
   library functions.
Packit 6c4009
   Copyright (C) 2007-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _SHA256_H
Packit 6c4009
#define _SHA256_H 1
Packit 6c4009
Packit 6c4009
#include <limits.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <endian.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Structure to save state of computation between the single steps.  */
Packit 6c4009
struct sha256_ctx
Packit 6c4009
{
Packit 6c4009
  uint32_t H[8];
Packit 6c4009
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    uint64_t total64;
Packit 6c4009
#define TOTAL64_low (1 - (BYTE_ORDER == LITTLE_ENDIAN))
Packit 6c4009
#define TOTAL64_high (BYTE_ORDER == LITTLE_ENDIAN)
Packit 6c4009
    uint32_t total[2];
Packit 6c4009
  };
Packit 6c4009
  uint32_t buflen;
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    char buffer[128];
Packit 6c4009
    uint32_t buffer32[32];
Packit 6c4009
    uint64_t buffer64[16];
Packit 6c4009
  };
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Initialize structure containing state of computation.
Packit 6c4009
   (FIPS 180-2: 5.3.2)  */
Packit 6c4009
extern void __sha256_init_ctx (struct sha256_ctx *ctx) __THROW;
Packit 6c4009
Packit 6c4009
/* Starting with the result of former calls of this function (or the
Packit 6c4009
   initialization function update the context for the next LEN bytes
Packit 6c4009
   starting at BUFFER.
Packit 6c4009
   It is NOT required that LEN is a multiple of 64.  */
Packit 6c4009
extern void __sha256_process_bytes (const void *buffer, size_t len,
Packit 6c4009
				    struct sha256_ctx *ctx) __THROW;
Packit 6c4009
Packit 6c4009
/* Process the remaining bytes in the buffer and put result from CTX
Packit 6c4009
   in first 32 bytes following RESBUF.
Packit 6c4009
Packit 6c4009
   IMPORTANT: On some systems it is required that RESBUF is correctly
Packit 6c4009
   aligned for a 32 bits value.  */
Packit 6c4009
extern void *__sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
Packit 6c4009
  __THROW;
Packit 6c4009
Packit 6c4009
#endif /* sha256.h */