Sorry for precedent message, I don't see the to page error; I rewrie all.
I keep for other few tay this topic in this section; at the same time a move it in Compact Framework section.
Hi, I don't know is the right section for my question. Question: I must use C code in C# web services on PDA with PocketPC, but I have any problem with marshaling. Below I paste the C code and the C# code that I write (but it doesn't complete).
C code:
/* define Octet Length Type - normally int but could be short or long */
typedef int oltype;
#define MR_P1363_OK 0
#define MR_P1363_DOMAIN_ERROR -1
#define MR_P1363_INVALID_PUBLIC_KEY -2
#define MR_P1363_ERROR -3
#define MR_P1363_INVALID -4
#define MR_P1363_DOMAIN_NOT_FOUND -5
#define MR_P1363_OUT_OF_MEMORY -6
#define MR_P1363_DIV_BY_ZERO -7
#define MR_P1363_BAD_ASSUMPTION -8
// Dichiarato nel file mirdef.h
#ifdef mr_unsign64
#define MAX_HASH_BYTES 64
#else
#define MAX_HASH_BYTES 32
#endif
/* Defintion */
#define mr_utype int
#define mr_unsign32 unsigned int
typedef unsigned mr_utype mr_small;
/* portable representation of a big positive number */
typedef struct
{
oltype len;
oltype max;
#ifdef OCTET_FROM_STACK_SIZE
char val[OCTET_FROM_STACK_SIZE];
#else
char *val;
#endif
} octet;
/* Cryptographically strong pseudo-random number generator */
typedef struct {
mr_unsign32 ira[NK]; /* random number... */
int rndptr; /* ...array & pointer */
mr_unsign32 borrow;
int pool_ptr;
char pool[MR_HASH_BYTES]; /* random pool */
} csprng;
/* Big */
struct bigtype
{
mr_unsign32 len;
mr_small *w;
};
typedef struct bigtype *big;
/* Ebrick2 */
typedef struct {
#ifdef MR_STATIC
const mr_small *table;
#else
mr_small *table;
#endif
big a6,a2;
int m,a,b,c;
int window;
int max;
} ebrick2;
/* EC2 domain parameters */
typedef struct
{
int words;
int fsize;
int rbits;
int M;
octet A;
octet B;
octet R;
octet Gx;
octet Gy;
octet K;
octet IK;
int H;
int a,b,c;
ebrick2 PC;
} ec2_domain;
/* Octet string handlers */
extern P1363_API BOOL OCTET_INIT(octet *,int);
extern P1363_API void OCTET_KILL(octet *);
/* EC2 primitives - support functions */
extern P1363_API void EC2_DOMAIN_KILL(ec2_domain *);
extern P1363_API int EC2_DOMAIN_INIT(ec2_domain *,char *,char **,int);
extern P1363_API int EC2_DOMAIN_VALIDATE(BOOL (*)(void),ec2_domain *);
extern P1363_API int EC2_KEY_PAIR_GENERATE(BOOL (*)(void),ec2_domain *,csprng *,octet *,BOOL,octet *);
extern P1363_API int EC2_PUBLIC_KEY_VALIDATE(BOOL (*)(void),ec2_domain
*,BOOL,octet *);
/* P1363 EC2 primitives */
extern P1363_API int EC2SVDP_DH(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *);
extern P1363_API int EC2SVDP_DHC(BOOL (*)(void),ec2_domain *,octet *,octet *,BOOL,octet *);
extern P1363_API int EC2SVDP_MQV(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2SVDP_MQVC(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *,octet *,BOOL,octet *);
extern P1363_API int EC2SP_NR(BOOL (*)(void),ec2_domain *,csprng *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2VP_NR(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2SP_DSA(BOOL (*)(void),ec2_domain *,csprng *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2VP_DSA(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2PSP_NR2PV(BOOL (*)(void),ec2_domain *,csprng *,octet *,octet *);
extern P1363_API int EC2SP_NR2(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2VP_NR2(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2SP_PV(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *);
extern P1363_API int EC2VP_PV(BOOL (*)(void),ec2_domain *,octet *,octet *,octet *,octet *);
C# code:
public enum MR
{
MR_P1363_OK = 0,
MR_P1363_DOMAIN_ERROR = -1,
MR_P1363_INVALID_PUBLIC_KEY = -2,
MR_P1363_ERROR = -3,
MR_P1363_INVALID = -4,
MR_P1363_DOMAIN_NOT_FOUND = -5,
MR_P1363_OUT_OF_MEMORY = -6,
MR_P1363_DIV_BY_ZERO = -7,
MR_P1363_BAD_ASSUMPTION = -8,
}
public enum MAX
{
MAX_HASH_BYTES = 64,
}
public enum mr
{
mr_utype = int,
mr_unsign32 = int,
}
public struct octet
{
public int len;
public int max;
public string val ;
};
public struct csprng
{
public mr_unsign32 [] ira;
public int rndptr;
public mr_unsign32 borrow;
public int pool_ptr;
public char [] pool;
};
public struct bigtype
{
public mr_unsign32 len;
public unsigned mr_utype w;
};
public struct ebrick2
{
public unsigned mr_utype table;
public big a6,a2;
public int m,a,b,c;
€public int window;
public int max;
};
public struct ec2_domain
{
public int words;
public int fsize;
public int rbits;
public int M;
public octet A;
public octet B;
public octet R;
public octet Gx;
public octet Gy;
public octet K;
public octet IK;
public int H;
public int a,b,c;
public ebrick2 PC;
};
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int OCTET_INIT (ref octet param0, int param1);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern void OCTET_KILL (ref octet param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern void EC2_DOMAIN_KILL (ref ec2_domain param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2_DOMAIN_INIT (ref ec2_domain param0, string , string , int param3);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2_DOMAIN_VALIDATE (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2_KEY_PAIR_GENERATE (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2_PUBLIC_KEY_VALIDATE (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2SVDP_DH (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2SP_DSA (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2VP_DSA (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2SP_PV (int param0);
[DllImport("header1.dll", CharSet=CharSet.Unicode)]
public static extern int EC2VP_PV (int param0);