Skip to content

Commit 82bf36d

Browse files
committed
removed use of Cipher class!
1 parent 1855db8 commit 82bf36d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

core/src/test/java/org/bouncycastle/pqc/legacy/crypto/test/QTESLASecureRandomFactory.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.bouncycastle.pqc.legacy.crypto.test;
22

3-
import javax.crypto.Cipher;
4-
import javax.crypto.spec.SecretKeySpec;
5-
3+
import org.bouncycastle.crypto.BufferedBlockCipher;
4+
import org.bouncycastle.crypto.DefaultBufferedBlockCipher;
5+
import org.bouncycastle.crypto.engines.AESEngine;
6+
import org.bouncycastle.crypto.params.KeyParameter;
67
import org.bouncycastle.util.test.FixedSecureRandom;
78

89
/**
@@ -113,11 +114,13 @@ private void AES256_ECB(byte[] key, byte[] ctr, byte[] buffer, int startPosition
113114
{
114115
try
115116
{
116-
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
117+
BufferedBlockCipher bufferedBlockCipher = new DefaultBufferedBlockCipher(AESEngine.newInstance());
118+
119+
bufferedBlockCipher.init(true, new KeyParameter(key));
117120

118-
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
121+
int len = bufferedBlockCipher.processBytes(ctr, 0, ctr.length, buffer, startPosition);
119122

120-
cipher.doFinal(ctr, 0, ctr.length, buffer, startPosition);
123+
bufferedBlockCipher.doFinal(buffer, len);
121124
}
122125
catch (Throwable ex)
123126
{

0 commit comments

Comments
 (0)