<div dir="ltr">Dear Dmitry,<div>Thanks for sharing the patch. I will try and let you know the results. </div><div><br></div><div>Thanks,</div><div>Shariful</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 4, 2021 at 5:56 AM Dmitry Belyavsky <<a href="mailto:beldmit@gmail.com">beldmit@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Shariful,<div><br></div><div>Could you please try the patch from <a href="https://github.com/openssl/openssl/pull/16734" target="_blank">https://github.com/openssl/openssl/pull/16734</a>?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 29, 2021 at 6:59 PM Dmitry Belyavsky <<a href="mailto:beldmit@gmail.com" target="_blank">beldmit@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Shariful,</div><div><br></div><div><div>Yes. You have to provide all the RSA_METHO functions your app is going to use.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 28, 2021 at 5:46 PM Shariful Alam <<a href="mailto:dipto181@gmail.com" target="_blank">dipto181@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Dmitry,<div>Thank you for your response. </div><div><br></div><div>Here is the stack trace </div><div><br></div><div><br></div><div>I was trying using gdb to debug the error. I get to until RSA_public_encrypt(), then if I step in, I get the segmentation fault,</div><div>==================================================================================================</div><div>bt<br>#0  0x0000000000000000 in ?? ()<br>#1  0x00007ffff77dbfc0 in RSA_public_encrypt (flen=72, from=0x6d8860 "Hi. This is a test message. Hope to see some performace gain with this.\nme", to=0x6d8a70 "x\353;\367\377\177", rsa=0x6d8540, padding=1) at crypto/rsa/rsa_crpt.c:30<br>#2  0x00000000004479a7 in rsautl_main (argc=0, argv=0x7fffffffde10) at apps/rsautl.c:248<br>#3  0x00000000004379fa in do_cmd (prog=0x6d5930, argc=11, argv=0x7fffffffde10) at apps/openssl.c:564<br>#4  0x0000000000436e4d in main (argc=11, argv=0x7fffffffde10) at apps/openssl.c:183<br></div><div>==================================================================================================<br></div><div><br></div><div>To my understanding, instead of pointing to the default encryption function, it is pointing to  0x0000000000000000, thus causing the segmentation fault. </div></div></blockquote><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,<br>Shariful</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 28, 2021 at 1:40 AM Dmitry Belyavsky <<a href="mailto:beldmit@gmail.com" target="_blank">beldmit@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Shariful,<div><br></div><div>Could you please also provide a stack trace of your segfault?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 28, 2021 at 1:06 AM Shariful Alam <<a href="mailto:dipto181@gmail.com" target="_blank">dipto181@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div>I have the following simple RSA engine code from <b>e_dasync.c. </b> Following code compiles and works. Until now, I was under the impression that if I do not supply an alternative method in function <b>bind_dasync(), the </b>engine will use the default method. However, it doesn't seem to be the case. If I comment out line 37 and try to perform an encryption operation with the following command, </div><div><b><br></b></div><div><b>"openssl rsautl -encrypt -inkey public.pem -pubin -in msg.txt -out msg.enc -engine rsa-engine-new" </b></div><div><b><br></b></div><div>I get segmentation errors.</div><div><br></div><div>Can anyone please tell me why this is happening?</div><div><br></div><div><div>==============================================================================</div><div><ol><li>/* Engine Id and Name */</li><li>static const char *engine_rsa_id = "rsa-engine-new";</li><li>static const char *engine_rsa_name = "RSA engine for testing";</li><li><br></li><li>// data encryption function</li><li>static int eng_rsa_pub_enc(int flen, const unsigned char *from,</li><li>                          unsigned char *to, RSA *rsa, int padding) {</li><li>    printf("Encryption\n");</li><li>    return 0;</li><li>}</li><li><br></li><li>// signature verify</li><li>static int eng_rsa_pub_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding){</li><li>    printf("Signature verify:\n");</li><li>    return 0;</li><li>}</li><li><br></li><li>// signature</li><li>static int eng_rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding){</li><li>    printf("Signature:\n");</li><li>    return 0;</li><li>}</li><li><br></li><li>// data decryption</li><li>static int eng_rsa_priv_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding){</li><li>    printf("Decryption\n");</li><li>    return 0;</li><li>}</li><li><br></li><li><br></li><li>static RSA_METHOD *test_rsa_method = NULL;</li><li><br></li><li><br></li><li>static int bind_dasync(ENGINE *e){</li><li>    /* Setup RSA_METHOD */</li><li>    if ((test_rsa_method = RSA_meth_new("Test RSA method", 0)) == NULL</li><li>       // || RSA_meth_set_pub_enc(test_rsa_method, eng_rsa_pub_enc) == 0</li><li>        || RSA_meth_set_pub_dec(test_rsa_method, eng_rsa_pub_dec) == 0</li><li>        || RSA_meth_set_priv_enc(test_rsa_method, eng_rsa_priv_enc) == 0</li><li>        || RSA_meth_set_priv_dec(test_rsa_method, eng_rsa_priv_dec) == 0</li><li>            ) {</li><li><br></li><li>        return 0;</li><li>    }</li><li><br></li><li>    /* Ensure the dasync error handling is set up */</li><li><br></li><li>    if (!ENGINE_set_id(e, engine_rsa_id)</li><li>        || !ENGINE_set_name(e, engine_rsa_name)</li><li>        || !ENGINE_set_RSA(e, test_rsa_method)</li><li>            ) {</li><li>        return 0;</li><li>    }</li><li>    return 1;</li><li>}</li><li><br></li><li>static int bind_helper(ENGINE *e, const char *id){</li><li>    if (!bind_dasync(e)){</li><li>        printf("2_Error: Inside Bind helper\n");</li><li>        return 0;</li><li>    }</li><li>    return 1;</li><li>}</li><li><br></li><li>IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)</li><li>IMPLEMENT_DYNAMIC_CHECK_FN()</li></ol></div><div>==============================================================================<br></div><div><br></div><div>Regards,</div><div>Shariful Alam</div><div><br></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr">SY, Dmitry Belyavsky</div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr">SY, Dmitry Belyavsky</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr">SY, Dmitry Belyavsky</div>
</blockquote></div>