Whole document tree
    

Whole document tree

Using MD5 for Authentication

17.16. Using MD5 for Authentication

LPRng has built-in support for using MD5 digests as an authentication method. The implementation is provided as an example of how to add user level authentication into the LPRng system.

The method used to do authentication is very simple. Each user has a file containing a set of keys that are used to salt an md5 hash. The information being transferred has its md5 checksum calculated using this salt, and is then transferred to the destination, along with the md5 hash result. At the destination the server will get the user id, obtain the salt value from a key file, and then calculate the md5 hash value. If the two are in agreement, authentication is successful.

The keyfile used for md5 authentication contains an id followed by a text string whose binary value is used as a hash key:

    id1=key
    id2=key
    
    Example:
    
    lpr@h2=tadf79asd%^1asdf
    lpr@h1=fdfa%$^&^%$


17.16.1. Printcap Entries

Options used:

  • auth=md5use MD5 authentication

  • auth_forward=md5forward using MD5 authentication

  • md5_id=id for server

  • md5_forward_id=id for server

  • md5_server_keyfile=server keyfile



Example printcap entry:

    pr:
        :lp=pr@wayoff
        :auth=md5
        :md5_id=lpr@wayoff.com
    pr:server
        :auth_forward=md5
        :md5_id=lpr@wayoff.com
        :md5_server_keyfile
        :md5_forward_id=lpr@faroff.com


The md5_id value is used by the client to obtain a hash key that is used to salt the md5 calculation for client to server transfers. The md5_forward_id value is used by the server to obtain a hash key that is used to salt the md5 calculation for server to server transfers.

The md5_server_keyfile contains the keys of users; the id sent as the connection information is used to obtain the key from the file.

To set up md5 authentication, all that is needed is the following.

  • For each user generate a key and place it in the server keyfile. This file should have the form:

        user1@host1=asdfasdfadf
        user2@host2=a8789087asddasdf
    


  • Assign a key to the server, and set its printcap entry to this key.

        pr:
            :lp=pr@wayoff
            :auth=md5
            :md5_id=lpr@wayoff.com
    


  • For each user, create a user key file with the following format:

        lpr@wayoff = user1@host1 asdfasdfadf
    
    The first entry corresponds to the md5_id value in the printcap. The second field is the AUTHUSER value supplied to the server and which will be used to look up the key in the servers key file. Finally, the last field is the salt value for the md5 calculation.



17.16.2. User Environment Variables and Files

Options used:

  • MD5KEYFILE=5location of user keyfile



The MD5KEYFILE environment variable contains the path to the user keytab file.