[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-list
Subject:    [Mono-list] to wrapp mono with C
From:       pa-alran () tele2 ! fr
Date:       2005-09-29 12:39:19
Message-ID: web-2903811 () mailbe05 ! swip ! net
[Download RAW message or body]

hello, congratulation for Mono.

I'm french, so my english is very poor... sorry.
I want to use the hash function of openssl with my code in 
mono.

The file .h in C is :

#define SHA_BLOCK	16

typedef struct SHAstate_st
{
	unsigned long h0,h1,h2,h3,h4;
	unsigned long Nl,Nh;
	unsigned long data[SHA_LBLOCK];
	int num;
} SHA_CTX;

void SHA1_Init(SHA_CTX *c);

void SHA1_Update(SHA_CTX *c, unsigned char *data, unsigned 
long len);

void SHA1_Final(unsigned char *md, SHA_CTX *c);

---------------------------

I have write my wrapper like this :

protected int SHA_BLOCK = 16;

[StructLayout(LayoutKind.Sequential, 
CharSet=CharSet.Ansi)]
public struct SHA_CTX
{
     public uint h0;
     public uint h1;
     public uint h2;
     public uint h3;
     public uint h4;
     public uint Nl;
     public uint Nh;
     [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
     public uint [] data ;
     public int num;
} 
		
//chargement de la dll SHA1.so "C"
[DllImport("SHA1")]
public static extern void SHA1_Init(ref SHA_CTX c);
//public static extern void SHA1_Init(IntPtr c);

//chargement de la dll SHA1.dll "C"
[DllImport("SHA1")]
public static extern void SHA1_Update(ref SHA_CTX c, ref 
byte [] data, uint len);
//public static extern void SHA1_Update(ref SHA_CTX c, 
IntPtr data, uint len);
//public static extern void SHA1_Update(ref SHA_CTX c, 
byte * data, uint len);
		
//chargement de la dll SHA1.dll "C"
[DllImport("SHA1")]
public static extern void  SHA1_Final(ref byte [] md, ref 
SHA_CTX c);
//public static extern void  SHA1_Final(IntPtr md, ref 
SHA_CTX c);
//public static extern void  SHA1_Final(byte* md, ref 
SHA_CTX c);
		
-----------------------

With the structure, i can acces to the array data ?

And i don't know how to wrapp " unsigned char * " ? my 
solutions don't work.


Can you help me please ?

Thank you very much.

Pierre alain.
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic