Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

md5auth.c File Reference

#include <stdio.h>
#include "md5.h"
#include "libcomm.h"

Functions

void free_authinfo (struct AUTHINFO *destroy)
 Free the memory space which is used by an AUTHINFO structure. More...

int socket_md5auth (int fd, char *netname, char *name, struct AUTHINFO **plocallogin, struct AUTHINFO **premotelogin)
 Do both side authentification. More...

AUTHINFOgetauthinfo (char *netname, char *name)
 Load authentication informations (netname, name, passwd, keyencrypt, keydecrypt) from authfile. More...


Function Documentation

void free_authinfo struct AUTHINFO   destroy
 

Free the memory space which is used by an AUTHINFO structure.

Parameters:
struct  AUTHINFO *) pointer to structure to destroy.

struct AUTHINFO* getauthinfo char *    netname,
char *    name
 

Load authentication informations (netname, name, passwd, keyencrypt, keydecrypt) from authfile.

Parameters:
netname  (char *) specify the network name (may IP). NULL not specified.
name  (char *) specity the login name. NULL not specified.
Returns:
(struct AUTHINFO *) the first entry from authfile which matches network name OR login name. If both values are NULL, the first entry of the authfile is given back.

int socket_md5auth int    fd,
char *    netname,
char *    name,
struct AUTHINFO **    plocallogin,
struct AUTHINFO **    premotelogin
 

Do both side authentification.

This function is usually called just after a socket stream is established. The function must be called on both sides. Both sides following these steps:

1. get auth info ([login] name, passwd) by using getauthinfo() from name or netname for remote login

2. generate random numbers

3. exchange (first send, then receive) login names

4. exchange random numbers

5. calculate md5 checksum over the random numbers (received from other side) and the remote passwd.

6. exchange md5 checksums

7. get auth info from name (received from other side) for local login

8. calculate md5 checksum over the local random numbers and the local passwd.

9. check login -- compare the received md5sum (6.) with the generated one (8.); send acknowledgement

10. receive remote acknowledgement

11. return suitable values

Parameters:
fd  (int) describes the socket on which the authentication has to be done
netname  (char *) use netname to resolve [login] name and passwd of the remote machine (NULL: not specified)
netname  (char *) use [login] name to resolve passwd of the remote machine (NULL: not specified; both NULL use first entry in file, see getauthinfo())
plocallogin  (struct AUTHINFO **) (pointer to pointer to an AUTHINFO struct) in this (double pointed) struct the local authinfo will be loaded, if the parameter is not null.
premotelogin  (struct AUTHINFO **) in this (double pointed) struct the remote authinfo will be loaded, if the parameter is not null.
Returns:
(int) 0: Authentication/Login OK; -1: remote login error; -2: login error on both sides; -3: local login error; -4: other (network) error; -5: cannot load remote auth info; -6: cannot load local auth info;


Generated on Thu Feb 17 10:17:23 2005 for FinalYearProject,A.Hofmeier:CommunicationLibrary by doxygen1.2.15