Using Cryptography block methods with cryptostream

Topics: Cryptography Application Block
Jan 24, 2011 at 9:31 PM

I am new at using the Enterprise library. While it works really quick and easy on strings, It seems the block isn't really geared for processing files but maybe I am just missing something.

 I am trying to encode/decode large files (>1 Gig) on my drive using cryptostream and a Symmetric provider through the Enterprise Library, but I'm stumped about how to take the provider and produce the necessary transform parameter for the cryptostream object.

 Has anybody used the Crypto block this way before? Is there a better way to using the Library methods for file encryption?

 Any help would be greatly appreciated.


Jan 25, 2011 at 12:23 PM

Haven't tried this yet. Though looking into the source code it looks like CryptoStream is also being utilized in entlib crypto block. We'll look into this and keep you updated what we may find.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.

Jan 25, 2011 at 5:23 PM

Is it possible to access the info that a Symmetric provider is configured with? (ie - key, vectors, ect)

If so then I could still create my own RigindaelManaged object for my file crypto needs -  as long as it can be configured to use the same settings as the factory made objects have.



Jan 26, 2011 at 4:09 AM

No, there are no symmetric algorithm properties that are exposed to the user and are thus not configurable.  You might be able to achieve the goal you want by creating a custom implementation of an algorithm provider that just essentially wraps the functionality of RijndaelManaged and at the same time, allows you to configure the properties you want by placing those values in the Attributes collection property (which can be retrieved in the NameValueCollection parameter of the custom provider's constructor).   


Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.

Mar 16, 2011 at 10:53 PM

Just wondering if any one has done any more work on this front?  Sarah, could you point me to some more details on creating the custom implementation of an algorithm provider?

Mar 17, 2011 at 2:39 AM

You would create a class implementing ISymmetricCryptoProvider.  You then need to decide to implement basic or full integration with the config tool.  If you need full integration with the config tool, you need to create a class inheriting from the SymmetricProviderData.  This is actually included in the documentation, refer to this topic.  In addition, you can refer to the EntLib Extensibility Labs.  Although it doesn't include sample for creating a custom alrogithm provider, the idea is the same for other blocks.


Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.