1 (edited by kjjy7 2018-09-28 00:53:22)

Topic: Error using wc_RsaPublicKeyDecode

To use Signiture verification, I make these code.

Error happened while using wc_RsaPublicKeyDecode

that function is seem to get rsakey info from string.


    ret = wc_Sha256Hash((const byte*)token, strlen(token), ucSha256Hashed);
    if(ret != 0)
    {
        printf("Error wc_Sha256Hash ret = %d", ret);
        return -25;
    }

    RsaKey rsaKey;
    word32 idx = 0;

    XMEMSET(&rsaKey, 0, sizeof(rsaKey));

    word32 pksize = (word32)wolfSSL_X509_get_pubkey( parse_jason->x509Cert[0] )->pkey_sz;
    const byte * pubkey = (const unsigned char*) wolfSSL_X509_get_pubkey( parse_jason->x509Cert[0] )->pkey.ptr;

    if(pubkey == NULL)
        printf("pubkey is NULL");
    else
        printf("pubkey is not NULL");

    PLOG("%s, pksize %d", __func__, pksize);

    ret = wc_InitRsaKey(&rsaKey, NULL);
    if(ret != 0)
    {
        printf("Error wc_InitRsaKey ret = %d", ret);
        return -25;
    }

    ret = wc_RsaPublicKeyDecode(pubkey, &idx, &rsaKey, pksize);   <-- Error Msg Occurred
    PLOG("wc_RsaPublicKeyDecode ret = %d", ret);
    if (ret != 0)
    {
        // error parsing public key 
        memset( err_string, 0x00, sizeof(err_string) );       

        printf("%s failed ! wc_RsaPublicKeyDecode error %d", __func__, ret);
        return -28;
    } else {
        printf("%s success ! wc_RsaPublicKeyDecode success", __func__);
    }

    ret = wc_SignatureVerify(WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_RSA_W_ENC,
                            (const byte*)ucSha256Hashed, sizeof(ucSha256Hashed),
                            (const byte*)ucSignatureBase64decoded, nLengthSigDecoded,
                            &rsaKey, 300);

    free(token);

    free (ucSignatureBase64decoded);

    wc_FreeRsaKey( &rsaKey );

Error Message is ......

wc_Sha256Hash ret = 0
pubkey is not NULL
check_signature_verification, pksize 270
wc_InitRsaKey ret = 0

then

Process 1110071 (-) terminated SIGSEGV code=1 fltno=11 ip=0000000011b538d8(/usr/lib/libwolfssl.so.12@wc_DhSetKey+0x0000000000000edc) mapaddr=000000000001c8d8. ref=10bc352000000000

could you answer why this error happened?

wait your answer....

thanks..

Share

Re: Error using wc_RsaPublicKeyDecode

kjjy7,

Please share what it is you are working on. Thanks.

- K

Re: Error using wc_RsaPublicKeyDecode

I Send you email...

Please answer to me....

Share

Re: Error using wc_RsaPublicKeyDecode

kjjy7,

Thank you for providing details on the effort. Can you share the contents of the parse_jason data? I am guessing there may be extra encoding in there and you may need to set the "idx" variable to the appropriate offset for start of the RsaKey (if in fact that is an RSA key and not some other key). If you can share the parse_jason string that this error results from we can gladly run some tests on our end to see what the issue might be.

To result in even quicker turn-around if you can send us a test.c application and all relevant headers that we can compile and execute to reproduce this we'll get you results asap.

- K

Re: Error using wc_RsaPublicKeyDecode

An error appears while using the RSA PUB page for the users. All the customers of the https://www.bestbritishwriter.com are assumed or the better aims for all people. The style is issued for the top of the grand items for humans. Elevation is timely proceeded for the RSA forum for the removal of the errors.

Share

Re: Error using wc_RsaPublicKeyDecode

What happens to you, please don't happen to me
I broke up but I won't ... What to regret. slope unblocked
deeeepio

Share

Re: Error using wc_RsaPublicKeyDecode

Hmmmm, clarification is really interesting. Thank you for your thoughts. I've been having a similar issue for a while. I will try to read more and fix it when I get back to my property in Sicily later today

Share

Re: Error using wc_RsaPublicKeyDecode

Hi, kjjy7. I'm curious to know what you are working on. I've been recently attempting to self-educate myself in coding when I'm not managing https://www.commercialpaintersbrisbane.com/. Thanks.

Share