libalpm
Arch Linux Package Manager Library
md5.h
Go to the documentation of this file.
00001 /*
00002  *  RFC 1321 compliant MD5 implementation
00003  *
00004  *  Copyright (C) 2006-2010, Brainspark B.V.
00005  *
00006  *  This file is part of PolarSSL (http://www.polarssl.org)
00007  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
00008  *
00009  *  All rights reserved.
00010  *
00011  *  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023  */
00024 #ifndef _MD5_H
00025 #define _MD5_H
00026 
00027 #include <string.h>
00028 
00029 /**
00030  * \brief          MD5 context structure
00031  */
00032 typedef struct
00033 {
00034     unsigned long total[2];     /*!< number of bytes processed  */
00035     unsigned long state[4];     /*!< intermediate digest state  */
00036     unsigned char buffer[64];   /*!< data block being processed */
00037 }
00038 md5_context;
00039 
00040 /**
00041  * \brief          Output = MD5( input buffer )
00042  *
00043  * \param input    buffer holding the  data
00044  * \param ilen     length of the input data
00045  * \param output   MD5 checksum result
00046  */
00047 void md5( const unsigned char *input, size_t ilen, unsigned char output[16] );
00048 
00049 /**
00050  * \brief          Output = MD5( file contents )
00051  *
00052  * \param path     input file name
00053  * \param output   MD5 checksum result
00054  *
00055  * \return         0 if successful, 1 if fopen failed,
00056  *                 or 2 if fread failed
00057  */
00058 int md5_file( const char *path, unsigned char output[16] );
00059 
00060 #endif /* md5.h */