<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">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" class="gmail_signature">SY, Dmitry Belyavsky</div>