Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.net.ssl.provider
Class GNUSecurityParameters  view GNUSecurityParameters download GNUSecurityParameters.java

java.lang.Object
  extended bygnu.javax.net.ssl.provider.GNUSecurityParameters
All Implemented Interfaces:
SecurityParameters

class GNUSecurityParameters
extends java.lang.Object
implements SecurityParameters

This class implements the SecurityParameters interface, using the GNU Crypto interface for ciphers and macs, and the JZlib package for record compression.


Field Summary
private static java.io.PrintWriter debug
           
private static boolean DEBUG_RECORD_LAYER
           
private  java.util.zip.Deflater deflater
           
(package private)  int fragmentLength
           
(package private)  gnu.javax.crypto.mode.IMode inCipher
          The CBC block cipher, if any.
private  java.util.zip.Inflater inflater
           
(package private)  gnu.javax.crypto.mac.IMac inMac
          The MAC algorithm.
(package private)  gnu.java.security.prng.IRandom inRandom
          The RC4 PRNG, if any.
(package private)  long inSequence
           
(package private)  gnu.javax.crypto.mode.IMode outCipher
          The CBC block cipher, if any.
(package private)  gnu.javax.crypto.mac.IMac outMac
          The MAC algorithm.
(package private)  gnu.java.security.prng.IRandom outRandom
          The RC4 PRNG, if any.
(package private)  long outSequence
           
(package private)  Session session
           
(package private)  ProtocolVersion version
           
 
Constructor Summary
(package private) GNUSecurityParameters(Session session)
           
 
Method Summary
 byte[] decrypt(byte[] fragment, ProtocolVersion version, ContentType type)
          Decrypt, verify, and decompress a fragment, returning the transformed fragment.
 byte[] encrypt(byte[] buf, int off, int len, ContentType type)
          Compress, MAC, encrypt, and write a record.
 int getFragmentLength()
          Returns the maximum size that plaintext fragments may be.
 ProtocolVersion getVersion()
          Returns the version of texts being sent.
 void reset()
          Set all crypto primitives to null, meaning that any calls to #encrypt(byte[],int,int,org.metastatic.jessie.provider.ContentType) or #decrypt(byte[],org.metastatic.jessie.provider.ProtocolVersion,org.metastatic.jessie.provider.ContentType) will perform the identity transformation.
 void setDeflating(boolean deflate)
          Turns zlib deflating on or off.
 void setFragmentLength(int fragmentLength)
          Sets the maximum size that plaintext fragments may be.
 void setInCipher(java.lang.Object inCipher)
          Set the cipher used to decrypt incoming fragments.
 void setInflating(boolean inflate)
          Turns zlib inflating on or off.
 void setInMac(java.lang.Object inMac)
          Set the MAC used to verify incoming fragments.
 void setOutCipher(java.lang.Object outCipher)
          Set the cipher used to encrypt outgoing fragments.
 void setOutMac(java.lang.Object outMac)
          Set the MAC used to authenticating outgoinging fragments.
 void setVersion(ProtocolVersion version)
          Sets the version of texts being sent.
private static void transformRC4(byte[] in, int off, int len, byte[] out, int outOffset, gnu.java.security.prng.IRandom random)
          Encrypt/decrypt a byte array with the RC4 stream cipher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_RECORD_LAYER

private static final boolean DEBUG_RECORD_LAYER
See Also:
Constant Field Values

debug

private static final java.io.PrintWriter debug

inCipher

gnu.javax.crypto.mode.IMode inCipher
The CBC block cipher, if any.


outCipher

gnu.javax.crypto.mode.IMode outCipher
The CBC block cipher, if any.


inRandom

gnu.java.security.prng.IRandom inRandom
The RC4 PRNG, if any.


outRandom

gnu.java.security.prng.IRandom outRandom
The RC4 PRNG, if any.


inMac

gnu.javax.crypto.mac.IMac inMac
The MAC algorithm.


outMac

gnu.javax.crypto.mac.IMac outMac
The MAC algorithm.


