Skip to content

Commit

Permalink
code refine
Browse files Browse the repository at this point in the history
  • Loading branch information
Xianda Ke committed May 31, 2017
1 parent 9be5d80 commit 22c98a3
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public OpenSslGaloisCounterMode(long context, int algorithmMode, int padding) {
public void init(int mode, byte[] key, AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {

if (aadBuffer == null) {
aadBuffer = new ByteArrayOutputStream();
} else {
aadBuffer.reset();
}

this.cipherMode = mode;
byte[] iv;
if (params instanceof GCMParameterSpec) {
Expand Down Expand Up @@ -255,6 +261,11 @@ public int doFinal(ByteBuffer input, ByteBuffer output)
return totalLen;
}

public void clean() {
super.clean();
aadBuffer = null;
}

@Override
public void updateAAD(byte[] aad) {
// must be called after initialized.
Expand Down

0 comments on commit 22c98a3

Please sign in to comment.