Skip to content

Commit f8c09c9

Browse files
author
gefeili
committed
Fix the issue for #2025
1 parent 050c9a4 commit f8c09c9

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

core/src/main/java/org/bouncycastle/crypto/engines/AEADBufferBaseEngine.java

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected enum DataOperatorType
2828
Default,
2929
Counter,
3030
Stream,
31-
//StreamCipher //TODO: add for Grain 128 AEAD
31+
StreamCipher
3232
}
3333

3434
protected enum State
@@ -99,9 +99,10 @@ protected void setInnerMembers(ProcessingBufferType type, AADOperatorType aadOpe
9999
m_buf = new byte[MAC_SIZE];
100100
dataOperator = new StreamDataOperator();
101101
break;
102-
// case StreamCipher:
103-
// dataOperator = new StreamCipherOperator();
104-
// break;
102+
case StreamCipher:
103+
m_buf = new byte[m_bufferSizeDecrypt];
104+
dataOperator = new StreamCipherOperator();
105+
break;
105106
}
106107
}
107108

@@ -368,30 +369,38 @@ public void reset()
368369
}
369370
}
370371

371-
// protected class StreamCipherOperator
372-
// implements DataOperator
373-
// {
374-
// private int len;
375-
// @Override
376-
// public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff)
377-
// {
378-
// this.len = len;
379-
// processBufferEncrypt(input, inOff, output, outOff);
380-
// return len;
381-
// }
382-
//
383-
// @Override
384-
// public int getLen()
385-
// {
386-
// return 0;
387-
// }
388-
//
389-
// @Override
390-
// public void reset()
391-
// {
392-
//
393-
// }
394-
// }
372+
protected class StreamCipherOperator
373+
implements DataOperator
374+
{
375+
private int len;
376+
377+
@Override
378+
public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff)
379+
{
380+
this.len = len;
381+
if (forEncryption)
382+
{
383+
processBufferEncrypt(input, inOff, output, outOff);
384+
}
385+
else
386+
{
387+
processBufferDecrypt(input, inOff, output, outOff);
388+
}
389+
return len;
390+
}
391+
392+
@Override
393+
public int getLen()
394+
{
395+
return 0;
396+
}
397+
398+
@Override
399+
public void reset()
400+
{
401+
402+
}
403+
}
395404

396405
protected static final class ErasableOutputStream
397406
extends ByteArrayOutputStream

core/src/main/java/org/bouncycastle/crypto/engines/PhotonBeetleEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected void finishAAD(State nextState, boolean isDoFinal)
116116
m_state = nextState;
117117
}
118118

119-
public void processFinalAAD()
119+
protected void processFinalAAD()
120120
{
121121
int aadLen = aadOperator.getLen();
122122
if (aadLen != 0)

0 commit comments

Comments
 (0)