<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content="HTML Tidy, see www.w3.org"> <title>Using MD5 for Authentication</title> <meta name="GENERATOR" content= "Modular DocBook HTML Stylesheet Version 1.71 "> <link rel="HOME" title=" LPRng-HOWTO" href="index.htm"> <link rel="UP" title="Permissions and Authentication " href= "permsref.htm"> <link rel="PREVIOUS" title= "Using Kerberos 4 for Authentication" href="x9264.htm"> <link rel="NEXT" title="Adding Authentication Support" href= "x9357.htm"> </head> <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link= "#0000FF" vlink="#840084" alink="#0000FF"> <div class="NAVHEADER"> <table summary="Header navigation table" width="100%" border= "0" cellpadding="0" cellspacing="0"> <tr> <th colspan="3" align="center">LPRng-HOWTO: 8 Feb 2002 (For LPRng-3.8.6)</th> </tr> <tr> <td width="10%" align="left" valign="bottom"><a href= "x9264.htm" accesskey="P">Prev</a></td> <td width="80%" align="center" valign="bottom">Chapter 17. Permissions and Authentication</td> <td width="10%" align="right" valign="bottom"><a href= "x9357.htm" accesskey="N">Next</a></td> </tr> </table> <hr align="LEFT" width="100%"> </div> <div class="SECT1"> <h1 class="SECT1"><a name="AEN9290">17.16. Using MD5 for Authentication</a></h1> <p><b class="APPLICATION">LPRng</b> 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 <b class= "APPLICATION">LPRng</b> system.</p> <p>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.</p> <p>The keyfile used for md5 authentication contains an id followed by a text string whose binary value is used as a hash key:</p> <div class="INFORMALEXAMPLE"> <a name="AEN9297"></a> <pre class="SCREEN"> id1=key id2=key Example: lpr@h2=tadf79asd%^1asdf lpr@h1=fdfa%$^&^%$ </pre> </div> <br> <br> <div class="SECT2"> <h2 class="SECT2"><a name="AEN9299">17.16.1. Printcap Entries</a></h2> <p>Options used:</p> <ul> <li> <p><tt class="LITERAL">auth=md5</tt><i class= "EMPHASIS">use MD5 authentication</i></p> </li> <li> <p><tt class="LITERAL">auth_forward=md5</tt><i class= "EMPHASIS">forward using MD5 authentication</i></p> </li> <li> <p><tt class="LITERAL">md5_id=</tt><i class= "EMPHASIS">id for server</i></p> </li> <li> <p><tt class="LITERAL">md5_forward_id=</tt><i class= "EMPHASIS">id for server</i></p> </li> <li> <p><tt class="LITERAL">md5_server_keyfile=</tt><i class="EMPHASIS">server keyfile</i></p> </li> </ul> <br> <br> <p>Example printcap entry:</p> <div class="INFORMALEXAMPLE"> <a name="AEN9324"></a> <pre class="SCREEN"> 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 </pre> </div> <br> <br> <p>The <tt class="LITERAL">md5_id</tt> 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 <tt class= "LITERAL">md5_forward_id</tt> value is used by the server to obtain a hash key that is used to salt the md5 calculation for server to server transfers.</p> <p>The <tt class="LITERAL">md5_server_keyfile</tt> contains the keys of users; the id sent as the connection information is used to obtain the key from the file.</p> <p>To set up md5 authentication, all that is needed is the following.</p> <ul> <li> <p>For each user generate a key and place it in the server keyfile. This file should have the form:</p> <div class="INFORMALEXAMPLE"> <a name="AEN9335"></a> <pre class="SCREEN"> user1@host1=asdfasdfadf user2@host2=a8789087asddasdf </pre> </div> <br> <br> </li> <li> <p>Assign a key to the server, and set its printcap entry to this key.</p> <div class="INFORMALEXAMPLE"> <a name="AEN9339"></a> <pre class="SCREEN"> pr: :lp=pr@wayoff :auth=md5 :md5_id=lpr@wayoff.com </pre> </div> <br> <br> </li> <li> <p>For each user, create a user key file with the following format:</p> <div class="INFORMALEXAMPLE"> <a name="AEN9343"></a> <pre class="SCREEN"> lpr@wayoff = user1@host1 asdfasdfadf </pre> </div> The first entry corresponds to the <tt class= "LITERAL">md5_id</tt> value in the printcap. The second field is the <span class="ACRONYM">AUTHUSER</span> 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.<br> <br> </li> </ul> <br> <br> </div> <div class="SECT2"> <h2 class="SECT2"><a name="AEN9347">17.16.2. User Environment Variables and Files</a></h2> <p>Options used:</p> <ul> <li> <p><tt class="LITERAL">MD5KEYFILE=5</tt><i class= "EMPHASIS">location of user keyfile</i></p> </li> </ul> <br> <br> <p>The <tt class="LITERAL">MD5KEYFILE</tt> environment variable contains the path to the user keytab file.</p> </div> </div> <div class="NAVFOOTER"> <hr align="LEFT" width="100%"> <table summary="Footer navigation table" width="100%" border= "0" cellpadding="0" cellspacing="0"> <tr> <td width="33%" align="left" valign="top"><a href= "x9264.htm" accesskey="P">Prev</a></td> <td width="34%" align="center" valign="top"><a href= "index.htm" accesskey="H">Home</a></td> <td width="33%" align="right" valign="top"><a href= "x9357.htm" accesskey="N">Next</a></td> </tr> <tr> <td width="33%" align="left" valign="top">Using Kerberos 4 for Authentication</td> <td width="34%" align="center" valign="top"><a href= "permsref.htm" accesskey="U">Up</a></td> <td width="33%" align="right" valign="top">Adding Authentication Support</td> </tr> </table> </div> </body> </html>