Skip to content

Commit 3688754

Browse files
committed
Moved to 151b01, added extra example/test to AEADTest class.
1 parent 9f8a531 commit 3688754

3 files changed

Lines changed: 63 additions & 5 deletions

File tree

bc-build.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
release.suffix: 150
3-
release.name: 1.50
4-
release.debug: false
2+
release.suffix: 151b01
3+
release.name: 1.51b01
4+
release.debug: true
55

66
mail.jar.home: /opt/javamail/mail.jar
77
activation.jar.home: /opt/jaf/activation.jar

prov/src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public final class BouncyCastleProvider extends Provider
4545
implements ConfigurableProvider
4646
{
47-
private static String info = "BouncyCastle Security Provider v1.50";
47+
private static String info = "BouncyCastle Security Provider v1.51b";
4848

4949
public static final String PROVIDER_NAME = "BC";
5050

@@ -117,7 +117,7 @@ public final class BouncyCastleProvider extends Provider
117117
*/
118118
public BouncyCastleProvider()
119119
{
120-
super(PROVIDER_NAME, 1.50, info);
120+
super(PROVIDER_NAME, 1.505, info);
121121

122122
AccessController.doPrivileged(new PrivilegedAction()
123123
{

prov/src/test/java/org/bouncycastle/jce/provider/test/AEADTest.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.security.InvalidKeyException;
77
import java.security.NoSuchAlgorithmException;
88
import java.security.NoSuchProviderException;
9+
import java.security.SecureRandom;
910
import java.security.Security;
1011
import java.security.spec.InvalidParameterSpecException;
1112

@@ -55,6 +56,7 @@ public void performTest() throws Exception
5556
testGCMParameterSpec(K2, N2, A2, P2, C2);
5657
testGCMParameterSpecWithRepeatKey(K2, N2, A2, P2, C2);
5758
testGCMGeneric(KGCM, NGCM, new byte[0], new byte[0], CGCM);
59+
testGCMParameterSpecWithMultipleUpdates(K2, N2, A2, P2, C2);
5860
}
5961
catch (ClassNotFoundException e)
6062
{
@@ -141,6 +143,62 @@ private void testGCMParameterSpec(byte[] K,
141143
}
142144
}
143145

146+
private void testGCMParameterSpecWithMultipleUpdates(byte[] K,
147+
byte[] N,
148+
byte[] A,
149+
byte[] P,
150+
byte[] C)
151+
throws Exception
152+
{
153+
Cipher eax = Cipher.getInstance("AES/EAX/NoPadding", "BC");
154+
SecretKeySpec key = new SecretKeySpec(K, "AES");
155+
SecureRandom random = new SecureRandom();
156+
157+
// GCMParameterSpec mapped to AEADParameters and overrides default MAC
158+
// size
159+
GCMParameterSpec spec = new GCMParameterSpec(128, N);
160+
161+
for (int i = 900; i != 1024; i++)
162+
{
163+
byte[] message = new byte[i];
164+
165+
random.nextBytes(message);
166+
167+
eax.init(Cipher.ENCRYPT_MODE, key, spec);
168+
169+
byte[] out = new byte[eax.getOutputSize(i)];
170+
171+
int offSet = 0;
172+
173+
int count;
174+
for (count = 0; count < i / 21; count++)
175+
{
176+
offSet += eax.update(message, count * 21, 21, out, offSet);
177+
}
178+
179+
offSet += eax.doFinal(message, count * 21, i - (count * 21), out, offSet);
180+
181+
byte[] dec = new byte[i];
182+
int len = offSet;
183+
184+
eax.init(Cipher.DECRYPT_MODE, key, spec);
185+
186+
offSet = 0;
187+
for (count = 0; count < len / 10; count++)
188+
{
189+
offSet += eax.update(out, count * 10, 10, dec, offSet);
190+
}
191+
192+
offSet += eax.doFinal(out, count * 10, len - (count * 10), dec, offSet);
193+
194+
if (!Arrays.areEqual(message, dec) || offSet != message.length)
195+
{
196+
fail("message mismatch");
197+
}
198+
}
199+
}
200+
201+
144202
private void testGCMParameterSpecWithRepeatKey(byte[] K,
145203
byte[] N,
146204
byte[] A,

0 commit comments

Comments
 (0)