@@ -12,25 +12,25 @@ abstract class AEADBufferBaseEngine
1212{
1313 protected enum ProcessingBufferType
1414 {
15- Buffered ,
16- BufferedLargeMac ,
17- Immediate ,
18- ImmediateLargeMac ,
15+ Buffered , // Store a (aad) block size of input and process after the input size exceeds the buffer size
16+ BufferedLargeMac , // handle the situation when mac size is larger than the block size, used for pb128
17+ Immediate , //process the input immediately when the input size is equal or greater than the block size
18+ ImmediateLargeMac , // handle the situation when mac size is larger than the block size, used for ascon80pq, ascon128, ISAP_A_128(A)
1919 }
2020
2121 protected enum AADOperatorType
2222 {
2323 Default ,
24- Counter ,
25- Stream
24+ Counter ,//add a counter to count the size of AAD
25+ Stream //process AAD data during the process data, used for elephant
2626 }
2727
2828 protected enum DataOperatorType
2929 {
3030 Default ,
3131 Counter ,
3232 Stream ,
33- //StreamCipher
33+ //StreamCipher //TODO: add for Grain 128 AEAD
3434 }
3535
3636 protected enum State
@@ -525,6 +525,7 @@ protected int processEncDecBytes(byte[] input, int inOff, int len, byte[] output
525525 if (m_bufPos > 0 )
526526 {
527527 available = BlockSize - m_bufPos ;
528+ // The function is just an operator < or <=
528529 if (processor .isLengthWithinAvailableSpace (len , available ))
529530 {
530531 System .arraycopy (input , inOff , m_buf , m_bufPos , len );
@@ -538,6 +539,7 @@ protected int processEncDecBytes(byte[] input, int inOff, int len, byte[] output
538539 processBufferEncrypt (m_buf , 0 , output , outOff );
539540 resultLength = BlockSize ;
540541 }
542+ // The function is just an operator >= or >
541543 while (processor .isLengthExceedingBlockSize (len , BlockSize ))
542544 {
543545 processBufferEncrypt (input , inOff , output , outOff + resultLength );
@@ -583,6 +585,8 @@ protected int processEncDecBytes(byte[] input, int inOff, int len, byte[] output
583585 private int processDecryptionWithLargeMacSize (byte [] input , int inOff , int len , byte [] output , int outOff )
584586 {
585587 int resultLength = 0 , available ;
588+ // If the mac size is greater than the block size, process the data in m_buf in the loop until
589+ // there is nearly mac_size data left
586590 while (processor .isLengthExceedingBlockSize (m_bufPos , BlockSize )
587591 && processor .isLengthExceedingBlockSize (len + m_bufPos , m_bufferSizeDecrypt ))
588592 {
0 commit comments