Package org.bouncycastle.crypto.tls
Class TlsECCUtils
- java.lang.Object
-
- org.bouncycastle.crypto.tls.TlsECCUtils
-
public class TlsECCUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Integer
EXT_ec_point_formats
static java.lang.Integer
EXT_elliptic_curves
-
Constructor Summary
Constructors Constructor Description TlsECCUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addSupportedEllipticCurvesExtension(java.util.Hashtable extensions, int[] namedCurves)
static void
addSupportedPointFormatsExtension(java.util.Hashtable extensions, short[] ecPointFormats)
static boolean
areOnSameCurve(ECDomainParameters a, ECDomainParameters b)
static byte[]
calculateECDHBasicAgreement(ECPublicKeyParameters publicKey, ECPrivateKeyParameters privateKey)
static boolean
containsECCCipherSuites(int[] cipherSuites)
static byte[]
createSupportedEllipticCurvesExtension(int[] namedCurves)
static byte[]
createSupportedPointFormatsExtension(short[] ecPointFormats)
static java.math.BigInteger
deserializeECFieldElement(int fieldSize, byte[] encoding)
static ECPoint
deserializeECPoint(short[] ecPointFormats, ECCurve curve, byte[] encoding)
static ECPublicKeyParameters
deserializeECPublicKey(short[] ecPointFormats, ECDomainParameters curve_params, byte[] encoding)
static AsymmetricCipherKeyPair
generateECKeyPair(java.security.SecureRandom random, ECDomainParameters ecParams)
static ECPrivateKeyParameters
generateEphemeralClientKeyExchange(java.security.SecureRandom random, short[] ecPointFormats, ECDomainParameters ecParams, java.io.OutputStream output)
static java.lang.String
getNameOfNamedCurve(int namedCurve)
static ECDomainParameters
getParametersForNamedCurve(int namedCurve)
static int[]
getSupportedEllipticCurvesExtension(java.util.Hashtable extensions)
static short[]
getSupportedPointFormatsExtension(java.util.Hashtable extensions)
static boolean
hasAnySupportedNamedCurves()
static boolean
isCompressionPreferred(short[] ecPointFormats, short compressionFormat)
static boolean
isECCCipherSuite(int cipherSuite)
static boolean
isSupportedNamedCurve(int namedCurve)
static int
readECExponent(int fieldSize, java.io.InputStream input)
static java.math.BigInteger
readECFieldElement(int fieldSize, java.io.InputStream input)
static java.math.BigInteger
readECParameter(java.io.InputStream input)
static ECDomainParameters
readECParameters(int[] namedCurves, short[] ecPointFormats, java.io.InputStream input)
static int[]
readSupportedEllipticCurvesExtension(byte[] extensionData)
static short[]
readSupportedPointFormatsExtension(byte[] extensionData)
static byte[]
serializeECFieldElement(int fieldSize, java.math.BigInteger x)
static byte[]
serializeECPoint(short[] ecPointFormats, ECPoint point)
static byte[]
serializeECPublicKey(short[] ecPointFormats, ECPublicKeyParameters keyParameters)
static ECPublicKeyParameters
validateECPublicKey(ECPublicKeyParameters key)
static void
writeECExponent(int k, java.io.OutputStream output)
static void
writeECFieldElement(int fieldSize, java.math.BigInteger x, java.io.OutputStream output)
static void
writeECFieldElement(ECFieldElement x, java.io.OutputStream output)
static void
writeECParameter(java.math.BigInteger x, java.io.OutputStream output)
static void
writeECPoint(short[] ecPointFormats, ECPoint point, java.io.OutputStream output)
static void
writeExplicitECParameters(short[] ecPointFormats, ECDomainParameters ecParameters, java.io.OutputStream output)
static void
writeNamedECParameters(int namedCurve, java.io.OutputStream output)
-
-
-
Method Detail
-
addSupportedEllipticCurvesExtension
public static void addSupportedEllipticCurvesExtension(java.util.Hashtable extensions, int[] namedCurves) throws java.io.IOException
- Throws:
java.io.IOException
-
addSupportedPointFormatsExtension
public static void addSupportedPointFormatsExtension(java.util.Hashtable extensions, short[] ecPointFormats) throws java.io.IOException
- Throws:
java.io.IOException
-
getSupportedEllipticCurvesExtension
public static int[] getSupportedEllipticCurvesExtension(java.util.Hashtable extensions) throws java.io.IOException
- Throws:
java.io.IOException
-
getSupportedPointFormatsExtension
public static short[] getSupportedPointFormatsExtension(java.util.Hashtable extensions) throws java.io.IOException
- Throws:
java.io.IOException
-
createSupportedEllipticCurvesExtension
public static byte[] createSupportedEllipticCurvesExtension(int[] namedCurves) throws java.io.IOException
- Throws:
java.io.IOException
-
createSupportedPointFormatsExtension
public static byte[] createSupportedPointFormatsExtension(short[] ecPointFormats) throws java.io.IOException
- Throws:
java.io.IOException
-
readSupportedEllipticCurvesExtension
public static int[] readSupportedEllipticCurvesExtension(byte[] extensionData) throws java.io.IOException
- Throws:
java.io.IOException
-
readSupportedPointFormatsExtension
public static short[] readSupportedPointFormatsExtension(byte[] extensionData) throws java.io.IOException
- Throws:
java.io.IOException
-
getNameOfNamedCurve
public static java.lang.String getNameOfNamedCurve(int namedCurve)
-
getParametersForNamedCurve
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
-
hasAnySupportedNamedCurves
public static boolean hasAnySupportedNamedCurves()
-
containsECCCipherSuites
public static boolean containsECCCipherSuites(int[] cipherSuites)
-
isECCCipherSuite
public static boolean isECCCipherSuite(int cipherSuite)
-
areOnSameCurve
public static boolean areOnSameCurve(ECDomainParameters a, ECDomainParameters b)
-
isSupportedNamedCurve
public static boolean isSupportedNamedCurve(int namedCurve)
-
isCompressionPreferred
public static boolean isCompressionPreferred(short[] ecPointFormats, short compressionFormat)
-
serializeECFieldElement
public static byte[] serializeECFieldElement(int fieldSize, java.math.BigInteger x) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeECPoint
public static byte[] serializeECPoint(short[] ecPointFormats, ECPoint point) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeECPublicKey
public static byte[] serializeECPublicKey(short[] ecPointFormats, ECPublicKeyParameters keyParameters) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeECFieldElement
public static java.math.BigInteger deserializeECFieldElement(int fieldSize, byte[] encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeECPoint
public static ECPoint deserializeECPoint(short[] ecPointFormats, ECCurve curve, byte[] encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeECPublicKey
public static ECPublicKeyParameters deserializeECPublicKey(short[] ecPointFormats, ECDomainParameters curve_params, byte[] encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
calculateECDHBasicAgreement
public static byte[] calculateECDHBasicAgreement(ECPublicKeyParameters publicKey, ECPrivateKeyParameters privateKey)
-
generateECKeyPair
public static AsymmetricCipherKeyPair generateECKeyPair(java.security.SecureRandom random, ECDomainParameters ecParams)
-
generateEphemeralClientKeyExchange
public static ECPrivateKeyParameters generateEphemeralClientKeyExchange(java.security.SecureRandom random, short[] ecPointFormats, ECDomainParameters ecParams, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
validateECPublicKey
public static ECPublicKeyParameters validateECPublicKey(ECPublicKeyParameters key) throws java.io.IOException
- Throws:
java.io.IOException
-
readECExponent
public static int readECExponent(int fieldSize, java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
readECFieldElement
public static java.math.BigInteger readECFieldElement(int fieldSize, java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
readECParameter
public static java.math.BigInteger readECParameter(java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
readECParameters
public static ECDomainParameters readECParameters(int[] namedCurves, short[] ecPointFormats, java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
writeECExponent
public static void writeECExponent(int k, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeECFieldElement
public static void writeECFieldElement(ECFieldElement x, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeECFieldElement
public static void writeECFieldElement(int fieldSize, java.math.BigInteger x, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeECParameter
public static void writeECParameter(java.math.BigInteger x, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeExplicitECParameters
public static void writeExplicitECParameters(short[] ecPointFormats, ECDomainParameters ecParameters, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeECPoint
public static void writeECPoint(short[] ecPointFormats, ECPoint point, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeNamedECParameters
public static void writeNamedECParameters(int namedCurve, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
-