[Mono-list] Crypto Unit tests on linux

Piers Haken piersh@friskit.com
Wed, 16 Oct 2002 02:23:48 -0700


Or, even better:

3) use: Assembly.Load, Activator.CreateInstance & MethodInfo.Invoke

Assuming they're supported, of course.

Piers.

> -----Original Message-----
> From: Paolo Molaro [mailto:lupus@ximian.com] 
> Sent: Wednesday, October 16, 2002 1:36 AM
> To: 'mono-list'
> Subject: Re: [Mono-list] Crypto Unit tests on linux
> 
> 
> On 10/15/02 Sebastien Pouliot wrote:
> > I found out that I made a cyclic dependency: some classes 
> > (AsymmetricAlgorithm, DSA, RSA) requires XmlDocument. And still the 
> > problem didn't show up until I tried a "make clean" (else it would 
> > just use the one present in System.Xml.Dll). These classes 
> have been 
> > excluded from the build process (probably just because of 
> this) but I 
> > wasn't aware of it. So this is the reason for the class library is 
> > compiling just fine.
> 
> corlib needs to be self-contained: you can't use types from 
> any other assembly in it, so you need to remove the use of 
> XmlDocument from the crypto classes. You have two choices for 
> the substitute code:
> 1) write a small xml parser that handles just the stuff you 
> need in corlib
> 2) (better, IMHO) write an internalcall that uses the GMarkup 
> parser in glib and fills in the RSA and DSA structures.
> 
> To do 2), you need to declare in the runtime header files two 
> structures that match the C# implementation of DSAParameters 
> and RSAParameters.
> 
> typedef struct {
> 	MonoArray *P;
> 	MonoArray *Q;
> 	MonoArray *D;
> 	MonoArray *DP;
> 	MonoArray *DQ;
> 	MonoArray *InverseQ;
> 	MonoArray *Modulus;
> 	MonoArray *Exponent;
> } MonoRSAParameters;
> 
> Then you write the two internalcalls as:
> 
> 	static extern bool GetRSA (string xml, out 
> RSAParameters rsap); and
> 	static extern bool GetDSA (string xml, out DSAParameters rsap);
> 
> The C functions will look like:
> 
> MonoBoolean
> CryptoGetRSA (MonoString *xml, MonoRSAParameters *rsap)
> {
> 	GMarkupParseContext *context;
> 	char *p = mono_string_to_utf8 (xml);
> 	
> 	context = ...create markup context...;
> 	...parse and set the fields in rsap...
> 	g_free (p);
> 	if (parse_success)
> 		return TRUE;
> 	return FALSE;
> }
> 
> mono/docs/internal-calls has some more info on registering 
> the internal call to the runtime.
> 
> lupus
> 
> -- 
> -----------------------------------------------------------------
> lupus@debian.org                                     debian/rules
> lupus@ximian.com                             Monkeys do it better
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com 
> http://lists.ximian.com/mailman/listinfo/mono-list
>