JXTA

jxta.security.impl.publickey
Class RSA

java.lang.Object
  |
  +--jxta.security.impl.publickey.RSA

public class RSA
extends java.lang.Object
implements jxta.security.publickey.PublicKeyAlgorithm


Fields inherited from interface jxta.security.publickey.PublicKeyAlgorithm
name
 
Constructor Summary
RSA(RSAKey rKey)
          Note: KeyBuilder must be called prior to instantiating this class to set the appropriate size.
 
Method Summary
 byte[] Algorithm(byte[] data, int offset, int length, byte type, boolean encrypt)
          Encrypt/decrypt byte array.
 void clearDebug()
          turn off debugging
 java.lang.String getAlgorithmName()
          // Algorithm name
 int getEncryptionBlockLength()
          length 0f Datablock + padding (Modulus in bytes)
 int getMaxInputDataBlockLength()
          max input data block length
 java.lang.Object getPrivatekey()
          get the RSA private key data
 java.lang.Object getPublickey()
          get the RSA public key data
 void reset()
           
 void setDebug()
          turn on debugging
 void setPrivateKey()
          Compute the private key from the public key Here, we compute d = 1/e mod((p-1)(q-1)), and store the remainder of the CRT parameters
 void setPrivateKey(java.lang.Object privatekeyData)
          Set private key from saved values
 void setPublicKey()
          Compute the public key given the key size in bits Here, we compute p, q, and n = pq.
 void setPublicKey(byte[] nModulus)
          Set the public key from a saved value for public key
 void setPublicKey(java.lang.Object publickeyData)
          Set the public key from a saved value for public key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSA

public RSA(RSAKey rKey)
    throws jxta.security.exceptions.CryptoException
Note: KeyBuilder must be called prior to instantiating this class to set the appropriate size.
Method Detail

setDebug

public void setDebug()
turn on debugging

clearDebug

public void clearDebug()
turn off debugging

reset

public void reset()
Specified by:
reset in interface jxta.security.publickey.PublicKeyAlgorithm

getAlgorithmName

public java.lang.String getAlgorithmName()
// Algorithm name

getMaxInputDataBlockLength

public int getMaxInputDataBlockLength()
max input data block length
Specified by:
getMaxInputDataBlockLength in interface jxta.security.publickey.PublicKeyAlgorithm

getEncryptionBlockLength

public int getEncryptionBlockLength()
length 0f Datablock + padding (Modulus in bytes)
Specified by:
getEncryptionBlockLength in interface jxta.security.publickey.PublicKeyAlgorithm

Algorithm

public byte[] Algorithm(byte[] data,
                        int offset,
                        int length,
                        byte type,
                        boolean encrypt)
                 throws jxta.security.exceptions.CryptoException
Encrypt/decrypt byte array. o Decrypt: 1) Public key decryption of private key encryption. CRT private key encrpytion used: length <= modulus length 2) Private key decryption of public key encryption (modulus length) <= length <= (modulus length + 1) o Encrypt: If size <= (modulus length - 11), then this is a legal encrypt, and we add the required padding before encryption as per PKCS #1 (rfc 2313) In this case the size MUST be <= than the modulus length in bytes - 11. If not, an illegal size error is thrown.
Specified by:
Algorithm in interface jxta.security.publickey.PublicKeyAlgorithm

setPrivateKey

public void setPrivateKey()
                   throws jxta.security.exceptions.CryptoException
Compute the private key from the public key Here, we compute d = 1/e mod((p-1)(q-1)), and store the remainder of the CRT parameters
Specified by:
setPrivateKey in interface jxta.security.publickey.PublicKeyAlgorithm

setPrivateKey

public void setPrivateKey(java.lang.Object privatekeyData)
                   throws jxta.security.exceptions.CryptoException
Set private key from saved values
Specified by:
setPrivateKey in interface jxta.security.publickey.PublicKeyAlgorithm

setPublicKey

public void setPublicKey()
                  throws jxta.security.exceptions.CryptoException
Compute the public key given the key size in bits Here, we compute p, q, and n = pq.
Specified by:
setPublicKey in interface jxta.security.publickey.PublicKeyAlgorithm

setPublicKey

public void setPublicKey(byte[] nModulus)
                  throws jxta.security.exceptions.CryptoException
Set the public key from a saved value for public key
Specified by:
setPublicKey in interface jxta.security.publickey.PublicKeyAlgorithm

setPublicKey

public void setPublicKey(java.lang.Object publickeyData)
                  throws jxta.security.exceptions.CryptoException
Set the public key from a saved value for public key
Specified by:
setPublicKey in interface jxta.security.publickey.PublicKeyAlgorithm

getPublickey

public java.lang.Object getPublickey()
                              throws jxta.security.exceptions.CryptoException
get the RSA public key data
Specified by:
getPublickey in interface jxta.security.publickey.PublicKeyAlgorithm

getPrivatekey

public java.lang.Object getPrivatekey()
                               throws jxta.security.exceptions.CryptoException
get the RSA private key data
Specified by:
getPrivatekey in interface jxta.security.publickey.PublicKeyAlgorithm

JXTA