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.

CryptReleaseContext(hProvider, 0);<br />

return FALSE;<br />

}<br />

}<br />

for (dwPass = 0; dwPass < sizeof(pbSinglePats); dwPass++) {<br />

memset(pbBuffer, pbSinglePats[dwPass], sizeof(pbBuffer));<br />

if (!PatternPass(hFile, pbBuffer, sizeof(pbBuffer), dwFileSize)) {<br />

CryptReleaseContext(hProvider, 0);<br />

return FALSE;<br />

}<br />

}<br />

for (dwPass = 0; dwPass < sizeof(pbTriplePats) / cbPattern; dwPass++) {<br />

dwCount = sizeof(pbBuffer) / cbPattern;<br />

for (dwIndex = 0; dwIndex < dwCount; dwIndex++)<br />

CopyMemory(pbBuffer + (dwIndex * cbPattern), pbTriplePats[dwPass],<br />

cbPattern);<br />

if (!PatternPass(hFile, pbBuffer, cbPattern * dwCount, dwFileSize)) {<br />

CryptReleaseContext(hProvider, 0);<br />

return FALSE;<br />

}<br />

}<br />

for (dwPass = 0; dwPass < 4; dwPass++)<br />

if (!RandomPass(hFile, hProvider, dwFileSize)) {<br />

CryptReleaseContext(hProvider, 0);<br />

return FALSE;<br />

}<br />

CryptReleaseContext(hProvider, 0);<br />

return TRUE;<br />

}<br />

See Also<br />

“Secure Deletion of Data from Magnetic and Solid-State Memory” by Peter Gutmann:<br />

http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html<br />

2.6 Accessing File Information Securely<br />

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

You need to access information about a file, such as its size or last modification date.<br />

In doing so, you want to avoid the possibility of race conditions.<br />

Solution<br />

Use a secure directory, as described in Recipe 2.4. Alternatively, open the file and<br />

query the needed information using the file handle. Do not use functions that oper-<br />

Accessing File Information Securely | 53<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!