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.

extra<br />

Additional application-specific information the client passed to the server. You<br />

can use this for whatever purpose you want. For example, you could use this<br />

field to encode the server name the client thinks it’s connecting to, in order to<br />

implement virtual servers.<br />

elen<br />

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

If the user does not exist, you must return 0 from this callback.<br />

The other callback allows you to log errors when a key exchange fails. You do not<br />

have to define this callback. If you do define it, the signature is the same as in the<br />

previous callback, except that it takes an extra parameter of type size_t that encodes<br />

the error, and it does not return anything. As of this writing, there are only two error<br />

conditions that might get reported:<br />

AX_SOCK_ERR<br />

Indicates that a generic socket error occurred. You can use your platform’s standard<br />

API to retrieve more specific information.<br />

AX_CAUTH_ERR<br />

Indicates that the server was unable to authenticate the client.<br />

The first error can represent a large number of failures. In most cases, the connection<br />

will close unexpectedly, which can indicate many things, including loss of connectivity<br />

or even the client’s failing to authenticate the server.<br />

To initialize a server, we use the following function:<br />

AX_SRV *AX_srv_listen(char *if, unsigned short port, size_t protocol,<br />

AX_get_creds_cb cf, AX_exchange_status_cb sf);<br />

This function has the following arguments:<br />

if<br />

String indicating the interface on which to bind. If you want to bind on all interfaces<br />

a machine has, use “0.0.0.0”.<br />

port<br />

Port on which to bind.<br />

protocol<br />

Indication of which protocol you’re using. As of this writing, the only valid values<br />

are SAX_PROTOCOL_v1 and PAX_PROTOCOL_v1.<br />

cf<br />

callback for retrieving credentials discussed above.<br />

sf<br />

Callback for error reporting discussed above. Set this to NULL if you don’t need it.<br />

Performing Password-Based Authentication and Key Exchange | 425<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!