66
77namespace Org . BouncyCastle . Crypto . Engines
88{
9- /**
10- * an implementation of the AES (Rijndael), from FIPS-197.
11- * <p>
12- * For further details see: <a href="http://csrc.nist.gov/encryption/aes/">http://csrc.nist.gov/encryption/aes/</a>.
13- *
14- * This implementation is based on optimizations from Dr. Brian Gladman's paper and C code at
15- * <a href="http://fp.gladman.plus.com/cryptography_technology/rijndael/">http://fp.gladman.plus.com/cryptography_technology/rijndael/</a>
16- *
17- * There are three levels of tradeoff of speed vs memory
18- * Because java has no preprocessor, they are written as three separate classes from which to choose
19- *
20- * The fastest uses 8Kbytes of static tables to precompute round calculations, 4 256 word tables for encryption
21- * and 4 for decryption.
22- *
23- * The middle performance version uses only one 256 word table for each, for a total of 2Kbytes,
24- * adding 12 rotate operations per round to compute the values contained in the other tables from
25- * the contents of the first.
26- *
27- * The slowest version uses no static tables at all and computes the values in each round.
28- * </p>
29- * <p>
30- * This file contains the middle performance version with 2Kbytes of static tables for round precomputation.
31- * </p>
32- */
9+ /// <summary>An implementation of the AES (Rijndael), from FIPS-197.</summary>
10+ /// <remarks>
11+ /// For further details see: <a href="http://csrc.nist.gov/encryption/aes/">http://csrc.nist.gov/encryption/aes/</a>.
12+ /// <para>
13+ /// This implementation is based on optimizations from Dr. Brian Gladman's paper and C code at
14+ /// <a href="http://fp.gladman.plus.com/cryptography_technology/rijndael/">http://fp.gladman.plus.com/cryptography_technology/rijndael/</a>
15+ /// </para>
16+ /// <para>
17+ /// There are three levels of tradeoff of speed vs memory:
18+ /// </para>
19+ /// <list type="bullet">
20+ /// <item>The fastest uses 8Kbytes of static tables to precompute round calculations.</item>
21+ /// <item>The middle performance version uses only one 256 word table for each, for a total of 2Kbytes, adding 12 rotate operations per round.</item>
22+ /// <item>The slowest version uses no static tables at all and computes the values in each round.</item>
23+ /// </list>
24+ /// <para>
25+ /// This file contains the middle performance version with 2Kbytes of static tables for round precomputation.
26+ /// </para>
27+ /// </remarks>
3328 public sealed class AesEngine
3429 : IBlockCipher
3530 {
@@ -437,21 +432,15 @@ private uint[][] GenerateWorkingKey(KeyParameter keyParameter, bool forEncryptio
437432
438433 private const int BLOCK_SIZE = 16 ;
439434
440- /**
441- * default constructor - 128 bit block size.
442- */
435+ /// <summary>Default constructor - 128 bit block size.</summary>
443436 public AesEngine ( )
444437 {
445438 }
446439
447- /**
448- * initialise an AES cipher.
449- *
450- * @param forEncryption whether or not we are for encryption.
451- * @param parameters the parameters required to set up the cipher.
452- * @exception ArgumentException if the parameters argument is
453- * inappropriate.
454- */
440+ /// <summary>Initialise an AES cipher.</summary>
441+ /// <param name="forEncryption">Whether or not we are using it for encryption.</param>
442+ /// <param name="parameters">The parameters required to set up the cipher.</param>
443+ /// <exception cref="ArgumentException">If the parameters argument is inappropriate.</exception>
455444 public void Init ( bool forEncryption , ICipherParameters parameters )
456445 {
457446 if ( ! ( parameters is KeyParameter keyParameter ) )
@@ -464,16 +453,27 @@ public void Init(bool forEncryption, ICipherParameters parameters)
464453 this . s = Arrays . Clone ( forEncryption ? S : Si ) ;
465454 }
466455
456+ /// <summary>The name of the algorithm this engine implements.</summary>
467457 public string AlgorithmName
468458 {
469459 get { return "AES" ; }
470460 }
471461
462+ /// <summary>Return the block size for this cipher (in bytes).</summary>
463+ /// <returns>16 (fixed block size for AES).</returns>
472464 public int GetBlockSize ( )
473465 {
474466 return BLOCK_SIZE ;
475467 }
476468
469+ /// <summary>Process a single block of data.</summary>
470+ /// <param name="input">The input buffer containing the data to be processed.</param>
471+ /// <param name="inOff">The offset into the input buffer.</param>
472+ /// <param name="output">The output buffer to store the result.</param>
473+ /// <param name="outOff">The offset into the output buffer.</param>
474+ /// <returns>The number of bytes processed and produced.</returns>
475+ /// <exception cref="DataLengthException">If the input buffer is too small, or the output buffer is too small.</exception>
476+ /// <exception cref="InvalidOperationException">If the cipher isn't initialised.</exception>
477477 public int ProcessBlock ( byte [ ] input , int inOff , byte [ ] output , int outOff )
478478 {
479479 if ( WorkingKey == null )
0 commit comments