Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2013-06-20 09:50:40 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2013-06-20 09:50:40 +0400
commit8239473e2e25dfcbc495bfd90d708feba6c056fd (patch)
treef673e727785d480acb042adf779ef2da718eacb4 /core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
parentbc3ab6397c3bd2fcf68aa9b597eb6014b33f6050 (diff)
New utility method and refactoring related to extension data
Diffstat (limited to 'core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java')
-rw-r--r--core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java40
1 files changed, 12 insertions, 28 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
index 5bb6fe7a..890e7280 100644
--- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
+++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
@@ -46,30 +46,14 @@ public class TlsECCUtils
public static int[] getSupportedEllipticCurvesExtension(Hashtable extensions) throws IOException
{
- if (extensions == null)
- {
- return null;
- }
- byte[] extensionValue = (byte[]) extensions.get(EXT_elliptic_curves);
- if (extensionValue == null)
- {
- return null;
- }
- return readSupportedEllipticCurvesExtension(extensionValue);
+ byte[] extensionData = TlsUtils.getExtensionData(extensions, EXT_elliptic_curves);
+ return extensionData == null ? null : readSupportedEllipticCurvesExtension(extensionData);
}
public static short[] getSupportedPointFormatsExtension(Hashtable extensions) throws IOException
{
- if (extensions == null)
- {
- return null;
- }
- byte[] extensionValue = (byte[]) extensions.get(EXT_ec_point_formats);
- if (extensionValue == null)
- {
- return null;
- }
- return readSupportedPointFormatsExtension(extensionValue);
+ byte[] extensionData = TlsUtils.getExtensionData(extensions, EXT_ec_point_formats);
+ return extensionData == null ? null : readSupportedPointFormatsExtension(extensionData);
}
public static byte[] createSupportedEllipticCurvesExtension(int[] namedCurves) throws IOException
@@ -112,14 +96,14 @@ public class TlsECCUtils
return buf.toByteArray();
}
- public static int[] readSupportedEllipticCurvesExtension(byte[] extensionValue) throws IOException
+ public static int[] readSupportedEllipticCurvesExtension(byte[] extensionData) throws IOException
{
- if (extensionValue == null)
+ if (extensionData == null)
{
- throw new IllegalArgumentException("'extensionValue' cannot be null");
+ throw new IllegalArgumentException("'extensionData' cannot be null");
}
- ByteArrayInputStream buf = new ByteArrayInputStream(extensionValue);
+ ByteArrayInputStream buf = new ByteArrayInputStream(extensionData);
int length = TlsUtils.readUint16(buf);
if (length < 2 || (length & 1) != 0)
@@ -134,14 +118,14 @@ public class TlsECCUtils
return namedCurves;
}
- public static short[] readSupportedPointFormatsExtension(byte[] extensionValue) throws IOException
+ public static short[] readSupportedPointFormatsExtension(byte[] extensionData) throws IOException
{
- if (extensionValue == null)
+ if (extensionData == null)
{
- throw new IllegalArgumentException("'extensionValue' cannot be null");
+ throw new IllegalArgumentException("'extensionData' cannot be null");
}
- ByteArrayInputStream buf = new ByteArrayInputStream(extensionValue);
+ ByteArrayInputStream buf = new ByteArrayInputStream(extensionData);
short length = TlsUtils.readUint8(buf);
if (length < 1)