Skip to content

Commit bce43d1

Browse files
author
gefeili
committed
Refactor on AEADBufferBaseEngine, and prepare to make SparkleEngine inherit from AEADBufferBaseEngine.
1 parent d31da08 commit bce43d1

File tree

14 files changed

+455
-448
lines changed

14 files changed

+455
-448
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public int processByte(byte in, byte[] out, int outOff)
5252
return processBytes(new byte[]{in}, 0, 1, out, outOff);
5353
}
5454

55-
protected byte[][] initialize(boolean forEncryption, CipherParameters params)
55+
public void init(boolean forEncryption, CipherParameters params)
5656
{
5757
this.forEncryption = forEncryption;
5858
KeyParameter key;
@@ -101,18 +101,21 @@ else if (params instanceof ParametersWithIV)
101101

102102
CryptoServicesRegistrar.checkConstraints(new DefaultServiceProperties(
103103
this.getAlgorithmName(), 128, params, Utils.getPurpose(forEncryption)));
104-
return new byte[][]{k, npub};
104+
105+
init(k, npub);
106+
if (initialAssociatedText != null)
107+
{
108+
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
109+
}
105110
}
106111

112+
protected abstract void init(byte[] key, byte[] iv);
113+
107114
protected void reset(boolean clearMac)
108115
{
109116
if (clearMac)
110117
{
111118
mac = null;
112119
}
113-
if (initialAssociatedText != null)
114-
{
115-
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
116-
}
117120
}
118121
}

0 commit comments

Comments
 (0)