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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

48<br />

<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />

Code test case Implemented? Feature that is implemented<br />

Verify that the<br />

configuration<br />

properties of the<br />

providers are<br />

exposed as public<br />

and that they are<br />

strongly typed.<br />

Yes<br />

In the CryptographySettings class, the SymmetricProviders<br />

property can only contain a SymmetricProvider-<br />

Data collection. The following code demonstrates this.<br />

The HashProviders property is similar.<br />

[ConfigurationProperty(symmetricCryptoProvider<br />

sProperty, IsRequired= false)]<br />

public NameTypeConfigurationElementCollection<<br />

SymmetricProviderData> SymmetricCryptoProviders<br />

{<br />

}<br />

Verify that the<br />

configuration properties<br />

for the custom<br />

providers are<br />

exposed as public<br />

and that they are<br />

implemented as<br />

custom property<br />

collections.<br />

Verify that there is<br />

a way to remove<br />

decrypted keys<br />

from memory after<br />

they have been<br />

used.<br />

Yes<br />

Yes<br />

The CustomSymmetricCryptoProviderData class<br />

and the CustomHashProviderData class have references<br />

to the CustomProviderDataHelper class. This<br />

class defines a NameValueCollection class that holds<br />

the attributes in custom property collections. This is<br />

shown in the following code example.<br />

private NameValueCollection attributes;<br />

private void AddAttributesFromConfigurationProperties()<br />

{<br />

foreach (ConfigurationProperty property in<br />

propertiesCollection)<br />

{<br />

…<br />

attributes.Add(property.Name, (string)helped<br />

CustomProviderData.BaseGetPropertyValue(prop<br />

erty));<br />

}<br />

}<br />

The CryptographicUtility.ZeroOutBytes method clears<br />

the decrypted key from memory. This is shown in the<br />

following code example.<br />

public byte[] Encrypt(…)<br />

{<br />

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

}

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

Saved successfully!

Ooh no, something went wrong!