07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Using the <strong>Test</strong> Cases 249<br />

Solution<br />

The solution was to zero out the unencrypted algorithm key before returning the<br />

data. The application block code was modified by adding the CryptographyUtility.<br />

ZeroOutBytes method. The following is the modified code.<br />

public byte[] Decrypt(byte[] encryptedText)<br />

{<br />

byte[] output = null;<br />

byte[] data = ExtractIV(encryptedText);<br />

this.algorithm.Key = Key;<br />

using (ICryptoTransform transform = this.algorithm.CreateDecryptor())<br />

{<br />

output = Transform(transform, data);<br />

}<br />

CryptographyUtility.ZeroOutBytes(this.algorithm.Key);<br />

return output;<br />

}<br />

Verification<br />

The CryptographyUtility.ZeroOutBytes method was examined to verify that it<br />

cleared the algorithm key, which is contained in a byte array. The method incorporates<br />

the .NET Framework Array.Clear method, which clears byte arrays.<br />

public static void ZeroOutBytes(byte[] bytes)<br />

{<br />

if (bytes == null)<br />

{<br />

return;<br />

}<br />

Array.Clear(bytes, 0, bytes.Length);<br />

}<br />

Functional <strong>Test</strong>ing<br />

The objective of the functional tests is to verify that the application block meets all<br />

of its functional requirements. This section discussions functional issues that were<br />

found in the Cryptography Application Block, the Data Access Application Block,<br />

the Exception Handling Application Block, the Logging Application Block, and the<br />

Security Application Block.<br />

<strong>Test</strong>ing the Cryptography Application Block<br />

This test case determined whether the Cryptography Application Block would encrypt<br />

data when the data protection scope was set to LocalMachine and there was no<br />

entropy.

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

Saved successfully!

Ooh no, something went wrong!