inSequence

long inSequence

outSequence

long outSequence

session

Session session

version

ProtocolVersion version

fragmentLength

int fragmentLength

inflater

private java.util.zip.Inflater inflater

deflater

private java.util.zip.Deflater deflater
Constructor Detail

GNUSecurityParameters

GNUSecurityParameters(Session session)
Method Detail

reset

public void reset()
Description copied from interface: SecurityParameters
Set all crypto primitives to null, meaning that any calls to #encrypt(byte[],int,int,org.metastatic.jessie.provider.ContentType) or #decrypt(byte[],org.metastatic.jessie.provider.ProtocolVersion,org.metastatic.jessie.provider.ContentType) will perform the identity transformation.

Specified by:
reset in interface SecurityParameters

getVersion

public ProtocolVersion getVersion()
Description copied from interface: SecurityParameters
Returns the version of texts being sent.

Specified by:
getVersion in interface SecurityParameters

setVersion

public void setVersion(ProtocolVersion version)
Description copied from interface: SecurityParameters
Sets the version of texts being sent. This affects the #encrypt(byte[],int,int,org.metastatic.jessie.provider.ContentType) method.

Specified by:
setVersion in interface SecurityParameters

setInCipher

public void setInCipher(java.lang.Object inCipher)
Description copied from interface: SecurityParameters
Set the cipher used to decrypt incoming fragments. The parameter must be appropriate for the implementation.

Specified by:
setInCipher in interface SecurityParameters

setOutCipher

public void setOutCipher(java.lang.Object outCipher)
Description copied from interface: SecurityParameters
Set the cipher used to encrypt outgoing fragments. The parameter must be appropriate for the implementation.

Specified by:
setOutCipher in interface SecurityParameters

setInMac

public void setInMac(java.lang.Object inMac)
Description copied from interface: SecurityParameters
Set the MAC used to verify incoming fragments. The parameter must be appropriate for the implementation.

Specified by:
setInMac in interface SecurityParameters

setOutMac

public void setOutMac(java.lang.Object outMac)
Description copied from interface: SecurityParameters
Set the MAC used to authenticating outgoinging fragments. The parameter must be appropriate for the implementation.

Specified by:
setOutMac in interface SecurityParameters

setDeflating

public void setDeflating(boolean deflate)
Description copied from interface: SecurityParameters
Turns zlib deflating on or off.

Specified by:
setDeflating in interface SecurityParameters

setInflating

public void setInflating(boolean inflate)
Description copied from interface: SecurityParameters
Turns zlib inflating on or off.

Specified by:
setInflating in interface SecurityParameters

getFragmentLength

public int getFragmentLength()
Description copied from interface: SecurityParameters
Returns the maximum size that plaintext fragments may be.

Specified by:
getFragmentLength in interface SecurityParameters

setFragmentLength

public void setFragmentLength(int fragmentLength)
Description copied from interface: SecurityParameters
Sets the maximum size that plaintext fragments may be.

Specified by:
setFragmentLength in interface SecurityParameters

decrypt

public byte[] decrypt(byte[] fragment,
                      ProtocolVersion version,
                      ContentType type)
               throws MacException,
                      OverflowException,
                      javax.net.ssl.SSLException
Decrypt, verify, and decompress a fragment, returning the transformed fragment.

Specified by:
decrypt in interface SecurityParameters

encrypt

public byte[] encrypt(byte[] buf,
                      int off,
                      int len,
                      ContentType type)
               throws javax.net.ssl.SSLException,
                      OverflowException
Compress, MAC, encrypt, and write a record. The fragment of the record is taken from buf as len bytes starting at offset. len must be smaller than or equal to the configured fragment length.

Specified by:
encrypt in interface SecurityParameters

transformRC4

private static void transformRC4(byte[] in,
                                 int off,
                                 int len,
                                 byte[] out,
                                 int outOffset,
                                 gnu.java.security.prng.IRandom random)
Encrypt/decrypt a byte array with the RC4 stream cipher.