1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<title>AES_Encrypt</title> 9<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 10</head> 11 12<body> 13 14<h1 align="left">AES_Encrypt <IMG src="../../image/TWL.gif" width="23" height="12" border="0" align="middle"></h1> 15<h2>Syntax</h2> 16 17<dl> 18 <dd> 19 <pre><CODE>#include <twl/aes.h> 20 21#define AES_ENCRYPT_HEADER_SIZE 16 22 23<a href="../api/AESResult.html">AESResult</a> AES_Encrypt( 24 const void* src, 25 u32 srcSize, 26 void* dst, 27 <a href="../api/AESCallback.html">AESCallback</a> callback, 28 void* arg ); 29</CODE></pre> 30</dd> 31</dl> 32 33<h2>Arguments</h2> 34<TABLE border="1" width="100%" class="arguments"> 35 <TBODY> 36 <TR> 37 <TH>src</TH> 38 <TD>Pointer to the plaintext. Must be 4-byte aligned. In addition, it must point to a location in main memory.</TD> 39 </TR> 40 <TR> 41 <TH>srcSize</TH> 42 <TD>Plaintext size. Must be greater than zero.</TD> 43 </TR> 44 <TR> 45 <TH>dst</TH> 46 <TD>Pointer to the buffer that will store the ciphertext. Must be 4-byte aligned. In addition, it must point to a location in main memory. 47 An area of size <span class="argument">srcSize</span> + <code>AES_ENCRYPT_HEADER_SIZE</code> bytes is required.</TD> 48 </TR> 49 <TR> 50 <TH>callback</TH> 51 <TD>Pointer to the callback function to call when encryption completes. 52 It is possible to specify <CODE>NULL</CODE>.</TD> 53 </TR> 54 <TR> 55 <TH>arg</TH> 56 <TD>User-defined parameter that is passed to the above callback function. 57 Can be any value, including <CODE>NULL</CODE>.</TD> 58 </TR> 59 </TBODY> 60</TABLE> 61 62<h2>Return Values</h2> 63<p> 64Returns <CODE>AES_RESULT_SUCCESS</CODE> if the AES operation was started successfully. Any other return values indicate an error. 65</p> 66 67<H2>Description</H2> 68<P> 69Uses the AES algorithm to encrypt data. <code><a href="AES_Decrypt.html">AES_Decrypt()</a></code> is used to decrypt data. 70</p> 71 72<p> 73This uses the key set with <code><a href="../api/AES_SetKey.html">AES_SetKey()</a></code> to encrypt <span class="argument">srcSize</span> bytes starting from <span class="argument">src</span>. The encrypted result will be written to a region starting at <span class="argument">dst</span> whose size is <span class="argument">srcSize</span> + <code>AES_ENCRYPT_HEADER_SIZE</code> bytes. When the encryption process completes, <span class="argument">callback</span> will be called, using the encrypted result and <span class="argument">arg</span> as arguments. <span class="argument">callback</span> is called from the interrupt handler, so note that it may be called even when interrupts are disabled. Conversely, also note that <span class="argument">callback</span> is not called when interrupts are disabled. 74</p> 75 76<p> 77This function returns control immediately once it has started the processing. If processing starts without a problem, this function will return <code>AES_RESULT_SUCCESS</code>, but if an error occurs during subsequent processing, it will call <span class="argument">callback</span> with the error value and <span class="argument">arg</span> as arguments. Note that error notification done using this callback will be started from the interrupt handler, so depending on the situation, it's possible that the callback could deliver an error notification before control returns from the function. 78</p> 79 80<p> 81The encryption key must be set beforehand using <code><a href="../api/AES_SetKey.html">AES_SetKey()</a></code>. 82</p> 83 84<h2>See Also</h2> 85<p><CODE><A href="AES_Decrypt.html">AES_Decrypt</A></CODE></p> 86 87<H2>Revision History</H2> 88<P> 892008/09/06 Revised in line with the removal of <CODE>AES_InitRand</CODE>.<br>2007/12/25 Initial version. 90</P> 91<hr><p>CONFIDENTIAL</p></body> 92</html> 93