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.

eturn result;<br />

}<br />

int spc_accept_key(char *filename, char *ipnum, EVP_PKEY *key) {<br />

int result;<br />

char answer[80];<br />

result = spc_lookup_key(filename, ipnum, key);<br />

if (result = = 1) return 1;<br />

if (result = = -1) {<br />

for (;;) {<br />

printf("FATAL ERROR! A different key has been received from the server "<br />

"%s\nthan we have on record. Do you wish to continue? ", ipnum);<br />

if (!fgets(answer, sizeof(answer), stdin)) continue;<br />

if (answer[0] = = 'Y' || answer[0] = = 'y') return 1;<br />

if (answer[0] = = 'N' || answer[0] = = 'n') return 0;<br />

}<br />

}<br />

for (;;) {<br />

printf("WARNING! The server %s has presented has presented a key for which "<br />

"we have no\nprior knowledge. Do you want to [r]eject the key, "<br />

"[a]ccept and remember it,\nor allow its use for only this [o]ne "<br />

"time? ", ipnum);<br />

if (!fgets(answer, sizeof(answer), stdin)) continue;<br />

if (answer[0] = = 'r' || answer[0] = = 'R') return 0;<br />

if (answer[0] = = 'o' || answer[0] = = 'O') return 1;<br />

if (answer[0] = = 'a' || answer[0] = = 'A') break;<br />

}<br />

if (!spc_remember_key(filename, ipnum, key))<br />

printf("Error remembering the key! It will be accepted this one time only "<br />

"instead.\n");<br />

return 1;<br />

}<br />

See Also<br />

Recipes 7.17, 10.5<br />

8.20 Providing Forward Secrecy in a Symmetric<br />

System<br />

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

When using a series of (session) keys generated from a master secret, as described in<br />

the previous recipe, we want to limit the scope of a key compromise. That is, if a<br />

derived key is stolen, or even if the master key is stolen, we would like to ensure that<br />

no data encrypted by previous session keys can be read by attackers as a result of the<br />

444 | Chapter 8: Authentication and Key Exchange<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!