1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../css/manpage.css" type="text/css" /> 7 <style type="text/css"><!-- 8 span.static_style 9 { 10 font-size : 8pt; 11 color : white; 12 font-weight : bold; 13 background : #44f; 14 border-left : solid 1px #aaf; 15 border-top : solid 1px #aaf; 16 border-right : solid 1px #00c; 17 border-bottom : solid 1px #00c; 18 padding-left : 2px; 19 padding-right : 2px; 20 } 21 22 span.virtual_style 23 { 24 font-size : 8pt; 25 color : white; 26 font-weight : bold; 27 background : #0a0; 28 border-left : solid 1px #0f0; 29 border-top : solid 1px #0f0; 30 border-right : solid 1px #060; 31 border-bottom : solid 1px #060; 32 padding-left : 2px; 33 padding-right : 2px; 34 } 35 36 span.protected_style 37 { 38 font-size : 8pt; 39 color : white; 40 font-weight : bold; 41 background : #444; 42 border-left : solid 1px #ccc; 43 border-top : solid 1px #ccc; 44 border-right : solid 1px #222; 45 border-bottom : solid 1px #222; 46 padding-left : 2px; 47 padding-right : 2px; 48 } 49 --></style> 50<title>nn::crypto</title> 51 </head> 52 <body> 53<h1><CODE><a href="../../nn/Overview.html">nn</a>::crypto</CODE> Namespace</h1> 54<h2>Description</h2> 55 <div class="section"> 56<p>The namespace of the encryption library.</p><h3>Block Cipher API</h3><p> 57Encryption using a block cipher has the following four stages, depending on the sophistication of the API.<br /> If at all possible, use the first stage, wherein a single function performs all operations. 58</p><ol><li><b>A single function that carries out all operations</b><p>It includes functions such as <CODE><a href="../../nn/crypto/EncryptAes128Ctr.html">EncryptAes128Ctr</a></CODE>, <CODE><a href="../../nn/crypto/DecryptAes128Ctr.html">DecryptAes128Ctr</a></CODE>, <CODE><a href="../../nn/crypto/EncryptAndGenerateAes128Ccm.html">EncryptAndGenerateAes128Ccm</a></CODE>, and <CODE><a href="../../nn/crypto/DecryptAndVerifyAes128Ccm.html">DecryptAndVerifyAes128Ccm</a></CODE>. <br /> Perform all processing required to encrypt by calling only this one function and specifying the encryption key, data to encrypt, and buffer to store the results. 59</p></li><li><b>Batch processing using a combination of a block cipher and a cipher mode</b><p>This uses an instance of a class derived from <CODE><a href="../../nn/crypto/BlockCipher/Overview.html">BlockCipher</a></CODE> and one of the following functions. 60<ul><li>The <CODE>Encrypt</CODE> function from the <CODE><a href="../../nn/crypto/Encryptor/Overview.html">Encryptor</a></CODE> derived class 61</li><li>The <CODE>Decrypt</CODE> function from the <CODE><a href="../../nn/crypto/Decryptor/Overview.html">Decryptor</a></CODE> derived class 62</li><li>The <CODE>EncryptAndGenerate</CODE> function from <CODE><a href="../../nn/crypto/AuthenticatedEncryptor/Overview.html">AuthenticatedEncryptor</a></CODE> derived class 63</li><li>The <CODE>DecryptAndVerify</CODE> function from the <CODE><a href="../../nn/crypto/AuthenticatedDecryptor/Overview.html">AuthenticatedDecryptor</a></CODE> derived class 64 </li></ul> 65You cannot use instances of these classes. You can use any combination of block cipher and cipher mode. Enter all required parameters and run as a batch. Consequently, all targeted data must be loaded into memory. 66</p></li><li><b>Stream processing using a combination of a block cipher and a cipher mode</b><p>Uses instances of a class derived from <CODE><a href="../../nn/crypto/BlockCipher/Overview.html">BlockCipher</a></CODE>, and a class derived from <CODE><a href="../../nn/crypto/CipherMode/Overview.html">CipherMode</a></CODE>. You can use any combination of block cipher and cipher mode. You can process a little at a time this way, allowing you to process a large volume of data using a smaller buffer to load and process the data. 67</p></li><li><b>Directly using the block cipher</b><p>Uses only an instance of a class derived from <CODE><a href="../../nn/crypto/BlockCipher/Overview.html">BlockCipher</a></CODE>. <br /> Do not use this method unless you know enough about encryption, and have a firm understanding of what you are doing. 68 </p></li></ol><p /></div> 69 <a name="class" id="class"> 70<h2>Classes</h2> 71 <div class="section"> 72 <table class="members"> 73 <tr> 74<th class="category" colspan="2">Block Cipher (Concrete Class)</th> 75 </tr> 76 <tr> 77 <th> 78<a href="../../nn/crypto/Aes/Overview.html"><CODE>nn::crypto::Aes</CODE></a> 79 </th> 80<td>Class for implementing AES ciphers.</td> 81 </tr> 82 <tr> 83 <th> 84<a href="../../nn/crypto/CcmDecryptor/Overview.html"><CODE>nn::crypto::CcmDecryptor</CODE></a> 85 </th> 86<td>Class for decrypting and verifying in CCM mode.</td> 87 </tr> 88 <tr> 89 <th> 90<a href="../../nn/crypto/CcmEncryptor/Overview.html"><CODE>nn::crypto::CcmEncryptor</CODE></a> 91 </th> 92<td>Class for encrypting and generating an MAC in CCM mode.</td> 93 </tr> 94 <tr> 95 <th> 96<a href="../../nn/crypto/CtrDecryptor/Overview.html"><CODE>nn::crypto::CtrDecryptor</CODE></a> 97 </th> 98<td>Class for decrypting in CTR mode.</td> 99 </tr> 100 <tr> 101 <th> 102<a href="../../nn/crypto/CtrEncryptor/Overview.html"><CODE>nn::crypto::CtrEncryptor</CODE></a> 103 </th> 104<td>Class for encrypting in CTR mode.</td> 105 </tr> 106 <tr> 107<th class="category" colspan="2">Block Cipher (Abstract Class)</th> 108 </tr> 109 <tr> 110 <th> 111<a href="../../nn/crypto/AuthenticatedDecryptor/Overview.html"><CODE>nn::crypto::AuthenticatedDecryptor</CODE></a> 112 </th> 113<td>Base class for classes that decrypt ciphertexts with MAC and verify them.</td> 114 </tr> 115 <tr> 116 <th> 117<a href="../../nn/crypto/AuthenticatedEncryptor/Overview.html"><CODE>nn::crypto::AuthenticatedEncryptor</CODE></a> 118 </th> 119<td>Base class for classes that encrypt with MAC.</td> 120 </tr> 121 <tr> 122 <th> 123<a href="../../nn/crypto/BlockCipher/Overview.html"><CODE>nn::crypto::BlockCipher</CODE></a> 124 </th> 125<td>Base class for classes that implement block ciphers.</td> 126 </tr> 127 <tr> 128 <th> 129<a href="../../nn/crypto/CipherMode/Overview.html"><CODE>nn::crypto::CipherMode</CODE></a> 130 </th> 131<td>Base class for the cipher mode classes.</td> 132 </tr> 133 <tr> 134 <th> 135<a href="../../nn/crypto/Decryptor/Overview.html"><CODE>nn::crypto::Decryptor</CODE></a> 136 </th> 137<td>Base class for classes performing decryption using a cipher mode.</td> 138 </tr> 139 <tr> 140 <th> 141<a href="../../nn/crypto/Encryptor/Overview.html"><CODE>nn::crypto::Encryptor</CODE></a> 142 </th> 143<td>Base class for classes that perform encryption using a cipher mode.</td> 144 </tr> 145 <tr> 146<th class="category" colspan="2">Hash</th> 147 </tr> 148 <tr> 149 <th> 150<a href="../../nn/crypto/HashContextBase/Overview.html"><CODE>nn::crypto::HashContextBase</CODE></a> 151 </th> 152<td>Base class for context objects used for hash calculation.</td> 153 </tr> 154 <tr> 155 <th> 156<a href="../../nn/crypto/Sha1Context/Overview.html"><CODE>nn::crypto::Sha1Context</CODE></a> 157 </th> 158<td>Context object for SHA-1 calculation.</td> 159 </tr> 160 <tr> 161 <th> 162<a href="../../nn/crypto/Sha256Context/Overview.html"><CODE>nn::crypto::Sha256Context</CODE></a> 163 </th> 164<td>Context object for SHA-256 calculation.</td> 165 </tr> 166 <tr> 167 <th> 168<a href="../../nn/crypto/ShaBlock512BitContext/Overview.html"><CODE>nn::crypto::ShaBlock512BitContext</CODE></a> 169 </th> 170<td>Context object for SHA calculation with a <CODE>BlockSize</CODE> of 512 bits.</td> 171 </tr> 172 <tr> 173<th class="category" colspan="2">RSA</th> 174 </tr> 175 <tr> 176 <th> 177<a href="../../nn/crypto/RsaContext/Overview.html"><CODE>nn::crypto::RsaContext</CODE></a> 178 </th> 179<td>The context class for RSA public key encryption.</td> 180 </tr> 181 <tr> 182 <th> 183<a href="../../nn/crypto/RsaKey/Overview.html"><CODE>nn::crypto::RsaKey</CODE></a> 184 </th> 185<td>The RSA key class.</td> 186 </tr> </table> 187 </div> 188 </a> <a name="typedef" id="typedef"> 189<h2>typedef Definitions</h2> 190 <div class="section"> 191 <table class="members"> 192 <tr> 193 <td width="100" /> 194 <th> 195<a href="../../nn/crypto/Aes128.html"><CODE>Aes128</CODE></a> 196 </th> 197<td>Class for AES encryption with a key length of 128 bits.</td> 198 </tr> 199 <tr> 200 <td width="100" /> 201 <th> 202<a href="../../nn/crypto/Aes192.html"><CODE>Aes192</CODE></a> 203 </th> 204<td>Class for AES encryption with a key length of 192 bits.</td> 205 </tr> 206 <tr> 207 <td width="100" /> 208 <th> 209<a href="../../nn/crypto/Aes256.html"><CODE>Aes256</CODE></a> 210 </th> 211<td>Class for AES encryption with a key length of 256 bits.</td> 212 </tr> 213 <tr> 214 <td width="100" /> 215 <th> 216<a href="../../nn/crypto/CtrDecryptor128.html"><CODE>CtrDecryptor128</CODE></a> 217 </th> 218<td><CODE><a href="../../nn/crypto/CtrDecryptor/Overview.html">CtrDecryptor</a></CODE> class for a block size of 128 bits.</td> 219 </tr> 220 <tr> 221 <td width="100" /> 222 <th> 223<a href="../../nn/crypto/CtrEncryptor128.html"><CODE>CtrEncryptor128</CODE></a> 224 </th> 225<td><CODE><a href="../../nn/crypto/CtrEncryptor/Overview.html">CtrEncryptor</a></CODE> class for a block size of 128 bits.</td> 226 </tr> </table> 227 </div> 228 </a> <a name="constant" id="constant"> 229<h2>Constants</h2> 230 <div class="section"> 231 <table class="members"> 232 <tr> 233 <td width="100"> </td> 234 <th> 235<span class="argument"><a href="../../nn/crypto/ENCRYPT_HEADER_SIZE.html"><CODE>ENCRYPT_HEADER_SIZE</CODE></a></span> 236 </th> 237<td width="100"><CODE>const size_t</CODE></td> 238<td>Amount by which data size increases when encrypted using the <CODE><a href="../../nn/crypto/EncryptAes128Ctr.html">EncryptAes128Ctr</a></CODE> function.</td> 239 </tr> 240 <tr> 241 <td width="100"> </td> 242 <th> 243<span class="argument"><a href="../../nn/crypto/GENERATE_HEADER_SIZE.html"><CODE>GENERATE_HEADER_SIZE</CODE></a></span> 244 </th> 245<td width="100"><CODE>const size_t</CODE></td> 246<td>Amount by which data size increases when encrypted using the <CODE><a href="../../nn/crypto/EncryptAndGenerateAes128Ccm.html">EncryptAndGenerateAes128Ccm</a></CODE> function.</td> 247 </tr> </table> 248 </div> 249 </a> <a name="function" id="function"> 250<h2>Functions</h2> 251 <div class="section"> 252 <table class="members"> 253 <tr> 254 <td width="100"> </td> 255 <th> 256<a href="../../nn/crypto/EncryptAes128Ctr.html"><CODE>EncryptAes128Ctr</CODE></a> 257 </th> 258<td>Encrypts.</td> 259 </tr> 260 <tr> 261 <td width="100"> </td> 262 <th> 263<a href="../../nn/crypto/DecryptAes128Ctr.html"><CODE>DecryptAes128Ctr</CODE></a> 264 </th> 265<td>Decrypts.</td> 266 </tr> 267 <tr> 268 <td width="100"> </td> 269 <th> 270<a href="../../nn/crypto/EncryptAndGenerateAes128Ccm.html"><CODE>EncryptAndGenerateAes128Ccm</CODE></a> 271 </th> 272<td>Encrypts and generates data for tampering tests.</td> 273 </tr> 274 <tr> 275 <td width="100"> </td> 276 <th> 277<a href="../../nn/crypto/DecryptAndVerifyAes128Ccm.html"><CODE>DecryptAndVerifyAes128Ccm</CODE></a> 278 </th> 279<td>Decrypts and tests for tampering.<BR></td> 280 </tr> 281 <tr> 282 <td width="100"> </td> 283 <th> 284<a href="../../nn/crypto/GenerateRandomBytes.html"><CODE>GenerateRandomBytes</CODE></a> 285 </th> 286<td>Generates a pseudo-random number.</td> 287 </tr> 288 <tr> 289 <td width="100"> </td> 290 <th> 291<a href="../../nn/crypto/CalculateHmacSha1.html"><CODE>CalculateHmacSha1</CODE></a> 292 </th> 293<td>Performs HMAC-SHA1 calculation.</td> 294 </tr> 295 <tr> 296 <td width="100"> </td> 297 <th> 298<a href="../../nn/crypto/CalculateHmacSha256.html"><CODE>CalculateHmacSha256</CODE> </a> 299 </th> 300<td>Performs HMAC-SHA256 calculation.</td> 301 </tr> 302 <tr> 303 <td width="100"> </td> 304 <th> 305<a href="../../nn/crypto/CalculateSha1.html"><CODE>CalculateSha1</CODE></a> 306 </th> 307<td>Utility function that encompasses a sequence of operations used for SHA-1 calculation.</td> 308 </tr> 309 <tr> 310 <td width="100"> </td> 311 <th> 312<a href="../../nn/crypto/CalculateSha256.html"><CODE>CalculateSha256</CODE></a> 313 </th> 314<td>Utility function that encompasses a sequence of operations used for SHA-256 calculation.</td> 315 </tr> </table> 316 </div> 317 </a> 318<h2>Revision History</h2> 319 <div class="section"> 320 <dl class="history"> 321 <dt>2011/10/27</dt> 322<dd>Added explanation of the block cipher API.<br /> 323 </dd> 324 <dt>2010/01/07</dt> 325<dd>Initial version.<br /> 326 </dd> 327 </dl> 328 </div> 329 <hr><p>CONFIDENTIAL</p></body> 330</html>