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.

*outlen = out_data.length - (blksz - padding);<br />

if (!(*outbuf = realloc(out_data.data, *outlen))) *outbuf = out_data.data;<br />

return 1;<br />

#else<br />

int padding, result;<br />

void *tmp;<br />

size_t blksz;<br />

krb5_data edata;<br />

krb5_crypto crypto;<br />

if (krb5_crypto_init(ctx, key, 0, &crypto) != 0) return 0;<br />

if (krb5_crypto_getblocksize(ctx, crypto, &blksz) != 0) {<br />

krb5_crypto_destroy(ctx, crypto);<br />

return 0;<br />

}<br />

if (!(tmp = malloc(inlen))) {<br />

krb5_crypto_destroy(ctx, crypto);<br />

return 0;<br />

}<br />

memcpy(tmp, inbuf, inlen);<br />

if (!krb5_decrypt(ctx, crypto, 0, tmp, inlen, &edata)) {<br />

if ((padding = spc_remove_padding((unsigned char *)edata.data + edata.length -<br />

blksz, blksz)) != -1) {<br />

*outlen = edata.length - (blksz - padding);<br />

if ((*outbuf = malloc(*outlen)) != 0) {<br />

result = 1;<br />

memcpy(*outbuf, edata.data, *outlen);<br />

}<br />

}<br />

krb5_data_free(&edata);<br />

}<br />

free(tmp);<br />

krb5_crypto_destroy(ctx, crypto);<br />

return result;<br />

#endif<br />

}<br />

See Also<br />

Recipes 5.11, 5.25, 8.13<br />

9.7 Performing Interprocess Communication<br />

Using Sockets<br />

<strong>Problem</strong><br />

You have two or more processes running on the same machine that need to communicate<br />

with each other.<br />

Performing Interprocess Communication Using Sockets | 475<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!