21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

API for encryption and decryption, although the number of supported ciphers is considerably<br />

fewer than those provided by other cryptographic protocols. Authentication<br />

yields a cryptographically strong session key that can be used as a key for<br />

encryption.<br />

This recipe works on Unix and Windows with the Heimdal and MIT Kerberos<br />

implementations. The code presented here will not work on Windows systems that<br />

are Kerberos-enabled with the built-in Windows support, because Windows does<br />

not expose the Kerberos API in such a way that the code could be made to work. In<br />

particular, the encryption and decryption functions used in this recipe are not<br />

present on Windows unless you are using either Heimdal or MIT Kerberos. Instead,<br />

you should use CryptoAPI on Windows (see Recipe 5.25).<br />

Discussion<br />

Kerberos provides authentication between clients and servers, communicating over<br />

an established data connection. The Kerberos API provides no support for establishing,<br />

terminating, or passing arbitrary data over a data connection, whether pipes,<br />

sockets, or otherwise. Once its job has been successfully performed, a cryptographically<br />

strong session key that can be used as a key for encryption is “left behind.”<br />

We present a discussion of how to authenticate using Kerberos in Recipe 8.13. In<br />

this recipe, we pick up at the point where Kerberos authentication has completed<br />

successfully. At this point, you’ll be left with at least a krb5_context object and a<br />

krb5_auth_context object. Using these two objects, you can obtain a krb5_keyblock<br />

object that contains the session key by calling krb5_auth_con_getremotesubkey( ).<br />

The prototype for this function is as follows:<br />

krb5_error_code krb5_auth_con_getremotesubkey(krb5_context context,<br />

krb5_auth_context auth_context,<br />

krb5_keyblock **key_block);<br />

Once you have the session key, you can use it for encryption and decryption.<br />

Kerberos supports only a limited number of symmetric ciphers, which may vary<br />

depending on the version of Kerberos that you are using. For maximum portability,<br />

you are limited primarily to DES and 3-key Triple-DES in CBC mode. The key<br />

returned from krb_auth_con_getremotesubkey( ) will have an algorithm already associated<br />

with it, so you don’t even have to choose. As part of the authentication process,<br />

the client and server will negotiate the strongest cipher that both are capable of<br />

supporting, which will (we hope) be Triple-DES (or something stronger) instead of<br />

DES, which is actually rather weak. In fact, if DES is negotiated, you may want to<br />

consider refusing to proceed.<br />

Many different implementations of Kerberos exist today. The most prominent among<br />

the free implementations is the MIT implementation, which is distributed with Darwin<br />

and many Linux distributions. Another popular implementation is the Heimdal<br />

implementation, which is distributed with FreeBSD and OpenBSD. Unfortunately,<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

Using Kerberos Encryption | 471

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!