Skip to content

Commit

Permalink
Refactor on AEADBufferBaseEngine, and prepare to make SparkleEngine i…
Browse files Browse the repository at this point in the history
…nherit from AEADBufferBaseEngine.
  • Loading branch information
gefeili committed Jan 10, 2025
1 parent d31da08 commit bce43d1
Show file tree
Hide file tree
Showing 14 changed files with 455 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public int processByte(byte in, byte[] out, int outOff)
return processBytes(new byte[]{in}, 0, 1, out, outOff);
}

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

CryptoServicesRegistrar.checkConstraints(new DefaultServiceProperties(
this.getAlgorithmName(), 128, params, Utils.getPurpose(forEncryption)));
return new byte[][]{k, npub};

init(k, npub);
if (initialAssociatedText != null)
{
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
}
}

protected abstract void init(byte[] key, byte[] iv);

protected void reset(boolean clearMac)
{
if (clearMac)
{
mac = null;
}
if (initialAssociatedText != null)
{
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
}
}
}
Loading

0 comments on commit bce43d1

Please sign in to comment.