crypto block - creating custom symmetric providers

Topics: Building and extending application blocks, Cryptography Application Block
Aug 14, 2007 at 6:00 AM
I need some urgent help. I have implemented a class library file that follows the guidance given for "To create a custom symmetric encryption algorithm provider" in the Enterprise Lib help file.

When I try to add a reference to this crypto assembly using the Enterprise Library Config tool to my app.config, i'm getting errors.

Basically I follow the guidance given in the help file to enter configuration info, aka:
To configure a Custom Symmetric Cryptography Provider
Click Symmetric Providers, point to New, and then click CustomSymmetric CryptographyProvider.
In the Attributes property section of the right pane, click the ellipsis button (...).
In the EditableKeyValueCollectionEditor dialog box, click Add to add a new name/value pair.
In the right pane of the EditableKeyValueCollectionEditor dialog box, enter the key name and the value of the property.
Add more name/value pairs as appropriate, and then click OK.
(Optional) In the Name property section located in the right pane of the configuration console, change the name of the custom symmetric cryptography provider. The default name is CustomHash Provider.
In the Type property section of the right pane, click the ellipsis button (…). If the type you want is not included in the Assemblies folder, click LoadAssembly on the TypeSelector dialog box to find the assembly that contains the type you want.

When I ask the config tool to load my custom provider assembly, it keeps complaining that :
No Types Found In Assembly.
There were no types found in the assembly 'IngrianProvider' that implement or inherit from the base type 'Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.ISymmetricCryptoProvider'.

But that is not true!

Here's how my custom provider is defined:
namespace Microsoft.Practices.EnterpriseLibrary.Security.Cryptography
public class SymmetricIngrianAlgorithmProvider : ISymmetricCryptoProvider

I also see the above metadata in ILDASM.

Is the config tool buggy?

If yes, can someone point me to the correct app.config XML entries that I need to add for referencing a custom symmetric provider..

Aug 14, 2007 at 12:52 PM

Make sure the tool you use matches the version of the assembly that you've used to build your provider, i.e. they are both signed (you referenced the binaries) or they are unsigned (you referenced the projects). If you're using the VS integrated editor, you'll need to set the "configuration set" for the solution; please see this post for details

Hope this helps,
Aug 15, 2007 at 1:31 AM

That is exactly the problem I have. To quote the link you gave:
Next, you need to make sure you edit configuration files using a copy of the Enterprise Library Configuration tool that knows about the same copy of the assemblies as your app, since it will use these to generate your configuration files. If you are using the external configuration tool (EntLibConfig.exe), you should simply use a copy of the tool compiled against the same set of assemblies (i.e. in the same "bin" directory).

My problem was that because I was using the Cryptography quickstart app to test my new provider, I was using the version of EntLibConfig.exe found in the EntLib3Src\App Blocks\Bin folder. This exe opens the existing app.config file of the crypto-quick start without errors.

On a hunch, i tried opening the app.config using the EntLibConfig in the C:\Program Files\Microsoft Enterprise Library 3.1 - May 2007\Bin, and this one gave errors as it was expecting the signed assembly references to Security.Cryptography.dll. The error was "the located assemblies manifest definition does not match the assembly reference".

Another problem was the mixed binaries that you refered to.. when I changed all my references in my custom-provider's project to the EntLib3Src projects (ie for Security.Cryptography and Common), then the EntLibConfig.exe located in the EntLib3Src\App Blocks\Bin was able to successfully query the type of my dll, and add the relevant app.config entries.

Btw, a lot of this headache could have been avoided if the documentation contains proper definitions of the various <securityCryptographyConfiguration> entries.

My new custom provider entry is:
<add type="Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.SymmetricIngrianAlgorithmProvider, IngrianProvider, Version=, Culture=neutral, PublicKeyToken=null"
name="Ingrian Provider" />
Aug 15, 2007 at 3:18 AM
Hi Satish,

I'm glad this is working for you now. I disagree knowing about the configuration schema would have helped here, though; once the assembly sets match the configuration tool should take care of writing the proper configuration for you. But I do acknowledge that this can be tricky.