Class TlsUtils


  • public class TlsUtils
    extends java.lang.Object
    Deprecated.
    Migrate to the (D)TLS API in org.bouncycastle.tls (bctls jar).
    Some helper functions for MicroTLS.
    • Field Detail

      • EMPTY_BYTES

        public static final byte[] EMPTY_BYTES
        Deprecated.
      • EMPTY_SHORTS

        public static final short[] EMPTY_SHORTS
        Deprecated.
      • EMPTY_INTS

        public static final int[] EMPTY_INTS
        Deprecated.
      • EMPTY_LONGS

        public static final long[] EMPTY_LONGS
        Deprecated.
      • EXT_signature_algorithms

        public static final java.lang.Integer EXT_signature_algorithms
        Deprecated.
    • Constructor Detail

      • TlsUtils

        public TlsUtils()
        Deprecated.
    • Method Detail

      • checkUint8

        public static void checkUint8​(short i)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint8

        public static void checkUint8​(int i)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint8

        public static void checkUint8​(long i)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint16

        public static void checkUint16​(int i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint16

        public static void checkUint16​(long i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint24

        public static void checkUint24​(int i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint24

        public static void checkUint24​(long i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint32

        public static void checkUint32​(long i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint48

        public static void checkUint48​(long i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • checkUint64

        public static void checkUint64​(long i)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • isValidUint8

        public static boolean isValidUint8​(short i)
        Deprecated.
      • isValidUint8

        public static boolean isValidUint8​(int i)
        Deprecated.
      • isValidUint8

        public static boolean isValidUint8​(long i)
        Deprecated.
      • isValidUint16

        public static boolean isValidUint16​(int i)
        Deprecated.
      • isValidUint16

        public static boolean isValidUint16​(long i)
        Deprecated.
      • isValidUint24

        public static boolean isValidUint24​(int i)
        Deprecated.
      • isValidUint24

        public static boolean isValidUint24​(long i)
        Deprecated.
      • isValidUint32

        public static boolean isValidUint32​(long i)
        Deprecated.
      • isValidUint48

        public static boolean isValidUint48​(long i)
        Deprecated.
      • isValidUint64

        public static boolean isValidUint64​(long i)
        Deprecated.
      • isSSL

        public static boolean isSSL​(TlsContext context)
        Deprecated.
      • isTLSv11

        public static boolean isTLSv11​(ProtocolVersion version)
        Deprecated.
      • isTLSv11

        public static boolean isTLSv11​(TlsContext context)
        Deprecated.
      • isTLSv12

        public static boolean isTLSv12​(ProtocolVersion version)
        Deprecated.
      • isTLSv12

        public static boolean isTLSv12​(TlsContext context)
        Deprecated.
      • writeUint8

        public static void writeUint8​(short i,
                                      java.io.OutputStream output)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8

        public static void writeUint8​(int i,
                                      java.io.OutputStream output)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8

        public static void writeUint8​(short i,
                                      byte[] buf,
                                      int offset)
        Deprecated.
      • writeUint8

        public static void writeUint8​(int i,
                                      byte[] buf,
                                      int offset)
        Deprecated.
      • writeUint16

        public static void writeUint16​(int i,
                                       java.io.OutputStream output)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint16

        public static void writeUint16​(int i,
                                       byte[] buf,
                                       int offset)
        Deprecated.
      • writeUint24

        public static void writeUint24​(int i,
                                       java.io.OutputStream output)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint24

        public static void writeUint24​(int i,
                                       byte[] buf,
                                       int offset)
        Deprecated.
      • writeUint32

        public static void writeUint32​(long i,
                                       java.io.OutputStream output)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint32

        public static void writeUint32​(long i,
                                       byte[] buf,
                                       int offset)
        Deprecated.
      • writeUint48

        public static void writeUint48​(long i,
                                       java.io.OutputStream output)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint48

        public static void writeUint48​(long i,
                                       byte[] buf,
                                       int offset)
        Deprecated.
      • writeUint64

        public static void writeUint64​(long i,
                                       java.io.OutputStream output)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint64

        public static void writeUint64​(long i,
                                       byte[] buf,
                                       int offset)
        Deprecated.
      • writeOpaque8

        public static void writeOpaque8​(byte[] buf,
                                        java.io.OutputStream output)
                                 throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeOpaque16

        public static void writeOpaque16​(byte[] buf,
                                         java.io.OutputStream output)
                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeOpaque24

        public static void writeOpaque24​(byte[] buf,
                                         java.io.OutputStream output)
                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8Array

        public static void writeUint8Array​(short[] uints,
                                           java.io.OutputStream output)
                                    throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8Array

        public static void writeUint8Array​(short[] uints,
                                           byte[] buf,
                                           int offset)
                                    throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8ArrayWithUint8Length

        public static void writeUint8ArrayWithUint8Length​(short[] uints,
                                                          java.io.OutputStream output)
                                                   throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint8ArrayWithUint8Length

        public static void writeUint8ArrayWithUint8Length​(short[] uints,
                                                          byte[] buf,
                                                          int offset)
                                                   throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint16Array

        public static void writeUint16Array​(int[] uints,
                                            java.io.OutputStream output)
                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint16Array

        public static void writeUint16Array​(int[] uints,
                                            byte[] buf,
                                            int offset)
                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint16ArrayWithUint16Length

        public static void writeUint16ArrayWithUint16Length​(int[] uints,
                                                            java.io.OutputStream output)
                                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeUint16ArrayWithUint16Length

        public static void writeUint16ArrayWithUint16Length​(int[] uints,
                                                            byte[] buf,
                                                            int offset)
                                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • encodeOpaque8

        public static byte[] encodeOpaque8​(byte[] buf)
                                    throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • encodeUint8ArrayWithUint8Length

        public static byte[] encodeUint8ArrayWithUint8Length​(short[] uints)
                                                      throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • encodeUint16ArrayWithUint16Length

        public static byte[] encodeUint16ArrayWithUint16Length​(int[] uints)
                                                        throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint8

        public static short readUint8​(java.io.InputStream input)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint8

        public static short readUint8​(byte[] buf,
                                      int offset)
        Deprecated.
      • readUint16

        public static int readUint16​(java.io.InputStream input)
                              throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint16

        public static int readUint16​(byte[] buf,
                                     int offset)
        Deprecated.
      • readUint24

        public static int readUint24​(java.io.InputStream input)
                              throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint24

        public static int readUint24​(byte[] buf,
                                     int offset)
        Deprecated.
      • readUint32

        public static long readUint32​(java.io.InputStream input)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint32

        public static long readUint32​(byte[] buf,
                                      int offset)
        Deprecated.
      • readUint48

        public static long readUint48​(java.io.InputStream input)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint48

        public static long readUint48​(byte[] buf,
                                      int offset)
        Deprecated.
      • readAllOrNothing

        public static byte[] readAllOrNothing​(int length,
                                              java.io.InputStream input)
                                       throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readFully

        public static byte[] readFully​(int length,
                                       java.io.InputStream input)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readFully

        public static void readFully​(byte[] buf,
                                     java.io.InputStream input)
                              throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readOpaque8

        public static byte[] readOpaque8​(java.io.InputStream input)
                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readOpaque16

        public static byte[] readOpaque16​(java.io.InputStream input)
                                   throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readOpaque24

        public static byte[] readOpaque24​(java.io.InputStream input)
                                   throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint8Array

        public static short[] readUint8Array​(int count,
                                             java.io.InputStream input)
                                      throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readUint16Array

        public static int[] readUint16Array​(int count,
                                            java.io.InputStream input)
                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readVersion

        public static ProtocolVersion readVersion​(byte[] buf,
                                                  int offset)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readVersion

        public static ProtocolVersion readVersion​(java.io.InputStream input)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readVersionRaw

        public static int readVersionRaw​(byte[] buf,
                                         int offset)
                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readVersionRaw

        public static int readVersionRaw​(java.io.InputStream input)
                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readASN1Object

        public static ASN1Primitive readASN1Object​(byte[] encoding)
                                            throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readDERObject

        public static ASN1Primitive readDERObject​(byte[] encoding)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeGMTUnixTime

        public static void writeGMTUnixTime​(byte[] buf,
                                            int offset)
        Deprecated.
      • writeVersion

        public static void writeVersion​(ProtocolVersion version,
                                        java.io.OutputStream output)
                                 throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeVersion

        public static void writeVersion​(ProtocolVersion version,
                                        byte[] buf,
                                        int offset)
        Deprecated.
      • getAllSignatureAlgorithms

        public static java.util.Vector getAllSignatureAlgorithms()
        Deprecated.
      • getDefaultDSSSignatureAlgorithms

        public static java.util.Vector getDefaultDSSSignatureAlgorithms()
        Deprecated.
      • getDefaultECDSASignatureAlgorithms

        public static java.util.Vector getDefaultECDSASignatureAlgorithms()
        Deprecated.
      • getDefaultRSASignatureAlgorithms

        public static java.util.Vector getDefaultRSASignatureAlgorithms()
        Deprecated.
      • getDefaultSupportedSignatureAlgorithms

        public static java.util.Vector getDefaultSupportedSignatureAlgorithms()
        Deprecated.
      • getExtensionData

        public static byte[] getExtensionData​(java.util.Hashtable extensions,
                                              java.lang.Integer extensionType)
        Deprecated.
      • hasExpectedEmptyExtensionData

        public static boolean hasExpectedEmptyExtensionData​(java.util.Hashtable extensions,
                                                            java.lang.Integer extensionType,
                                                            short alertDescription)
                                                     throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • isSignatureAlgorithmsExtensionAllowed

        public static boolean isSignatureAlgorithmsExtensionAllowed​(ProtocolVersion clientVersion)
        Deprecated.
      • addSignatureAlgorithmsExtension

        public static void addSignatureAlgorithmsExtension​(java.util.Hashtable extensions,
                                                           java.util.Vector supportedSignatureAlgorithms)
                                                    throws java.io.IOException
        Deprecated.
        Add a 'signature_algorithms' extension to existing extensions.
        Parameters:
        extensions - A Hashtable to add the extension to.
        supportedSignatureAlgorithms - Vector containing at least 1 SignatureAndHashAlgorithm.
        Throws:
        java.io.IOException
      • getSignatureAlgorithmsExtension

        public static java.util.Vector getSignatureAlgorithmsExtension​(java.util.Hashtable extensions)
                                                                throws java.io.IOException
        Deprecated.
        Get a 'signature_algorithms' extension from extensions.
        Parameters:
        extensions - A Hashtable to get the extension from, if it is present.
        Returns:
        A Vector containing at least 1 SignatureAndHashAlgorithm, or null.
        Throws:
        java.io.IOException
      • createSignatureAlgorithmsExtension

        public static byte[] createSignatureAlgorithmsExtension​(java.util.Vector supportedSignatureAlgorithms)
                                                         throws java.io.IOException
        Deprecated.
        Create a 'signature_algorithms' extension value.
        Parameters:
        supportedSignatureAlgorithms - A Vector containing at least 1 SignatureAndHashAlgorithm.
        Returns:
        A byte array suitable for use as an extension value.
        Throws:
        java.io.IOException
      • readSignatureAlgorithmsExtension

        public static java.util.Vector readSignatureAlgorithmsExtension​(byte[] extensionData)
                                                                 throws java.io.IOException
        Deprecated.
        Read 'signature_algorithms' extension data.
        Parameters:
        extensionData - The extension data.
        Returns:
        A Vector containing at least 1 SignatureAndHashAlgorithm.
        Throws:
        java.io.IOException
      • encodeSupportedSignatureAlgorithms

        public static void encodeSupportedSignatureAlgorithms​(java.util.Vector supportedSignatureAlgorithms,
                                                              boolean allowAnonymous,
                                                              java.io.OutputStream output)
                                                       throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • parseSupportedSignatureAlgorithms

        public static java.util.Vector parseSupportedSignatureAlgorithms​(boolean allowAnonymous,
                                                                         java.io.InputStream input)
                                                                  throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • verifySupportedSignatureAlgorithm

        public static void verifySupportedSignatureAlgorithm​(java.util.Vector supportedSignatureAlgorithms,
                                                             SignatureAndHashAlgorithm signatureAlgorithm)
                                                      throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • PRF

        public static byte[] PRF​(TlsContext context,
                                 byte[] secret,
                                 java.lang.String asciiLabel,
                                 byte[] seed,
                                 int size)
        Deprecated.
      • PRF_legacy

        public static byte[] PRF_legacy​(byte[] secret,
                                        java.lang.String asciiLabel,
                                        byte[] seed,
                                        int size)
        Deprecated.
      • createHash

        public static Digest createHash​(short hashAlgorithm)
        Deprecated.
      • cloneHash

        public static Digest cloneHash​(short hashAlgorithm,
                                       Digest hash)
        Deprecated.
      • createPRFHash

        public static Digest createPRFHash​(int prfAlgorithm)
        Deprecated.
      • clonePRFHash

        public static Digest clonePRFHash​(int prfAlgorithm,
                                          Digest hash)
        Deprecated.
      • getHashAlgorithmForPRFAlgorithm

        public static short getHashAlgorithmForPRFAlgorithm​(int prfAlgorithm)
        Deprecated.
      • getOIDForHashAlgorithm

        public static ASN1ObjectIdentifier getOIDForHashAlgorithm​(short hashAlgorithm)
        Deprecated.
      • hasSigningCapability

        public static boolean hasSigningCapability​(short clientCertificateType)
        Deprecated.
      • createTlsSigner

        public static TlsSigner createTlsSigner​(short clientCertificateType)
        Deprecated.
      • getCipherType

        public static int getCipherType​(int ciphersuite)
                                 throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • getEncryptionAlgorithm

        public static int getEncryptionAlgorithm​(int ciphersuite)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • getKeyExchangeAlgorithm

        public static int getKeyExchangeAlgorithm​(int ciphersuite)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • getMACAlgorithm

        public static int getMACAlgorithm​(int ciphersuite)
                                   throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • getMinimumVersion

        public static ProtocolVersion getMinimumVersion​(int ciphersuite)
        Deprecated.
      • isAEADCipherSuite

        public static boolean isAEADCipherSuite​(int ciphersuite)
                                         throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • isBlockCipherSuite

        public static boolean isBlockCipherSuite​(int ciphersuite)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • isStreamCipherSuite

        public static boolean isStreamCipherSuite​(int ciphersuite)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • isValidCipherSuiteForSignatureAlgorithms

        public static boolean isValidCipherSuiteForSignatureAlgorithms​(int cipherSuite,
                                                                       java.util.Vector sigAlgs)
        Deprecated.
      • isValidCipherSuiteForVersion

        public static boolean isValidCipherSuiteForVersion​(int cipherSuite,
                                                           ProtocolVersion serverVersion)
        Deprecated.
      • getUsableSignatureAlgorithms

        public static java.util.Vector getUsableSignatureAlgorithms​(java.util.Vector sigHashAlgs)
        Deprecated.