<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" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<div>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif,serif,"EmojiFont";">
<p>Hi there,</p>
<p><br>
</p>
<p>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.....</p>
<p><br>
</p>
<ol style="margin-bottom: 0px; margin-top: 0px;">
<li><b>How and where I should define the
<div>EVP_[En/De]cryptInit_ex(..),    <span>EVP_[En/De]cryptUpdate(..)</span>, and
<span>EVP_[En/De]cryptFinal_ex(..)</span></div>
functions in my Engine code? </b><br>
</li></ol>
<p><br>
</p>
<p>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>
</p>
<p><br>
</p>
<p>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>
</p>
<p><br>
</p>
<p>AFAIK (and please correct me if this is wrong)  my init_key function is invoked by the EVP interface when I call the EVP_<span>[En/De]</span>cryptInit_ex function, and the do_cipher function is called upon EVP_[En/De]cryptUpdate. But how should I handle
 the EVP_<span>[En/De]</span>cryptFinal functions? Should I not be implementing them in my engine? Or am I missing something here....</p>
<p><br>
</p>
<blockquote>
<p><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></p>
</blockquote>
<p><br>
</p>
<p><br>
</p>
<p>So to recap, two questions: <b><br>
</b></p>
<ol>
<li>How can I explicitly define which operations in my engine happen when the EVP_[En/De]cryptInit_ex(..),   
<span>EVP_[En/De]cryptUpdate(..)</span>, and <span>EVP_[En/De]cryptFinal_ex(..) functions are called from a driver program?</span></li><li><span>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)<b></b></span></li></ol>
<p>Thanks in advance, <br>
</p>
<p><br>
</p>
<p>- Brett <br>
</p>
<p><br>
</p>
<p></p>
<p><b><span>** 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</span><br>
</b></p>
<p><br>
</p>
<br>
<p><br>
</p>
</div>
</div>
</div>
<br>
<p></p>
</div>
</body>
</html>