com.kodemuse.security.ssl
Class SSLUtil

java.lang.Object
  |
  +--com.kodemuse.security.ssl.SSLUtil
All Implemented Interfaces:
SSLConstants

class SSLUtil
extends java.lang.Object
implements SSLConstants

Utility functions used by SSL. Booch may call this a utility class, code analyzers may say this is a class with low cohesion. Both would be correct.

Author:
Harmeet Bedi

Fields inherited from interface com.kodemuse.security.ssl.SSLConstants
ALERT_CONTENT, APPLICATION_DATA_CONTENT, BAD_CERTIFICATE_ALERTDESC, BAD_RECORD_MAC_ALERTDESC, CERTIFICATE_EXPIRED_ALERTDESC, CERTIFICATE_HANDSHAKE, CERTIFICATE_REQUEST_HANDSHAKE, CERTIFICATE_REVOKED_ALERTDESC, CERTIFICATE_UNKNOWN_ALERTDESC, CERTIFICATE_VERIFY_HANDSHAKE, CHANGE_CIPHER_SPEC_CONTENT, CLIENT, CLIENT_HELLO_HANDSHAKE, CLIENT_KEY_EXCHANGE_HANDSHAKE, CLOSE_ALERT, CLOSE_NOTIFY_ALERTDESC, DECOMPRESSION_FAILURE_ALERTDESC, FATAL_ALERTLEVEL, FINISHED_CLIENT_SENDER, FINISHED_HANDSHAKE, FINISHED_SERVER_SENDER, HANDSHAKE_CONTENT, HANDSHAKE_FAILURE_ALERTDESC, HELLO_REQUEST_HANDSHAKE, ILLEGAL_PARAMETER_ALERTDESC, MAX_RECORD_SIZE, MD5_PAD_1, MD5_PAD_2, MD5LEN, NO_CERTIFICATE_ALERTDESC, NULL_COMPRESSION, RNG, SERVER, SERVER_HELLO_DONE_HANDSHAKE, SERVER_HELLO_HANDSHAKE, SERVER_KEY_EXCHANGE_HANDSHAKE, SHA_PAD_1, SHA_PAD_2, SHA1LEN, SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_anon_EXPORT_WITH_RC4_40_MD5, SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_DES_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA, SSL_DH_DSS_WITH_DES_CBC_SHA, SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DH_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA, SSL_FORTEZZA_KEA_WITH_NULL_SHA, SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, SSL_NULL_WITH_NULL_NULL, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_RSA_WITH_IDEA_CBC_SHA, SSL_RSA_WITH_NULL_MD5, SSL_RSA_WITH_NULL_SHA, SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, SSLV3_VERSION, TLSV1_VERSION, UNEXPECTED_MESSAGE_ALERTDESC, UNEXPECTEDMSG_ALERT, UNSUPPORTED_CERTIFICATE_ALERTDESC, WARNING_ALERTLEVEL
 
Constructor Summary
(package private) SSLUtil()
           
 
Method Summary
static void affirm(boolean b)
           
static void affirm(boolean b, java.lang.String msg)
           
static byte[] cat(byte[] b1, byte[] b2)
           
static byte[] cat(byte[] b1, int b1off, int b1len, byte[] b2, int b2off, int b2len)
           
static void cat(byte[] b1, int b1off, int b1len, byte[] b2, int b2off, int b2len, byte[] trg, int toff)
           
static void compareMAC(byte[] got, byte[] calculated)
           
static int convertBytesToInt(byte[] ba, int offset)
           
static byte[] convertIntToBytes(int v)
           
static void convertIntToBytes(int v, byte[] ba, int offset)
           
static void convertLongToBytes(long v, byte[] ba, int offset)
           
static void convertShortToBytes(int v, byte[] ba, int offset)
           
static java.io.IOException convertToIOEx(java.lang.Exception ex)
           
static byte[] digest(org.bouncycastle.crypto.Digest d)
           
static byte[] drain(java.io.InputStream inp)
           
static void dump(java.lang.String label, byte[] ba)
           
static byte[] getData(DataSource ds)
           
static java.io.DataInputStream getInput(byte[] ba)
           
static boolean isEqual(byte[] b1, byte[] b2)
           
static byte[] newByteArray(int len, byte value)
           
static int readInt24(java.io.DataInputStream din)
           
static byte[] slice(byte[] ba, int offset, int len)
           
(package private) static void sort(java.security.cert.X509Certificate[] cert)
           
static void update(org.bouncycastle.crypto.Digest d, byte[] ba)
           
static void writeInt24(java.io.OutputStream out, int val)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLUtil

SSLUtil()
Method Detail

compareMAC

public static void compareMAC(byte[] got,
                              byte[] calculated)

affirm

public static void affirm(boolean b)

affirm

public static void affirm(boolean b,
                          java.lang.String msg)

getInput

public static java.io.DataInputStream getInput(byte[] ba)

getData

public static byte[] getData(DataSource ds)

drain

public static byte[] drain(java.io.InputStream inp)
                    throws java.io.IOException

digest

public static byte[] digest(org.bouncycastle.crypto.Digest d)

update

public static void update(org.bouncycastle.crypto.Digest d,
                          byte[] ba)

convertToIOEx

public static java.io.IOException convertToIOEx(java.lang.Exception ex)

dump

public static void dump(java.lang.String label,
                        byte[] ba)

readInt24

public static int readInt24(java.io.DataInputStream din)
                     throws java.io.IOException

writeInt24

public static void writeInt24(java.io.OutputStream out,
                              int val)
                       throws java.io.IOException

convertIntToBytes

public static byte[] convertIntToBytes(int v)

convertShortToBytes

public static void convertShortToBytes(int v,
                                       byte[] ba,
                                       int offset)

convertLongToBytes

public static void convertLongToBytes(long v,
                                      byte[] ba,
                                      int offset)

convertIntToBytes

public static void convertIntToBytes(int v,
                                     byte[] ba,
                                     int offset)

convertBytesToInt

public static int convertBytesToInt(byte[] ba,
                                    int offset)

newByteArray

public static byte[] newByteArray(int len,
                                  byte value)

slice

public static byte[] slice(byte[] ba,
                           int offset,
                           int len)

cat

public static byte[] cat(byte[] b1,
                         byte[] b2)

cat

public static byte[] cat(byte[] b1,
                         int b1off,
                         int b1len,
                         byte[] b2,
                         int b2off,
                         int b2len)

cat

public static void cat(byte[] b1,
                       int b1off,
                       int b1len,
                       byte[] b2,
                       int b2off,
                       int b2len,
                       byte[] trg,
                       int toff)

isEqual

public static boolean isEqual(byte[] b1,
                              byte[] b2)

sort

static void sort(java.security.cert.X509Certificate[] cert)