Back to index

glibc  2.9
sha512.h
Go to the documentation of this file.
00001 /* Declaration of functions and data types used for SHA512 sum computing
00002    library functions.
00003    Copyright (C) 2007 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _SHA512_H
00022 #define _SHA512_H 1
00023 
00024 #include <limits.h>
00025 #include <stdint.h>
00026 #include <stdio.h>
00027 
00028 
00029 /* Structure to save state of computation between the single steps.  */
00030 struct sha512_ctx
00031 {
00032   uint64_t H[8];
00033 
00034   uint64_t total[2];
00035   uint64_t buflen;
00036   char buffer[256] __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
00037 };
00038 
00039 /* Initialize structure containing state of computation.
00040    (FIPS 180-2: 5.3.3)  */
00041 extern void __sha512_init_ctx (struct sha512_ctx *ctx) __THROW;
00042 
00043 /* Starting with the result of former calls of this function (or the
00044    initialization function update the context for the next LEN bytes
00045    starting at BUFFER.
00046    It is NOT required that LEN is a multiple of 128.  */
00047 extern void __sha512_process_bytes (const void *buffer, size_t len,
00048                                 struct sha512_ctx *ctx) __THROW;
00049 
00050 /* Process the remaining bytes in the buffer and put result from CTX
00051    in first 64 bytes following RESBUF.
00052 
00053    IMPORTANT: On some systems it is required that RESBUF is correctly
00054    aligned for a 64 bits value.  */
00055 extern void *__sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
00056   __THROW;
00057 
00058 #endif /* sha512.h */