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

Quick Search    Search Deep

cryptix.jce.provider.rsa
Class RSACipher_OAEP  view RSACipher_OAEP download RSACipher_OAEP.java

java.lang.Object
  extended byjavax.crypto.CipherSpi
      extended bycryptix.jce.provider.rsa.RSACipher_OAEP
Direct Known Subclasses:
RSACipher_OAEP_MD2, RSACipher_OAEP_MD4, RSACipher_OAEP_MD5, RSACipher_OAEP_RIPEMD128, RSACipher_OAEP_RIPEMD160, RSACipher_OAEP_SHA1, RSACipher_OAEP_SHA256, RSACipher_OAEP_SHA384, RSACipher_OAEP_SHA512, RSACipher_OAEP_Tiger

public abstract class RSACipher_OAEP
extends javax.crypto.CipherSpi

Version:
$Revision: 1.2 $

Field Summary
private  java.math.BigInteger _exp
           
private  int _hLen
           
private  int _k
          Byte-length of modulus (n), excluding sign bit.
private  byte[] _lHash
           
private  java.security.MessageDigest _md
           
private  int _mode
           
private  java.math.BigInteger _n
           
private  java.math.BigInteger _p
           
private  java.math.BigInteger _q
           
private  java.security.SecureRandom _rng
           
private  java.math.BigInteger _u
           
 
Constructor Summary
RSACipher_OAEP(java.lang.String hashName)
           
 
Method Summary
private  byte[] concat(byte[] a, byte[] b)
           
private  byte[] concat(byte[] a, byte[] b, byte[] c)
           
private  byte[] concat(byte[] a, byte[] b, byte[] c, byte[] d)
           
protected  byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
          Finishes a multi-part transformation or transforms a portion of a byte array, and returns the transformed bytes.
protected  int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
          Finishes a multi-part transformation or transforms a portion of a byte array, and stores the transformed bytes in the supplied array.
protected  int engineGetBlockSize()
          Returns the block size of the underlying cipher.
protected  byte[] engineGetIV()
          Returns the initializaiton vector this cipher was initialized with, if any.
protected  int engineGetKeySize(java.security.Key key)
          Return the length of the given key in bits.
protected  int engineGetOutputSize(int inputLen)
          Returns the size, in bytes, an output buffer must be for a call to engineUpdate(byte[],int,int,byte[],int) 55 or engineDoFinal(byte[],int,int,byte[],int) 55 to succeed.
protected  java.security.AlgorithmParameters engineGetParameters()
          Returns the parameters that this cipher is using.
protected  void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
          Initializes this cipher with an operation mode, key, parameters, and source of randomness.
protected  void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random)
          Initializes this cipher with an operation mode, key, parameters, and source of randomness.
protected  void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random)
          Initializes this cipher with an operation mode, key, and source of randomness.
protected  void engineSetMode(java.lang.String mode)
          Set the mode in which this cipher is to run.
protected  void engineSetPadding(java.lang.String padding)
          Set the method with which the input is to be padded.
protected  byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
          Continue with a multi-part transformation, returning a new array of the transformed bytes.
protected  int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
          Continue with a multi-part transformation, storing the transformed bytes into the specified array.
private  byte[] mgf1(byte[] seed, int len)
           
private  byte[] mgf1Hash(byte[] seed, byte c)
           
private  byte[] RSAES_OAEP_DECRYPT(byte[] C)
           
private  byte[] RSAES_OAEP_ENCRYPT(byte[] M)
           
private static byte[] xor(byte[] a, byte[] b)
           
 
Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineUnwrap, engineUpdate, engineWrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_md

private final java.security.MessageDigest _md

_hLen

private final int _hLen

_lHash

private final byte[] _lHash

_rng

private java.security.SecureRandom _rng

_n

private java.math.BigInteger _n

_exp

private java.math.BigInteger _exp

_p

private java.math.BigInteger _p

_q

private java.math.BigInteger _q

_u

private java.math.BigInteger _u

_k

private int _k
Byte-length of modulus (n), excluding sign bit.


_mode

private int _mode
Constructor Detail

RSACipher_OAEP

public RSACipher_OAEP(java.lang.String hashName)
Method Detail

engineSetMode

protected final void engineSetMode(java.lang.String mode)
                            throws java.security.NoSuchAlgorithmException
Description copied from class: javax.crypto.CipherSpi
Set the mode in which this cipher is to run.


engineSetPadding

protected final void engineSetPadding(java.lang.String padding)
                               throws javax.crypto.NoSuchPaddingException
Description copied from class: javax.crypto.CipherSpi
Set the method with which the input is to be padded.


engineGetBlockSize

protected final int engineGetBlockSize()
Description copied from class: javax.crypto.CipherSpi
Returns the block size of the underlying cipher.


engineGetOutputSize

protected final int engineGetOutputSize(int inputLen)
Description copied from class: javax.crypto.CipherSpi

Returns the size, in bytes, an output buffer must be for a call to CipherSpi.engineUpdate(byte[],int,int,byte[],int)>CipherSpi.engineUpdate(byte[],int,int,byte[],int) 55 or CipherSpi.engineDoFinal(byte[],int,int,byte[],int)>CipherSpi.engineDoFinal(byte[],int,int,byte[],int) 55 to succeed.

The actual output length may be smaller than the value returned by this method, as it considers the padding length as well. The length considered is the argument plus the length of any buffered, unprocessed bytes.


engineGetIV

protected final byte[] engineGetIV()
Description copied from class: javax.crypto.CipherSpi
Returns the initializaiton vector this cipher was initialized with, if any.


engineGetParameters

protected final java.security.AlgorithmParameters engineGetParameters()
Description copied from class: javax.crypto.CipherSpi
Returns the parameters that this cipher is using. This may be the parameters used to initialize this cipher, or it may be parameters that have been initialized with random values.


engineInit

protected final void engineInit(int opmode,
                                java.security.Key key,
                                java.security.SecureRandom random)
                         throws java.security.InvalidKeyException
Description copied from class: javax.crypto.CipherSpi
Initializes this cipher with an operation mode, key, and source of randomness. If this cipher requires any other initializing data, for example an initialization vector, then it should generate it from the provided source of randomness.


engineInit

protected final void engineInit(int opmode,
                                java.security.Key key,
                                java.security.spec.AlgorithmParameterSpec params,
                                java.security.SecureRandom random)
                         throws java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException
Description copied from class: javax.crypto.CipherSpi
Initializes this cipher with an operation mode, key, parameters, and source of randomness. If this cipher requires any other initializing data, for example an initialization vector, then it should generate it from the provided source of randomness.


engineInit

protected final void engineInit(int opmode,
                                java.security.Key key,
                                java.security.AlgorithmParameters params,
                                java.security.SecureRandom random)
                         throws java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException
Description copied from class: javax.crypto.CipherSpi
Initializes this cipher with an operation mode, key, parameters, and source of randomness. If this cipher requires any other initializing data, for example an initialization vector, then it should generate it from the provided source of randomness.


engineUpdate

protected final byte[] engineUpdate(byte[] input,
                                    int inputOffset,
                                    int inputLen)
Description copied from class: javax.crypto.CipherSpi
Continue with a multi-part transformation, returning a new array of the transformed bytes.


engineUpdate

protected final int engineUpdate(byte[] input,
                                 int inputOffset,
                                 int inputLen,
                                 byte[] output,
                                 int outputOffset)
                          throws javax.crypto.ShortBufferException
Description copied from class: javax.crypto.CipherSpi
Continue with a multi-part transformation, storing the transformed bytes into the specified array.


engineDoFinal

protected final byte[] engineDoFinal(byte[] input,
                                     int inputOffset,
                                     int inputLen)
                              throws javax.crypto.IllegalBlockSizeException,
                                     javax.crypto.BadPaddingException
Description copied from class: javax.crypto.CipherSpi
Finishes a multi-part transformation or transforms a portion of a byte array, and returns the transformed bytes.


engineDoFinal

protected final int engineDoFinal(byte[] input,
                                  int inputOffset,
                                  int inputLen,
                                  byte[] output,
                                  int outputOffset)
                           throws javax.crypto.ShortBufferException,
                                  javax.crypto.IllegalBlockSizeException,
                                  javax.crypto.BadPaddingException
Description copied from class: javax.crypto.CipherSpi
Finishes a multi-part transformation or transforms a portion of a byte array, and stores the transformed bytes in the supplied array.


engineGetKeySize

protected int engineGetKeySize(java.security.Key key)
                        throws java.security.InvalidKeyException
Description copied from class: javax.crypto.CipherSpi

Return the length of the given key in bits.

For compatibility this method is not declared abstract, and the default implementation will throw an java.lang.UnsupportedOperationException. Concrete subclasses should override this method to return the correct value.


RSAES_OAEP_DECRYPT

private byte[] RSAES_OAEP_DECRYPT(byte[] C)
                           throws javax.crypto.BadPaddingException,
                                  javax.crypto.IllegalBlockSizeException

RSAES_OAEP_ENCRYPT

private byte[] RSAES_OAEP_ENCRYPT(byte[] M)
                           throws javax.crypto.IllegalBlockSizeException

xor

private static byte[] xor(byte[] a,
                          byte[] b)

mgf1

private byte[] mgf1(byte[] seed,
                    int len)

mgf1Hash

private byte[] mgf1Hash(byte[] seed,
                        byte c)

concat

private byte[] concat(byte[] a,
                      byte[] b)

concat

private byte[] concat(byte[] a,
                      byte[] b,
                      byte[] c)

concat

private byte[] concat(byte[] a,
                      byte[] b,
                      byte[] c,
                      byte[] d)