diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-05-21 04:46:17 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-05-21 04:46:17 +0400 |
commit | de990a9ff495480a8e61922ba87dba7511025a31 (patch) | |
tree | 5983976a18072ee8a1d4f45aeff145c123df6873 | |
parent | 3f6165d46f132ffcc9b30c27bfea5bcf88dd6b4c (diff) |
JDK 1.4 updates
9 files changed, 42 insertions, 21 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/macs/GMac.java b/src/main/java/org/bouncycastle/crypto/macs/GMac.java index 91bfe13d..ce29f8f7 100644 --- a/src/main/java/org/bouncycastle/crypto/macs/GMac.java +++ b/src/main/java/org/bouncycastle/crypto/macs/GMac.java @@ -63,7 +63,8 @@ public class GMac implements Mac // GCM is always operated in encrypt mode to calculate MAC cipher.init(true, new AEADParameters(keyParam, macSizeBits, iv)); - } else + } + else { throw new IllegalArgumentException("GMAC requires ParametersWithIV"); } @@ -84,20 +85,23 @@ public class GMac implements Mac cipher.processAADByte(in); } - public void update(byte[] in, int inOff, int len) throws DataLengthException, IllegalStateException + public void update(byte[] in, int inOff, int len) + throws DataLengthException, IllegalStateException { cipher.processAADBytes(in, inOff, len); } - public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException + public int doFinal(byte[] out, int outOff) + throws DataLengthException, IllegalStateException { try { return cipher.doFinal(out, outOff); - } catch (InvalidCipherTextException e) + } + catch (InvalidCipherTextException e) { // Impossible in encrypt mode - throw new IllegalStateException(e); + throw new IllegalStateException(e.toString()); } } diff --git a/src/main/java/org/bouncycastle/crypto/tls/Certificate.java b/src/main/java/org/bouncycastle/crypto/tls/Certificate.java index cdb8ff6e..0c87d928 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/Certificate.java +++ b/src/main/java/org/bouncycastle/crypto/tls/Certificate.java @@ -46,7 +46,7 @@ public class Certificate */
public org.bouncycastle.asn1.x509.Certificate[] getCerts()
{
- return certificateList.clone();
+ return clone(certificateList);
}
/**
@@ -55,7 +55,7 @@ public class Certificate */
public org.bouncycastle.asn1.x509.Certificate[] getCertificateList()
{
- return certificateList.clone();
+ return clone(certificateList);
}
public org.bouncycastle.asn1.x509.Certificate getCertificateAt(int index)
@@ -141,4 +141,13 @@ public class Certificate }
return new Certificate(certs);
}
+
+ private org.bouncycastle.asn1.x509.Certificate[] clone(org.bouncycastle.asn1.x509.Certificate[] list)
+ {
+ org.bouncycastle.asn1.x509.Certificate[] rv = new org.bouncycastle.asn1.x509.Certificate[list.length];
+
+ System.arraycopy(list, 0, rv, 0, rv.length);
+
+ return rv;
+ }
}
diff --git a/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java b/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java index 91b701aa..7e3e3c6a 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java +++ b/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java @@ -6,6 +6,8 @@ import java.util.Enumeration; import java.util.Hashtable;
import java.util.Vector;
+import org.bouncycastle.util.Integers;
+
class DTLSReliableHandshake
{
@@ -72,7 +74,7 @@ class DTLSReliableHandshake // Check if we already have the next message waiting
{
- DTLSReassembler next = (DTLSReassembler)currentInboundFlight.get(Integer.valueOf(next_receive_seq));
+ DTLSReassembler next = (DTLSReassembler)currentInboundFlight.get(Integers.valueOf(next_receive_seq));
if (next != null)
{
byte[] body = next.getBodyIfComplete();
@@ -139,7 +141,7 @@ class DTLSReliableHandshake */
if (previousInboundFlight != null)
{
- DTLSReassembler reassembler = (DTLSReassembler)previousInboundFlight.get(Integer
+ DTLSReassembler reassembler = (DTLSReassembler)previousInboundFlight.get(Integers
.valueOf(seq));
if (reassembler != null)
{
@@ -166,11 +168,11 @@ class DTLSReliableHandshake else
{
- DTLSReassembler reassembler = (DTLSReassembler)currentInboundFlight.get(Integer.valueOf(seq));
+ DTLSReassembler reassembler = (DTLSReassembler)currentInboundFlight.get(Integers.valueOf(seq));
if (reassembler == null)
{
reassembler = new DTLSReassembler(msg_type, length);
- currentInboundFlight.put(Integer.valueOf(seq), reassembler);
+ currentInboundFlight.put(Integers.valueOf(seq), reassembler);
}
reassembler.contributeFragment(msg_type, length, buf, 12, fragment_offset, fragment_length);
@@ -258,7 +260,7 @@ class DTLSReliableHandshake return;
}
- DTLSReassembler reassembler = (DTLSReassembler)currentInboundFlight.get(Integer.valueOf(seq));
+ DTLSReassembler reassembler = (DTLSReassembler)currentInboundFlight.get(Integers.valueOf(seq));
if (reassembler != null)
{
reassembler.contributeFragment(msg_type, length, buf, off + 12, fragment_offset,
diff --git a/src/test/java/org/bouncycastle/crypto/test/GMacTest.java b/src/test/java/org/bouncycastle/crypto/test/GMacTest.java index d8196f96..19026a37 100644 --- a/src/test/java/org/bouncycastle/crypto/test/GMacTest.java +++ b/src/test/java/org/bouncycastle/crypto/test/GMacTest.java @@ -126,7 +126,8 @@ public class GMacTest extends SimpleTest GMac mac = new GMac(new GCMBlockCipher(new AESFastEngine()), size); mac.init(new ParametersWithIV(null, new byte[16])); fail("Expected failure for illegal mac size " + size); - } catch (IllegalArgumentException e) + } + catch (IllegalArgumentException e) { } } diff --git a/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSClient.java b/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSClient.java index 46ae7e68..3170ad78 100644 --- a/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSClient.java +++ b/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSClient.java @@ -58,8 +58,9 @@ public class MockDTLSClient { Certificate[] chain = serverCertificate.getCertificateList(); System.out.println("Received server certificate chain of length " + chain.length); - for (Certificate entry : chain) + for (int i = 0; i != chain.length; i++) { + Certificate entry = chain[i]; // TODO Create fingerprint based on certificate signature algorithm digest System.out.println(" fingerprint:SHA-256 " + TlsTestUtils.fingerprint(entry) + " (" + entry.getSubject() + ")"); diff --git a/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSServer.java b/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSServer.java index 89368411..9f64e0a0 100644 --- a/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSServer.java +++ b/src/test/java/org/bouncycastle/crypto/tls/test/MockDTLSServer.java @@ -48,8 +48,9 @@ public class MockDTLSServer { Certificate[] chain = clientCertificate.getCertificateList(); System.out.println("Received client certificate chain of length " + chain.length); - for (Certificate entry : chain) + for (int i = 0; i != chain.length; i++) { + Certificate entry = chain[i]; // TODO Create fingerprint based on certificate signature algorithm digest System.out.println(" fingerprint:SHA-256 " + TlsTestUtils.fingerprint(entry) + " (" + entry.getSubject() + ")"); diff --git a/src/test/java/org/bouncycastle/crypto/tls/test/TlsClientTest.java b/src/test/java/org/bouncycastle/crypto/tls/test/TlsClientTest.java index c7bb8332..18bd0194 100644 --- a/src/test/java/org/bouncycastle/crypto/tls/test/TlsClientTest.java +++ b/src/test/java/org/bouncycastle/crypto/tls/test/TlsClientTest.java @@ -93,8 +93,9 @@ public class TlsClientTest { Certificate[] chain = serverCertificate.getCertificateList(); System.out.println("Received server certificate chain with " + chain.length + " entries"); - for (Certificate entry : chain) + for (int i = 0; i != chain.length; i++) { + Certificate entry = chain[i]; System.out.println(" " + entry.getSubject()); } } diff --git a/src/test/java/org/bouncycastle/crypto/tls/test/TlsProtocolTest.java b/src/test/java/org/bouncycastle/crypto/tls/test/TlsProtocolTest.java index 916b0200..99b47a09 100644 --- a/src/test/java/org/bouncycastle/crypto/tls/test/TlsProtocolTest.java +++ b/src/test/java/org/bouncycastle/crypto/tls/test/TlsProtocolTest.java @@ -120,8 +120,9 @@ public class TlsProtocolTest { Certificate[] chain = serverCertificate.getCertificateList(); System.out.println("Received server certificate chain of length " + chain.length); - for (Certificate entry : chain) + for (int i = 0; i != chain.length; i++) { + Certificate entry = chain[i]; // TODO Create fingerprint based on certificate signature algorithm digest System.out.println(" fingerprint:SHA-256 " + TlsTestUtils.fingerprint(entry) + " (" + entry.getSubject() + ")"); @@ -186,8 +187,9 @@ public class TlsProtocolTest { Certificate[] chain = clientCertificate.getCertificateList(); System.out.println("Received client certificate chain of length " + chain.length); - for (Certificate entry : chain) + for (int i = 0; i != chain.length; i++) { + Certificate entry = chain[i]; // TODO Create fingerprint based on certificate signature algorithm digest System.out.println(" fingerprint:SHA-256 " + TlsTestUtils.fingerprint(entry) + " (" + entry.getSubject() + ")"); diff --git a/src/test/java/org/bouncycastle/jce/provider/test/GMacTest.java b/src/test/java/org/bouncycastle/jce/provider/test/GMacTest.java index 72a4888a..0bbfadf0 100644 --- a/src/test/java/org/bouncycastle/jce/provider/test/GMacTest.java +++ b/src/test/java/org/bouncycastle/jce/provider/test/GMacTest.java @@ -35,8 +35,8 @@ public class GMacTest private void checkRegistrations() throws Exception { - List<String> missingMacs = new ArrayList<String>(); - List<String> missingKeyGens = new ArrayList<String>(); + List missingMacs = new ArrayList(); + List missingKeyGens = new ArrayList(); String[] ciphers = new String[] { "AES", "NOEKEON", "Twofish", "CAST6", "SEED", "Serpent", "RC6", "CAMELLIA" }; String[] macs = new String[] @@ -96,7 +96,7 @@ public class GMacTest } } - private void checkMac(String name, List<String> missingMacs, List<String> missingKeyGens, String macOutput) + private void checkMac(String name, List missingMacs, List missingKeyGens, String macOutput) { try { |