Package org.bouncycastle.tls
Class TlsUtils
- java.lang.Object
-
- org.bouncycastle.tls.TlsUtils
-
public class TlsUtils extends java.lang.ObjectSome helper functions for the TLS API.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]EMPTY_BYTESstatic int[]EMPTY_INTSstatic long[]EMPTY_LONGSstatic short[]EMPTY_SHORTSstatic java.lang.String[]EMPTY_STRINGS
-
Constructor Summary
Constructors Constructor Description TlsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddIfSupported(java.util.Vector supportedGroups, TlsCrypto crypto, int namedGroup)static voidaddIfSupported(java.util.Vector supportedGroups, TlsCrypto crypto, int[] namedGroups)static voidaddIfSupported(java.util.Vector supportedAlgs, TlsCrypto crypto, SignatureAndHashAlgorithm alg)static booleanaddToSet(java.util.Vector s, int i)static byte[]calculateExporterSeed(SecurityParameters securityParameters, byte[] context)static voidcheckPeerSigAlgs(TlsContext context, TlsCertificate[] peerCertPath)Check the signature algorithm for certificates in the peer's CertPath as specified in RFC 5246 7.4.2, 7.4.4, 7.4.6 and similar rules for earlier TLS versions.static voidcheckUint16(int i)static voidcheckUint16(long i)static voidcheckUint24(int i)static voidcheckUint24(long i)static voidcheckUint32(long i)static voidcheckUint48(long i)static voidcheckUint64(long i)static voidcheckUint8(int i)static voidcheckUint8(long i)static voidcheckUint8(short i)static SignatureAndHashAlgorithmchooseSignatureAndHashAlgorithm(ProtocolVersion negotiatedVersion, java.util.Vector sigHashAlgs, short signatureAlgorithm)static SignatureAndHashAlgorithmchooseSignatureAndHashAlgorithm(TlsContext context, java.util.Vector sigHashAlgs, short signatureAlgorithm)static byte[]clone(byte[] data)static java.lang.String[]clone(java.lang.String[] s)static booleanconstantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)static booleancontainsAnySignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, short signatureAlgorithm)static booleancontainsNonAscii(byte[] bs)static booleancontainsNonAscii(java.lang.String s)static booleancontainsSignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, SignatureAndHashAlgorithm signatureAlgorithm)static byte[]copyOfRangeExact(byte[] original, int from, int to)static byte[]decodeOpaque16(byte[] buf)static byte[]decodeOpaque16(byte[] buf, int minLength)static byte[]decodeOpaque8(byte[] buf)static byte[]decodeOpaque8(byte[] buf, int minLength)static intdecodeUint16(byte[] buf)static longdecodeUint32(byte[] buf)static shortdecodeUint8(byte[] buf)static short[]decodeUint8ArrayWithUint8Length(byte[] buf)static byte[]encodeOpaque16(byte[] buf)static byte[]encodeOpaque24(byte[] buf)static byte[]encodeOpaque8(byte[] buf)static voidencodeSupportedSignatureAlgorithms(java.util.Vector supportedSignatureAlgorithms, java.io.OutputStream output)static byte[]encodeUint16(int uint)static byte[]encodeUint16ArrayWithUint16Length(int[] uints)static byte[]encodeUint24(int uint)static byte[]encodeUint32(long uint)static byte[]encodeUint8(short uint)static byte[]encodeUint8ArrayWithUint8Length(short[] uints)static byte[]encodeVersion(ProtocolVersion version)static TlsSecretgenerateEncryptedPreMasterSecret(TlsContext context, TlsEncryptor encryptor, java.io.OutputStream output)Generate a pre_master_secret and send it encrypted to the server.static intgetCipherType(int cipherSuite)static intgetCommonCipherSuite13(ProtocolVersion negotiatedVersion, int[] peerCipherSuites, int[] localCipherSuites, boolean useLocalOrder)static int[]getCommonCipherSuites(int[] peerCipherSuites, int[] localCipherSuites, boolean useLocalOrder)static java.util.VectorgetDefaultDSSSignatureAlgorithms()static java.util.VectorgetDefaultECDSASignatureAlgorithms()static java.util.VectorgetDefaultRSASignatureAlgorithms()static SignatureAndHashAlgorithmgetDefaultSignatureAlgorithm(short signatureAlgorithm)static java.util.VectorgetDefaultSignatureAlgorithms(short signatureAlgorithm)static java.util.VectorgetDefaultSupportedSignatureAlgorithms(TlsContext context)static intgetEncryptionAlgorithm(int cipherSuite)static intgetEncryptionAlgorithmType(int encryptionAlgorithm)static byte[]getExtensionData(java.util.Hashtable extensions, java.lang.Integer extensionType)static shortgetHashAlgorithmForPRFAlgorithm(int prfAlgorithm)Deprecated.Will be removed.static intgetKeyExchangeAlgorithm(int cipherSuite)static java.util.VectorgetKeyExchangeAlgorithms(int[] cipherSuites)static shortgetLegacyClientCertType(short signatureAlgorithm)static shortgetLegacySignatureAlgorithmClient(short clientCertificateType)static shortgetLegacySignatureAlgorithmClientCert(short clientCertificateType)static shortgetLegacySignatureAlgorithmServer(int keyExchangeAlgorithm)static shortgetLegacySignatureAlgorithmServerCert(int keyExchangeAlgorithm)static java.util.VectorgetLegacySupportedSignatureAlgorithms()static intgetMACAlgorithm(int cipherSuite)static ProtocolVersiongetMinimumVersion(int cipherSuite)static java.util.VectorgetNamedGroupRoles(int[] cipherSuites)static java.util.VectorgetNamedGroupRoles(java.util.Vector keyExchangeAlgorithms)static org.bouncycastle.asn1.ASN1ObjectIdentifiergetOIDForHashAlgorithm(short hashAlgorithm)static SignatureAndHashAlgorithmgetSignatureAndHashAlgorithm(TlsContext context, TlsCredentialedSigner signerCredentials)static int[]getSupportedCipherSuites(TlsCrypto crypto, int[] suites)static int[]getSupportedCipherSuites(TlsCrypto crypto, int[] suites, int suitesCount)Deprecated.UsegetSupportedCipherSuites(TlsCrypto, int[], int, int)instead.static int[]getSupportedCipherSuites(TlsCrypto crypto, int[] suites, int suitesOff, int suitesCount)static java.util.VectorgetUsableSignatureAlgorithms(java.util.Vector sigHashAlgs)static booleanhasExpectedEmptyExtensionData(java.util.Hashtable extensions, java.lang.Integer extensionType, short alertDescription)static booleanhasSigningCapability(short clientCertificateType)static TlsSessionimportSession(byte[] sessionID, SessionParameters sessionParameters)static booleanisAEADCipherSuite(int cipherSuite)static booleanisBlockCipherSuite(int cipherSuite)static booleanisNullOrContainsNull(java.lang.Object[] array)static booleanisNullOrEmpty(byte[] array)static booleanisNullOrEmpty(int[] array)static booleanisNullOrEmpty(short[] array)static booleanisNullOrEmpty(java.lang.Object[] array)static booleanisNullOrEmpty(java.lang.String s)static booleanisNullOrEmpty(java.util.Vector v)static booleanisSignatureAlgorithmsExtensionAllowed(ProtocolVersion version)static booleanisSSL(TlsContext context)static booleanisStreamCipherSuite(int cipherSuite)static booleanisSupportedCipherSuite(TlsCrypto crypto, int cipherSuite)static booleanisSupportedKeyExchange(TlsCrypto crypto, int keyExchangeAlgorithm)static booleanisTLSv10(ProtocolVersion version)static booleanisTLSv10(TlsContext context)static booleanisTLSv11(ProtocolVersion version)static booleanisTLSv11(TlsContext context)static booleanisTLSv12(ProtocolVersion version)static booleanisTLSv12(TlsContext context)static booleanisTLSv13(ProtocolVersion version)static booleanisTLSv13(TlsContext context)static booleanisValidCipherSuiteForSignatureAlgorithms(int cipherSuite, java.util.Vector sigAlgs)static booleanisValidCipherSuiteForVersion(int cipherSuite, ProtocolVersion version)Deprecated.UseisValidVersionForCipherSuite(int, ProtocolVersion)instead.static booleanisValidSignatureSchemeForServerKeyExchange(int signatureScheme, int keyExchangeAlgorithm)static booleanisValidUint16(int i)static booleanisValidUint16(long i)static booleanisValidUint24(int i)static booleanisValidUint24(long i)static booleanisValidUint32(long i)static booleanisValidUint48(long i)static booleanisValidUint64(long i)static booleanisValidUint8(int i)static booleanisValidUint8(long i)static booleanisValidUint8(short i)static booleanisValidVersionForCipherSuite(int cipherSuite, ProtocolVersion version)static java.util.VectorparseSupportedSignatureAlgorithms(java.io.InputStream input)static TlsSecretPRF(SecurityParameters securityParameters, TlsSecret secret, java.lang.String asciiLabel, byte[] seed, int length)static TlsSecretPRF(TlsContext context, TlsSecret secret, java.lang.String asciiLabel, byte[] seed, int length)Deprecated.static byte[]readAllOrNothing(int length, java.io.InputStream input)static org.bouncycastle.asn1.ASN1PrimitivereadASN1Object(byte[] encoding)static org.bouncycastle.asn1.ASN1PrimitivereadDERObject(byte[] encoding)Deprecated.Will be removed.static voidreadFully(byte[] buf, java.io.InputStream input)static byte[]readFully(int length, java.io.InputStream input)static intreadInt32(byte[] buf, int offset)static byte[]readOpaque16(java.io.InputStream input)static byte[]readOpaque16(java.io.InputStream input, int minLength)static byte[]readOpaque24(java.io.InputStream input)static byte[]readOpaque24(java.io.InputStream input, int minLength)static byte[]readOpaque8(java.io.InputStream input)static byte[]readOpaque8(java.io.InputStream input, int minLength)static byte[]readOpaque8(java.io.InputStream input, int minLength, int maxLength)static intreadUint16(byte[] buf, int offset)static intreadUint16(java.io.InputStream input)static int[]readUint16Array(int count, java.io.InputStream input)static intreadUint24(byte[] buf, int offset)static intreadUint24(java.io.InputStream input)static longreadUint32(byte[] buf, int offset)static longreadUint32(java.io.InputStream input)static longreadUint48(byte[] buf, int offset)static longreadUint48(java.io.InputStream input)static shortreadUint8(byte[] buf, int offset)static shortreadUint8(java.io.InputStream input)static short[]readUint8Array(int count, java.io.InputStream input)static short[]readUint8ArrayWithUint8Length(java.io.InputStream input, int minLength)static ProtocolVersionreadVersion(byte[] buf, int offset)static ProtocolVersionreadVersion(java.io.InputStream input)static voidrequireDEREncoding(org.bouncycastle.asn1.ASN1Object asn1, byte[] encoding)static java.util.VectorvectorOfOne(java.lang.Object obj)static voidverifySupportedSignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, SignatureAndHashAlgorithm signatureAlgorithm)static voidwriteGMTUnixTime(byte[] buf, int offset)static voidwriteOpaque16(byte[] data, byte[] buf, int off)static voidwriteOpaque16(byte[] buf, java.io.OutputStream output)static voidwriteOpaque24(byte[] data, byte[] buf, int off)static voidwriteOpaque24(byte[] buf, java.io.OutputStream output)static voidwriteOpaque8(byte[] data, byte[] buf, int off)static voidwriteOpaque8(byte[] buf, java.io.OutputStream output)static voidwriteUint16(int i, byte[] buf, int offset)static voidwriteUint16(int i, java.io.OutputStream output)static voidwriteUint16Array(int[] uints, byte[] buf, int offset)static voidwriteUint16Array(int[] uints, java.io.OutputStream output)static voidwriteUint16ArrayWithUint16Length(int[] uints, byte[] buf, int offset)static voidwriteUint16ArrayWithUint16Length(int[] uints, java.io.OutputStream output)static voidwriteUint24(int i, byte[] buf, int offset)static voidwriteUint24(int i, java.io.OutputStream output)static voidwriteUint32(long i, byte[] buf, int offset)static voidwriteUint32(long i, java.io.OutputStream output)static voidwriteUint48(long i, byte[] buf, int offset)static voidwriteUint48(long i, java.io.OutputStream output)static voidwriteUint64(long i, byte[] buf, int offset)static voidwriteUint64(long i, java.io.OutputStream output)static voidwriteUint8(int i, byte[] buf, int offset)static voidwriteUint8(int i, java.io.OutputStream output)static voidwriteUint8(short i, byte[] buf, int offset)static voidwriteUint8(short i, java.io.OutputStream output)static voidwriteUint8Array(short[] uints, byte[] buf, int offset)static voidwriteUint8Array(short[] uints, java.io.OutputStream output)static voidwriteUint8ArrayWithUint8Length(short[] uints, byte[] buf, int offset)static voidwriteUint8ArrayWithUint8Length(short[] uints, java.io.OutputStream output)static voidwriteVersion(ProtocolVersion version, byte[] buf, int offset)static voidwriteVersion(ProtocolVersion version, java.io.OutputStream output)
-
-
-
Method Detail
-
checkUint8
public static void checkUint8(short i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint8
public static void checkUint8(int i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint8
public static void checkUint8(long i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint16
public static void checkUint16(int i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint16
public static void checkUint16(long i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint24
public static void checkUint24(int i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint24
public static void checkUint24(long i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint32
public static void checkUint32(long i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint48
public static void checkUint48(long i) throws java.io.IOException- Throws:
java.io.IOException
-
checkUint64
public static void checkUint64(long i) throws java.io.IOException- Throws:
java.io.IOException
-
isValidUint8
public static boolean isValidUint8(short i)
-
isValidUint8
public static boolean isValidUint8(int i)
-
isValidUint8
public static boolean isValidUint8(long i)
-
isValidUint16
public static boolean isValidUint16(int i)
-
isValidUint16
public static boolean isValidUint16(long i)
-
isValidUint24
public static boolean isValidUint24(int i)
-
isValidUint24
public static boolean isValidUint24(long i)
-
isValidUint32
public static boolean isValidUint32(long i)
-
isValidUint48
public static boolean isValidUint48(long i)
-
isValidUint64
public static boolean isValidUint64(long i)
-
isSSL
public static boolean isSSL(TlsContext context)
-
isTLSv10
public static boolean isTLSv10(ProtocolVersion version)
-
isTLSv10
public static boolean isTLSv10(TlsContext context)
-
isTLSv11
public static boolean isTLSv11(ProtocolVersion version)
-
isTLSv11
public static boolean isTLSv11(TlsContext context)
-
isTLSv12
public static boolean isTLSv12(ProtocolVersion version)
-
isTLSv12
public static boolean isTLSv12(TlsContext context)
-
isTLSv13
public static boolean isTLSv13(ProtocolVersion version)
-
isTLSv13
public static boolean isTLSv13(TlsContext context)
-
writeUint8
public static void writeUint8(short i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8
public static void writeUint8(int i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8
public static void writeUint8(short i, byte[] buf, int offset)
-
writeUint8
public static void writeUint8(int i, byte[] buf, int offset)
-
writeUint16
public static void writeUint16(int i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint16
public static void writeUint16(int i, byte[] buf, int offset)
-
writeUint24
public static void writeUint24(int i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint24
public static void writeUint24(int i, byte[] buf, int offset)
-
writeUint32
public static void writeUint32(long i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint32
public static void writeUint32(long i, byte[] buf, int offset)
-
writeUint48
public static void writeUint48(long i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint48
public static void writeUint48(long i, byte[] buf, int offset)
-
writeUint64
public static void writeUint64(long i, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint64
public static void writeUint64(long i, byte[] buf, int offset)
-
writeOpaque8
public static void writeOpaque8(byte[] buf, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeOpaque8
public static void writeOpaque8(byte[] data, byte[] buf, int off) throws java.io.IOException- Throws:
java.io.IOException
-
writeOpaque16
public static void writeOpaque16(byte[] buf, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeOpaque16
public static void writeOpaque16(byte[] data, byte[] buf, int off) throws java.io.IOException- Throws:
java.io.IOException
-
writeOpaque24
public static void writeOpaque24(byte[] buf, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeOpaque24
public static void writeOpaque24(byte[] data, byte[] buf, int off) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8Array
public static void writeUint8Array(short[] uints, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8Array
public static void writeUint8Array(short[] uints, byte[] buf, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8ArrayWithUint8Length
public static void writeUint8ArrayWithUint8Length(short[] uints, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint8ArrayWithUint8Length
public static void writeUint8ArrayWithUint8Length(short[] uints, byte[] buf, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint16Array
public static void writeUint16Array(int[] uints, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint16Array
public static void writeUint16Array(int[] uints, byte[] buf, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint16ArrayWithUint16Length
public static void writeUint16ArrayWithUint16Length(int[] uints, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
writeUint16ArrayWithUint16Length
public static void writeUint16ArrayWithUint16Length(int[] uints, byte[] buf, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
decodeOpaque8
public static byte[] decodeOpaque8(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
decodeOpaque8
public static byte[] decodeOpaque8(byte[] buf, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
decodeOpaque16
public static byte[] decodeOpaque16(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
decodeOpaque16
public static byte[] decodeOpaque16(byte[] buf, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
decodeUint8
public static short decodeUint8(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
decodeUint8ArrayWithUint8Length
public static short[] decodeUint8ArrayWithUint8Length(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
decodeUint16
public static int decodeUint16(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
decodeUint32
public static long decodeUint32(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
encodeOpaque8
public static byte[] encodeOpaque8(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
encodeOpaque16
public static byte[] encodeOpaque16(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
encodeOpaque24
public static byte[] encodeOpaque24(byte[] buf) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint8
public static byte[] encodeUint8(short uint) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint8ArrayWithUint8Length
public static byte[] encodeUint8ArrayWithUint8Length(short[] uints) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint16
public static byte[] encodeUint16(int uint) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint16ArrayWithUint16Length
public static byte[] encodeUint16ArrayWithUint16Length(int[] uints) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint24
public static byte[] encodeUint24(int uint) throws java.io.IOException- Throws:
java.io.IOException
-
encodeUint32
public static byte[] encodeUint32(long uint) throws java.io.IOException- Throws:
java.io.IOException
-
encodeVersion
public static byte[] encodeVersion(ProtocolVersion version) throws java.io.IOException
- Throws:
java.io.IOException
-
readInt32
public static int readInt32(byte[] buf, int offset)
-
readUint8
public static short readUint8(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint8
public static short readUint8(byte[] buf, int offset)
-
readUint16
public static int readUint16(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint16
public static int readUint16(byte[] buf, int offset)
-
readUint24
public static int readUint24(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint24
public static int readUint24(byte[] buf, int offset)
-
readUint32
public static long readUint32(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint32
public static long readUint32(byte[] buf, int offset)
-
readUint48
public static long readUint48(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint48
public static long readUint48(byte[] buf, int offset)
-
readAllOrNothing
public static byte[] readAllOrNothing(int length, java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readFully
public static byte[] readFully(int length, java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readFully
public static void readFully(byte[] buf, java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque8
public static byte[] readOpaque8(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque8
public static byte[] readOpaque8(java.io.InputStream input, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque8
public static byte[] readOpaque8(java.io.InputStream input, int minLength, int maxLength) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque16
public static byte[] readOpaque16(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque16
public static byte[] readOpaque16(java.io.InputStream input, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque24
public static byte[] readOpaque24(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readOpaque24
public static byte[] readOpaque24(java.io.InputStream input, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
readUint8Array
public static short[] readUint8Array(int count, java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readUint8ArrayWithUint8Length
public static short[] readUint8ArrayWithUint8Length(java.io.InputStream input, int minLength) throws java.io.IOException- Throws:
java.io.IOException
-
readUint16Array
public static int[] readUint16Array(int count, java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
readVersion
public static ProtocolVersion readVersion(byte[] buf, int offset)
-
readVersion
public static ProtocolVersion readVersion(java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
readASN1Object
public static org.bouncycastle.asn1.ASN1Primitive readASN1Object(byte[] encoding) throws java.io.IOException- Throws:
java.io.IOException
-
readDERObject
public static org.bouncycastle.asn1.ASN1Primitive readDERObject(byte[] encoding) throws java.io.IOExceptionDeprecated.Will be removed. Use readASN1Object in combination with requireDEREncoding instead- Throws:
java.io.IOException
-
requireDEREncoding
public static void requireDEREncoding(org.bouncycastle.asn1.ASN1Object asn1, byte[] encoding) throws java.io.IOException- Throws:
java.io.IOException
-
writeGMTUnixTime
public static void writeGMTUnixTime(byte[] buf, int offset)
-
writeVersion
public static void writeVersion(ProtocolVersion version, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeVersion
public static void writeVersion(ProtocolVersion version, byte[] buf, int offset)
-
addIfSupported
public static void addIfSupported(java.util.Vector supportedAlgs, TlsCrypto crypto, SignatureAndHashAlgorithm alg)
-
addIfSupported
public static void addIfSupported(java.util.Vector supportedGroups, TlsCrypto crypto, int namedGroup)
-
addIfSupported
public static void addIfSupported(java.util.Vector supportedGroups, TlsCrypto crypto, int[] namedGroups)
-
addToSet
public static boolean addToSet(java.util.Vector s, int i)
-
getDefaultDSSSignatureAlgorithms
public static java.util.Vector getDefaultDSSSignatureAlgorithms()
-
getDefaultECDSASignatureAlgorithms
public static java.util.Vector getDefaultECDSASignatureAlgorithms()
-
getDefaultRSASignatureAlgorithms
public static java.util.Vector getDefaultRSASignatureAlgorithms()
-
getDefaultSignatureAlgorithm
public static SignatureAndHashAlgorithm getDefaultSignatureAlgorithm(short signatureAlgorithm)
-
getDefaultSignatureAlgorithms
public static java.util.Vector getDefaultSignatureAlgorithms(short signatureAlgorithm)
-
getDefaultSupportedSignatureAlgorithms
public static java.util.Vector getDefaultSupportedSignatureAlgorithms(TlsContext context)
-
getSignatureAndHashAlgorithm
public static SignatureAndHashAlgorithm getSignatureAndHashAlgorithm(TlsContext context, TlsCredentialedSigner signerCredentials) throws java.io.IOException
- Throws:
java.io.IOException
-
getExtensionData
public static byte[] getExtensionData(java.util.Hashtable extensions, java.lang.Integer extensionType)
-
hasExpectedEmptyExtensionData
public static boolean hasExpectedEmptyExtensionData(java.util.Hashtable extensions, java.lang.Integer extensionType, short alertDescription) throws java.io.IOException- Throws:
java.io.IOException
-
importSession
public static TlsSession importSession(byte[] sessionID, SessionParameters sessionParameters)
-
isNullOrContainsNull
public static boolean isNullOrContainsNull(java.lang.Object[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(byte[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(short[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(int[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.lang.Object[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.lang.String s)
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.util.Vector v)
-
isSignatureAlgorithmsExtensionAllowed
public static boolean isSignatureAlgorithmsExtensionAllowed(ProtocolVersion version)
-
getLegacyClientCertType
public static short getLegacyClientCertType(short signatureAlgorithm)
-
getLegacySignatureAlgorithmClient
public static short getLegacySignatureAlgorithmClient(short clientCertificateType)
-
getLegacySignatureAlgorithmClientCert
public static short getLegacySignatureAlgorithmClientCert(short clientCertificateType)
-
getLegacySignatureAlgorithmServer
public static short getLegacySignatureAlgorithmServer(int keyExchangeAlgorithm)
-
getLegacySignatureAlgorithmServerCert
public static short getLegacySignatureAlgorithmServerCert(int keyExchangeAlgorithm)
-
getLegacySupportedSignatureAlgorithms
public static java.util.Vector getLegacySupportedSignatureAlgorithms()
-
encodeSupportedSignatureAlgorithms
public static void encodeSupportedSignatureAlgorithms(java.util.Vector supportedSignatureAlgorithms, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
parseSupportedSignatureAlgorithms
public static java.util.Vector parseSupportedSignatureAlgorithms(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
verifySupportedSignatureAlgorithm
public static void verifySupportedSignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, SignatureAndHashAlgorithm signatureAlgorithm) throws java.io.IOException- Throws:
java.io.IOException
-
containsSignatureAlgorithm
public static boolean containsSignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, SignatureAndHashAlgorithm signatureAlgorithm) throws java.io.IOException- Throws:
java.io.IOException
-
containsAnySignatureAlgorithm
public static boolean containsAnySignatureAlgorithm(java.util.Vector supportedSignatureAlgorithms, short signatureAlgorithm)
-
PRF
public static TlsSecret PRF(SecurityParameters securityParameters, TlsSecret secret, java.lang.String asciiLabel, byte[] seed, int length)
-
PRF
public static TlsSecret PRF(TlsContext context, TlsSecret secret, java.lang.String asciiLabel, byte[] seed, int length)
Deprecated.
-
clone
public static byte[] clone(byte[] data)
-
clone
public static java.lang.String[] clone(java.lang.String[] s)
-
constantTimeAreEqual
public static boolean constantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)
-
copyOfRangeExact
public static byte[] copyOfRangeExact(byte[] original, int from, int to)
-
calculateExporterSeed
public static byte[] calculateExporterSeed(SecurityParameters securityParameters, byte[] context)
-
getHashAlgorithmForPRFAlgorithm
public static short getHashAlgorithmForPRFAlgorithm(int prfAlgorithm)
Deprecated.Will be removed.TlsCryptoUtils.getHashForPRF(int)should be a useful alternative.
-
getOIDForHashAlgorithm
public static org.bouncycastle.asn1.ASN1ObjectIdentifier getOIDForHashAlgorithm(short hashAlgorithm)
-
hasSigningCapability
public static boolean hasSigningCapability(short clientCertificateType)
-
vectorOfOne
public static java.util.Vector vectorOfOne(java.lang.Object obj)
-
getCipherType
public static int getCipherType(int cipherSuite)
-
getEncryptionAlgorithm
public static int getEncryptionAlgorithm(int cipherSuite)
-
getEncryptionAlgorithmType
public static int getEncryptionAlgorithmType(int encryptionAlgorithm)
-
getKeyExchangeAlgorithm
public static int getKeyExchangeAlgorithm(int cipherSuite)
-
getKeyExchangeAlgorithms
public static java.util.Vector getKeyExchangeAlgorithms(int[] cipherSuites)
-
getMACAlgorithm
public static int getMACAlgorithm(int cipherSuite)
-
getMinimumVersion
public static ProtocolVersion getMinimumVersion(int cipherSuite)
-
getNamedGroupRoles
public static java.util.Vector getNamedGroupRoles(int[] cipherSuites)
-
getNamedGroupRoles
public static java.util.Vector getNamedGroupRoles(java.util.Vector keyExchangeAlgorithms)
-
isAEADCipherSuite
public static boolean isAEADCipherSuite(int cipherSuite) throws java.io.IOException- Throws:
java.io.IOException
-
isBlockCipherSuite
public static boolean isBlockCipherSuite(int cipherSuite) throws java.io.IOException- Throws:
java.io.IOException
-
isStreamCipherSuite
public static boolean isStreamCipherSuite(int cipherSuite) throws java.io.IOException- Throws:
java.io.IOException
-
isValidCipherSuiteForSignatureAlgorithms
public static boolean isValidCipherSuiteForSignatureAlgorithms(int cipherSuite, java.util.Vector sigAlgs)- Returns:
- Whether a server can select the specified cipher suite given the available signature algorithms for ServerKeyExchange.
-
isValidCipherSuiteForVersion
public static boolean isValidCipherSuiteForVersion(int cipherSuite, ProtocolVersion version)Deprecated.UseisValidVersionForCipherSuite(int, ProtocolVersion)instead.
-
isValidSignatureSchemeForServerKeyExchange
public static boolean isValidSignatureSchemeForServerKeyExchange(int signatureScheme, int keyExchangeAlgorithm)
-
isValidVersionForCipherSuite
public static boolean isValidVersionForCipherSuite(int cipherSuite, ProtocolVersion version)
-
chooseSignatureAndHashAlgorithm
public static SignatureAndHashAlgorithm chooseSignatureAndHashAlgorithm(TlsContext context, java.util.Vector sigHashAlgs, short signatureAlgorithm) throws java.io.IOException
- Throws:
java.io.IOException
-
chooseSignatureAndHashAlgorithm
public static SignatureAndHashAlgorithm chooseSignatureAndHashAlgorithm(ProtocolVersion negotiatedVersion, java.util.Vector sigHashAlgs, short signatureAlgorithm) throws java.io.IOException
- Throws:
java.io.IOException
-
getUsableSignatureAlgorithms
public static java.util.Vector getUsableSignatureAlgorithms(java.util.Vector sigHashAlgs)
-
getCommonCipherSuite13
public static int getCommonCipherSuite13(ProtocolVersion negotiatedVersion, int[] peerCipherSuites, int[] localCipherSuites, boolean useLocalOrder)
-
getCommonCipherSuites
public static int[] getCommonCipherSuites(int[] peerCipherSuites, int[] localCipherSuites, boolean useLocalOrder)
-
getSupportedCipherSuites
public static int[] getSupportedCipherSuites(TlsCrypto crypto, int[] suites)
-
getSupportedCipherSuites
public static int[] getSupportedCipherSuites(TlsCrypto crypto, int[] suites, int suitesCount)
Deprecated.UsegetSupportedCipherSuites(TlsCrypto, int[], int, int)instead.
-
getSupportedCipherSuites
public static int[] getSupportedCipherSuites(TlsCrypto crypto, int[] suites, int suitesOff, int suitesCount)
-
isSupportedCipherSuite
public static boolean isSupportedCipherSuite(TlsCrypto crypto, int cipherSuite)
-
isSupportedKeyExchange
public static boolean isSupportedKeyExchange(TlsCrypto crypto, int keyExchangeAlgorithm)
-
checkPeerSigAlgs
public static void checkPeerSigAlgs(TlsContext context, TlsCertificate[] peerCertPath) throws java.io.IOException
Check the signature algorithm for certificates in the peer's CertPath as specified in RFC 5246 7.4.2, 7.4.4, 7.4.6 and similar rules for earlier TLS versions. The supplied CertPath should include the trust anchor (its signature algorithm isn't checked, but in the general case checking a certificate requires the issuer certificate).- Throws:
java.io.IOException- if any certificate in the CertPath (excepting the trust anchor) has a signature algorithm that is not one of the locally supported signature algorithms.
-
containsNonAscii
public static boolean containsNonAscii(byte[] bs)
-
containsNonAscii
public static boolean containsNonAscii(java.lang.String s)
-
generateEncryptedPreMasterSecret
public static TlsSecret generateEncryptedPreMasterSecret(TlsContext context, TlsEncryptor encryptor, java.io.OutputStream output) throws java.io.IOException
Generate a pre_master_secret and send it encrypted to the server.- Throws:
java.io.IOException
-
-