[Mono-list] Replace the default windows system.security.cryptography classes with mono

Sébastien Pouliot spouliot at videotron.ca
Wed May 18 10:36:28 EDT 2005


Hello Daniel,

> How would you do accomplish this?

1. Create a new assembly, e.g. Daniel.Crypto.dll
2. Copy the algorithms you want in it, e.g. SHA1Managed
3. Edit the machine.config file to remap SHA1 to
"System.Security.Cryptography.SHA1Managed, Daniel.Crypto, version, culture,
publickeytoken"

> Editing machine.config?

Yes. That's how the runtime will use the new, or alternate, classes.

But keep in mind that this works _only_ if the applications were written
_correctly_, i.e. that they used the Create static methods [1] to create new
instance of cryptographic classes. Code that directly creates an instance of
a specific type [2] will continue to use the MS version of the algorithm
(the constructors shouldn't have been made public but it's a little too late
for that).

[1] SHA1 hash = SHA1.Create ();

[2] SHA1 hash = new SHA1CryptoServiceProvider ();

> What happens
> then to classes like CryptographyException, which are not explicitly
> mapped in machine.config?

Your new assembly needs to link to mscorlib.dll so the
CryptographicException will still be from MS (like the underlying code that
the algorithms uses, e.g. Buffer.BlockCopy).

Sebastien Pouliot
home: spouliot at videotron.ca
blog: http://pages.infinit.net/ctech/poupou.html



More information about the Mono-list mailing list