Topic: RSA 2048 bit signature generation & verification

Hello team, I am trying to use RSA-2048 based Signature generation & Verification using wolfssl on s32k144EVB. So I used wolfssl source files from NXP folder found under design studio installation & built it as static library. I have attached the user_settings.h file for which i'm building the application. I'm getting stack smashing error when generating signature for data. "unsigned char* privKey" is der pkcs1 key 2048bit , "size_t privKeyLen" is the sizeof privKey byte array is 1218 bytes. Also i've attached the test application source file here. Requesting your help with this issue. I am using below wolfssl functions in order.
1.ret = wc_InitRng(&rng);
2.ret = wc_InitRsaKey(&rsaKey, NULL);
3.ret = wc_RsaPrivateKeyDecode(privKey, &idx, &rsaKey, (word32)privKeyLen);
4.ret = wc_Sha256Hash(inData, (word32)inDataLen, hash);
5.int keySize = wc_RsaEncryptSize(&rsaKey);
6.ret = wc_RsaSSL_Sign(
            hash,
            sizeof(hash),
            outSign,
            (word32)*inOutSignBufSize,
            &rsaKey,
            &rng
    );

Post's attachments

user_settings.h 2.49 kb, 2 downloads since 2026-02-16 

You don't have the permssions to download the attachments of this post.

Share

Re: RSA 2048 bit signature generation & verification

Hello,

Please share your wolfSSL version and if possible, your full wolfSSL code.  If you can't share your code, please try using our example here: https://github.com/wolfSSL/wolfssl-exam … fer/sign.c

Please also ensure that your code is including "#include <wolfssl/wolfcrypt/settings.h>" before all other wolfSSL headers.

Are you able to share any information on your project?  Are you working on a commercial or personal project?  If this information is sensitive you can contact us at support [AT] wolfssl [DOT] com.

Thanks,
Kareem

Share

Re: RSA 2048 bit signature generation & verification

One thing worth checking is the output buffer size and stack usage. Make sure outSign is large enough for a 2048-bit RSA signature (256 bytes) and that *inOutSignBufSize reflects the actual buffer capacity. Also, verify that sizeof(hash) is 32 bytes and check the return value of each wolfSSL function. If the issue persists, try increasing the stack size and reviewing the compiler's stack protection settings. Sharing the buffer declarations and relevant build configuration may help identify the root cause.

Share