21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

xl<br />

Pointer into which the length of the application-specific data is placed.<br />

On success, AX_srv_exchange( ) will return a connected socket descriptor in blocking<br />

mode that you can then use to talk to the client. On failure, an XXLexception will be<br />

raised. The value of the exception will be either AX_CAUTH_ERR if we believe the client<br />

refused our credentials or AX_SAUTH_ERR if we refused the client’s credentials. In both<br />

cases, it is possible that an attacker’s tampering with the data stream caused the<br />

error. On the other hand, it could be that the two parties could not agree on the protocol<br />

version or key size.<br />

With a valid socket descriptor in hand, you can now use the exchanged key to set up<br />

a secure channel, as discussed in Recipe 9.12. When you are finished communicating,<br />

you may simply close the socket descriptor.<br />

Note that whether or not the exchange with the client succeeds, AX_srv_exchange( )<br />

will free the AC_CLIENT object passed into it. If the exchange fails, the socket descriptor<br />

will be closed, and the client will have to reconnect in order to attempt another<br />

exchange.<br />

The client<br />

The client side is a bit less work. We first connect to the server with the following<br />

function:<br />

AX *AX_connect(char *addr, unsigned short port, char *uname, size_t ulen,<br />

char *extra, size_t elen, size_t protocol);<br />

This function has the following arguments:<br />

addr<br />

IP address (or DNS name) of the server as a NULL-terminated string.<br />

port<br />

Port to which we should connect on the remote machine.<br />

uname<br />

Username.<br />

ulen<br />

Length of the username in bytes.<br />

extra<br />

Application-specific data discussed above.<br />

elen<br />

Length of the application-specific data in bytes.<br />

protocol<br />

Indication of the protocol you’re using to connect. As of this writing, the only<br />

valid values are SAX_PROTOCOL_v1 and PAX_PROTOCOL_v1.<br />

Performing Password-Based Authentication and Key Exchange | 427<br />

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

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!