X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fmd5.c;h=f4f93fff818bfdfb1e7c1c35d86fb6d1fa735494;hb=c035e8417b7d1ff3df7d95af3a7e34092912db96;hp=4672deae85063288f1e083c1992eff7ca5a80c59;hpb=30efcc2bae6e7968b1c87f9cb6dc29404232e08a;p=vlc diff --git a/src/misc/md5.c b/src/misc/md5.c index 4672deae85..f4f93fff81 100644 --- a/src/misc/md5.c +++ b/src/misc/md5.c @@ -1,7 +1,7 @@ /***************************************************************************** * md5.c: not so strong MD5 hashing ***************************************************************************** - * Copyright (C) 2004-2005 VideoLAN + * Copyright (C) 2004-2005 the VideoLAN team * $Id$ * * Authors: Jon Lech Johansen @@ -19,12 +19,17 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include -#include -#include "vlc_md5.h" + +#include +#include #ifdef WORDS_BIGENDIAN /***************************************************************************** @@ -53,9 +58,9 @@ static inline void Reverse( uint32_t *p_buffer, int n ) ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /***************************************************************************** - * Digest: update the MD5 digest with 64 bytes of data + * DigestMD5: update the MD5 digest with 64 bytes of data *****************************************************************************/ -void Digest( struct md5_s *p_md5, uint32_t *p_input ) +static void DigestMD5( struct md5_s *p_md5, uint32_t *p_input ) { uint32_t a, b, c, d; @@ -159,10 +164,10 @@ void InitMD5( struct md5_s *p_md5 ) /***************************************************************************** * AddMD5: add i_len bytes to an MD5 message *****************************************************************************/ -void AddMD5( struct md5_s *p_md5, const uint8_t *p_src, uint32_t i_len ) +void AddMD5( struct md5_s *p_md5, const void *p_src, size_t i_len ) { unsigned int i_current; /* Current bytes in the spare buffer */ - unsigned int i_offset = 0; + size_t i_offset = 0; i_current = (p_md5->i_bits / 8) & 63; @@ -174,7 +179,7 @@ void AddMD5( struct md5_s *p_md5, const uint8_t *p_src, uint32_t i_len ) { memcpy( ((uint8_t *)p_md5->p_data) + i_current, p_src, (64 - i_current) ); - Digest( p_md5, p_md5->p_data ); + DigestMD5( p_md5, p_md5->p_data ); i_offset += (64 - i_current); i_len -= (64 - i_current); @@ -185,14 +190,15 @@ void AddMD5( struct md5_s *p_md5, const uint8_t *p_src, uint32_t i_len ) while( i_len >= 64 ) { uint32_t p_tmp[ 16 ]; - memcpy( p_tmp, p_src + i_offset, 64 ); - Digest( p_md5, p_tmp ); + memcpy( p_tmp, ((const uint8_t *)p_src) + i_offset, 64 ); + DigestMD5( p_md5, p_tmp ); i_offset += 64; i_len -= 64; } /* Copy our remaining data to the message's spare buffer */ - memcpy( ((uint8_t *)p_md5->p_data) + i_current, p_src + i_offset, i_len ); + memcpy( ((uint8_t *)p_md5->p_data) + i_current, + ((const uint8_t *)p_src) + i_offset, i_len ); } /***************************************************************************** @@ -217,7 +223,7 @@ void EndMD5( struct md5_s *p_md5 ) if( i_current > 56 ) { memset( ((uint8_t *)p_md5->p_data) + i_current, 0, (64 - i_current) ); - Digest( p_md5, p_md5->p_data ); + DigestMD5( p_md5, p_md5->p_data ); i_current = 0; } @@ -228,7 +234,7 @@ void EndMD5( struct md5_s *p_md5 ) p_md5->p_data[ 15 ] = (p_md5->i_bits >> 32); REVERSE( &p_md5->p_data[ 14 ], 2 ); - Digest( p_md5, p_md5->p_data ); + DigestMD5( p_md5, p_md5->p_data ); }