<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><font size="2"><span style="font-size:10pt">> Note also that if you set the public key components (n, e) you don't need<br>
> to perform the public key operations in your ENGINE if you keep the original<br>
> bn_mod_exp(): OpenSSL will do them for you</span></font></p>
<p>This is good to know. However, I think I will be implementing modular exponentiation for both public and private keys in hardware for proof of concept.
<br>
</p>
<p><br>
</p>
<p>One more follow up question:       <br>
</p>
<p><br>
</p>
<p><font size="2">><span style="font-size:10pt"> If possible you should set the public key components anyway: some operations
<br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">> such as generating certificate requests require them to be present</span></font><br>
</p>
<p>I'm confused what you mean here, since my engine doesn't "own" any instances of an RSA struct, it just has a static instance of RSA_METHOD struct defined. So therefore my engine never "sets" public or private key components. It just uses the modexp functions
 to write the public/private data (contained in the RSA struct passed as an argument from the higher level encrypt/decrypt functions) out to the hardware accelerator, and then return the result. So I could never "set the public key components anyway", as they
 would be set by whichever program calls RSA_public/private_encrypt/decrypt(). <br>
</p>
<p><br>
</p>
<p>Is my implementing it in this way different than how you thought I was implementing it? It made sense to me to do it this way, however please let me know if you think I'm going about it wrong, or if there are issues with this particular strategy. I want
 to make sure I'm using the engine API in the most intuitive and efficient way!<br>
</p>
<p><br>
</p>
<p>Brett<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> openssl-dev <openssl-dev-bounces@openssl.org> on behalf of Dr. Stephen Henson <steve@openssl.org><br>
<b>Sent:</b> Monday, August 28, 2017 10:32:30 AM<br>
<b>To:</b> openssl-dev@openssl.org<br>
<b>Subject:</b> Re: [openssl-dev] confusion with rsa_meth_st in a custom RSA engine</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Mon, Aug 28, 2017, Brett R. Nicholas wrote:<br>
<br>
> > The rsa_mod_exp function is only called for private key operations. You can't<br>
> > tell if it is a private encrypt or a private decrypt though but that<br>
> > shouldn't matter because the operation performed at that level is the same for<br>
> > both.<br>
> <br>
> Ah, I see. So to clarify (pls correct me if I'm wrong):<br>
> <br>
>   *   rsa_mod_exp() is the modular exponentiation function that openSSL will attempt to use for all private key operations (if RSA_FLAG_EXT_PKEY is set, or the private parameters of that method are non-null), before defaulting to bn_mod_exp().<br>
>   *   And bn_mod_exp() is the modular exponentiation function used by all public key operations<br>
> <br>
> <br>
> So in my case, I should set RSA_FLAG_EX_PKEY in my engine's RSA_METHOD struct, and then implement my own versions of rsa_mod_exp (for the private key encryption/decryption), and bn_mod_exp (for the public key encryption/decryption).<br>
> <br>
> <br>
<br>
Yes. Note also that if you set the public key components (n, e) you don't need<br>
to perform the public key operations in your ENGINE if you keep the original<br>
bn_mod_exp(): OpenSSL will do them for you. If possible you should set the<br>
public key components anyway: some operations such as generating certificate<br>
requests require them to be present.<br>
<br>
Steve.<br>
--<br>
Dr Stephen N. Henson. OpenSSL project core developer.<br>
Commercial tech support now available see: <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.openssl.org&data=02%7C01%7Cbrett.r.nicholas.th%40dartmouth.edu%7Cb1b7883dd5584c8488d708d4ee3ac4e4%7C995b093648d640e5a31ebf689ec9446f%7C0%7C0%7C636395383568793933&sdata=wDesZm0QTSpMHyOtQyAaWQRzEVYFmp9ewgZaZDn6unI%3D&reserved=0">
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.openssl.org&data=02%7C01%7Cbrett.r.nicholas.th%40dartmouth.edu%7Cb1b7883dd5584c8488d708d4ee3ac4e4%7C995b093648d640e5a31ebf689ec9446f%7C0%7C0%7C636395383568793933&sdata=wDesZm0QTSpMHyOtQyAaWQRzEVYFmp9ewgZaZDn6unI%3D&reserved=0</a><br>
-- <br>
openssl-dev mailing list<br>
To unsubscribe: <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmta.openssl.org%2Fmailman%2Flistinfo%2Fopenssl-dev&data=02%7C01%7Cbrett.r.nicholas.th%40dartmouth.edu%7Cb1b7883dd5584c8488d708d4ee3ac4e4%7C995b093648d640e5a31ebf689ec9446f%7C0%7C0%7C636395383568793933&sdata=g8dPj%2Fx9GwR6ldjezTCNKWkvcIOzy1nK0wSLK30ZjjY%3D&reserved=0">
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmta.openssl.org%2Fmailman%2Flistinfo%2Fopenssl-dev&data=02%7C01%7Cbrett.r.nicholas.th%40dartmouth.edu%7Cb1b7883dd5584c8488d708d4ee3ac4e4%7C995b093648d640e5a31ebf689ec9446f%7C0%7C0%7C636395383568793933&sdata=g8dPj%2Fx9GwR6ldjezTCNKWkvcIOzy1nK0wSLK30ZjjY%3D&reserved=0</a><br>
</div>
</span></font>
</body>
</html>