removed the condition in alpm_db_set_servers since FREELIST is NULL safe
[pacman-ng.git] / lib / libalpm / sha2.h
blob887b9c60c074f5ea56cf20b4f48cc40461dec63f
1 /*
2 * SHA-224 and SHA-256 cryptographic hash function
4 * Copyright (C) 2006-2010, Brainspark B.V.
6 * This file is part of PolarSSL (http://www.polarssl.org)
7 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
9 * All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _SHA2_H
25 #define _SHA2_H
27 #include <string.h>
29 /**
30 * \brief SHA-256 context structure
32 typedef struct
34 unsigned long total[2]; /*!< number of bytes processed */
35 unsigned long state[8]; /*!< intermediate digest state */
36 unsigned char buffer[64]; /*!< data block being processed */
38 int is224; /*!< 0 => SHA-256, else SHA-224 */
40 sha2_context;
42 /**
43 * \brief Output = SHA-256( input buffer )
45 * \param input buffer holding the data
46 * \param ilen length of the input data
47 * \param output SHA-224/256 checksum result
48 * \param is224 0 = use SHA256, 1 = use SHA224
50 void sha2( const unsigned char *input, size_t ilen,
51 unsigned char output[32], int is224 );
53 /**
54 * \brief Output = SHA-256( file contents )
56 * \param path input file name
57 * \param output SHA-224/256 checksum result
58 * \param is224 0 = use SHA256, 1 = use SHA224
60 * \return 0 if successful, 1 if fopen failed,
61 * or 2 if fread failed
63 int sha2_file( const char *path, unsigned char output[32], int is224 );
65 #endif /* sha2.h */