Changeset b79308b for lib/misc.c


Ignore:
Timestamp:
2008-04-14T13:10:53Z (17 years ago)
Author:
ulim <a.sporto+bee@…>
Branches:
master
Children:
0cab388
Parents:
6cac643 (diff), aa31117 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merged in upstream r379 (somewhere after 1.2-3).
Just one trivial conflict in the jabber Makefile, went smoothly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    r6cac643 rb79308b  
    3333#define BITLBEE_CORE
    3434#include "nogaim.h"
     35#include "base64.h"
    3536#include <stdio.h>
    3637#include <stdlib.h>
     
    597598                return sockerr_again();
    598599}
     600
     601/* Returns values: -1 == Failure (base64-decoded to something unexpected)
     602                    0 == Okay
     603                    1 == Password doesn't match the hash. */
     604int md5_verify_password( char *password, char *hash )
     605{
     606        md5_byte_t *pass_dec = NULL;
     607        md5_byte_t pass_md5[16];
     608        md5_state_t md5_state;
     609        int ret, i;
     610       
     611        if( base64_decode( hash, &pass_dec ) != 21 )
     612        {
     613                ret = -1;
     614        }
     615        else
     616        {
     617                md5_init( &md5_state );
     618                md5_append( &md5_state, (md5_byte_t*) password, strlen( password ) );
     619                md5_append( &md5_state, (md5_byte_t*) pass_dec + 16, 5 ); /* Hmmm, salt! */
     620                md5_finish( &md5_state, pass_md5 );
     621               
     622                for( i = 0; i < 16; i ++ )
     623                {
     624                        if( pass_dec[i] != pass_md5[i] )
     625                        {
     626                                ret = 1;
     627                                break;
     628                        }
     629                }
     630               
     631                /* If we reached the end of the loop, it was a match! */
     632                if( i == 16 )
     633                        ret = 0;
     634        }
     635       
     636        g_free( pass_dec );
     637
     638        return ret;
     639}
Note: See TracChangeset for help on using the changeset viewer.