Hi David

Thanks for your reply.
In fact it I had defined small heap/stack memory. I increased it, then it resolved.

john & alex.abrahamson

Thanks for your replies.
Clearly, as John has answered,  the root and modulo pair of parameters should be the same on both sides.

I missed this obvious point.

Hi everyone

I appreciate any hint in advanced.
Diffie-Helman Key agreement "wc_DhAgree" returns error (-243): "DH Check Public Key failure".

I tried to have both sides 'A' and 'B' in a same program and then establish a key using both private and public keys. I used 'p' and 'g' in cert_test.h  to generate public and private keys on side A. and also used 'dh_key_der_1024' in cert_test.h  to decode public and private keys for side B.

Side A:

DhKey keyA;
int ret;
const byte* pA= dh_p; // initialize with prime };
const  byte* gA= dh_g; // initialize with base };
byte privA[256];
byte pubA[256];
byte agree[256];
word32 agreeSz;
word32 privSzA, pubSzA;
wc_InitDhKey(&keyA); // initialize key
WC_RNG rng;
wc_InitRng(&rng); // initialize rng
ret = wc_DhSetKey(&keyA, pA, sizeof(pA), gA, sizeof(gA));
ret = wc_DhGenerateKeyPair(&keyA, &rng, privA, &privSzA, pubA, &pubSzA);

Side B:

DhKey keyB;    
byte privB[256];
byte pubB[256];    
word32 privSzB, pubSzB;
const unsigned char* tmpB = dh_key_der_1024;
word32 idxB = 0;
wc_InitDhKey(&keyB); // initialize key
ret = wc_DhKeyDecode(tmpB, &idxB, &keyB, sizeof_client_keypub_der_1024);
ret = wc_DhGenerateKeyPair(&keyB, &rng, privB, &privSzB, pubB, &pubSzB);

and finally

ret = wc_DhAgree(&keyA,agree, &agreeSz, privA, sizeof(privA), pubB, pubSzB);
wc_ErrorString(ret,errorString);
printf("\r\nwc_DhAgree Error: (%d): %s",ret,errorString);

:

This will return error (-243): "DH Check Public Key failure". 
Any clue?!

Hi

I appreciate your help. I am running a very basic RSA code snippet on STM32F7xx. But it is stuck at wc_MakeRsaKey and never stops. Here is the code:

    int    ret;

    size_t bytes;
    WC_RNG rng;
    RsaKey key;

    /* initialize stack structures */
    XMEMSET(&rng, 0, sizeof(rng));
    XMEMSET(&key, 0, sizeof(key));


    bytes = (size_t)sizeof_client_key_der_2048;

     ret = wc_InitRsaKey(&key, NULL);
    
    ret = wc_InitRng(&rng);

    ret = wc_MakeRsaKey(&key, 1024, 65537, &rng);