Skip to content

Commit 7576e8f

Browse files
committed
rewrote to remove use of Cipher class.
1 parent b9203d2 commit 7576e8f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

core/src/test/java/org/bouncycastle/pqc/crypto/test/NISTSecureRandom.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import java.security.SecureRandom;
44

5-
import javax.crypto.Cipher;
6-
import javax.crypto.spec.SecretKeySpec;
7-
5+
import org.bouncycastle.crypto.engines.AESEngine;
6+
import org.bouncycastle.crypto.params.KeyParameter;
87
import org.bouncycastle.util.test.FixedSecureRandom;
98

109
/**
@@ -118,11 +117,14 @@ private void AES256_ECB(byte[] key, byte[] ctr, byte[] buffer, int startPosition
118117
{
119118
try
120119
{
121-
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
120+
AESEngine cipher = new AESEngine();
122121

123-
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
122+
cipher.init(true, new KeyParameter(key));
124123

125-
cipher.doFinal(ctr, 0, ctr.length, buffer, startPosition);
124+
for (int i = 0; i != ctr.length; i += 16)
125+
{
126+
cipher.processBlock(ctr, i, buffer, startPosition + i);
127+
}
126128
}
127129
catch (Throwable ex)
128130
{

0 commit comments

Comments
 (0)