<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;">
<p><font style="font-family: Calibri,Helvetica,sans-serif,serif,"EmojiFont";" size="3" color="black" face="Calibri,Helvetica,sans-serif"><span style="font-size:12pt;" id="divtagdefaultwrapper"></p>
<div>
<div>
<div id="x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,serif,EmojiFont">
<div style="margin-top:0;margin-bottom:0;">Hi there,</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">I'm building a dynamic engine to support a custom AES hardware module that I've implemented in FPGA logic<b>**</b>, but after reading all available documentation, and pouring over the source code, I'm still very confused
 about the following two things.....</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<ol style="margin-top:0;margin-bottom:0;">
<li><b>How and where I should define the </b>
<div><b>EVP_[En/De]cryptInit_ex(..),    EVP_[En/De]cryptUpdate(..), and EVP_[En/De]cryptFinal_ex(..)</b></div>
<b>functions in my Engine code? </b><br>
</li></ol>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">Prior to this, I successfully built an engine for my sha256 accelerator, and now I'm trying to follow the same steps for AES. For sha256, the EVP_MD structure allowed me to declare pointers to my init, update, and
 final functions. This all worked flawlessly. <br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">Now, when I'm building the AES engine, I see that the EVP_CIPHER structure does not have these pointers (init, update, final), but instead has a pointer to init_key and do_cipher functions. However, the EVP encryption
 interface still has these functions defined. <br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">AFAIK (and please correct me if this is wrong)  my init_key function is invoked by the EVP interface when I call the EVP_[En/De]cryptInit_ex function, and the do_cipher function is called upon EVP_[En/De]cryptUpdate.
 But how should I handle the EVP_[En/De]cryptFinal functions? Should I not be implementing them in my engine? Or am I missing something here....</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin:14pt 30pt;">
<div style="margin-top:0;margin-bottom:0;"><b>2. Does the EVP interface handle padding when a dynamic engine is involved? Or is it up to me to implement a padding structure within the engine itself? If the latter is the case, then I think the answer to the
 previous questions will help me figure out exactly where to implement it. </b></div>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">So to recap, two questions: <b><br>
</b></div>
<ol style="margin-top:14pt;margin-bottom:14pt;">
<li>How can I explicitly define which operations in my engine happen when the EVP_[En/De]cryptInit_ex(..),    EVP_[En/De]cryptUpdate(..), and EVP_[En/De]cryptFinal_ex(..) functions are called from a driver program?</li><li>Does my engine need to handle padding the input data upon encryption, and stripping the padding when decrypting? Or does the EVP API handle the padding for me, and I only need to worry about the core AES algorithm on the arbitrary input data? (for reference,
 I'd like to just use standard PKCS padding)</li></ol>
<div style="margin-top:0;margin-bottom:0;">Thanks in advance, <br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">- Brett <br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;"> </div>
<div style="margin-top:0;margin-bottom:0;"><b>** I'm using the Xilinx Zynq SoC, so I can create custom hardware in the programmable logic, and then interact with it from software running on the processor through the memory map, just like any peripheral....details
 irrelevant</b><b><br>
</b></div>
</font></div>
</div>
</div>
</span></font><br>
<p></p>
</div>
</body>
</html>