JXTA

jxta.security.impl.publickey
Class RSAKey

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

public final class RSAKey
extends java.lang.Object
implements jxta.security.publickey.RSAPublicKey, jxta.security.publickey.RSAPrivateKey


Fields inherited from interface jxta.security.publickey.RSAPublicKey
name
 
Fields inherited from interface jxta.security.publickey.RSAPrivateKey
name
 
Constructor Summary
RSAKey(byte type, short len)
          Constructor
 
Method Summary
 void clearDebug()
          turn off debugging
 void clearKey()
          Clear key values
 boolean equals(jxta.security.publickey.RSAPrivateKey key)
           
 boolean equals(jxta.security.publickey.RSAPublicKey key)
           
 java.lang.String getAlgorithmName()
           
 int getCrtCoefficient(byte[] crtCo, int offset)
           
 int getCrtCoefficientLength()
          Chinese remainder theorem coefficient 1/q mod p
 int getLength()
          get Key length in bytes
 int getModulus(byte[] mod, int offset)
           
 int getModulusLength()
          get modulus length, n Note: This may exceed the keysize in bytes by one byte.
 int getPrimeExponentP(byte[] pExpP, int offset)
           
 int getPrimeExponentPLength()
          prime exponent, d mod (p-1)
 int getPrimeExponentQ(byte[] pExpQ, int offset)
           
 int getPrimeExponentQLength()
          prime exponent, d mod (q-1)
 int getPrimeP(byte[] prP, int offset)
           
 int getPrimePLength()
          Prime p
 int getPrimeQ(byte[] prQ, int offset)
           
 int getPrimeQLength()
          Prime q
 int getPrivateExponent(byte[] exp, int offset)
           
 int getPrivateExponentLength()
          get private exponent length d = 1/e mod (p-1)(q-1)
 int getPublicExponent(byte[] exp, int offset)
          copy the exponent into the byte array and return the exponent length in bytes.
 int getPublicExponentLength()
          get public exponent length e
 short getSize()
          get Key length in bits
 byte getType()
          Get key type
 boolean isInitialized()
          Check initialization state of key
 boolean RSAEquals(RSAKey k, byte type)
          Return true if key is equal to "this" key.
 void setCrtCoefficient(byte[] crtCo, int offset, int length)
          1/q mod p
 void setDebug()
          turn on debugging
 void setModulus(byte[] mod, int offset, int len)
          Store the modulus as restricted by our size.
 void setPrimeExponentP(byte[] pExpP, int offset, int length)
          d mod(p - 1)
 void setPrimeExponentQ(byte[] pExpQ, int offset, int length)
          d mod(q - 1)
 void setPrimeP(byte[] prP, int offset, int length)
           
 void setPrimeQ(byte[] prQ, int offset, int length)
           
 void setPrivateExponent(byte[] exp, int offset, int len)
           
 void setPublicExponent(byte[] exp, int offset, int len)
          Store the exponent as restricted by our size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSAKey

public RSAKey(byte type,
              short len)
Constructor
Method Detail

getAlgorithmName

public java.lang.String getAlgorithmName()

setDebug

public void setDebug()
turn on debugging

clearDebug

public void clearDebug()
turn off debugging

isInitialized

public boolean isInitialized()
Check initialization state of key

clearKey

public void clearKey()
Clear key values

getSize

public short getSize()
get Key length in bits

getLength

public int getLength()
get Key length in bytes

getType

public byte getType()
Get key type

equals

public boolean equals(jxta.security.publickey.RSAPrivateKey key)
Specified by:
equals in interface jxta.security.publickey.RSAPrivateKey

equals

public boolean equals(jxta.security.publickey.RSAPublicKey key)
Specified by:
equals in interface jxta.security.publickey.RSAPublicKey

RSAEquals

public boolean RSAEquals(RSAKey k,
                         byte type)
Return true if key is equal to "this" key. Otherwise false. Here we can compare key type, lengths of the exponents and moduli, and finally the byte arrays themselves.

getPublicExponentLength

public int getPublicExponentLength()
get public exponent length e
Specified by:
getPublicExponentLength in interface jxta.security.publickey.RSAPublicKey

getPrivateExponentLength

public int getPrivateExponentLength()
get private exponent length d = 1/e mod (p-1)(q-1)

getModulusLength

public int getModulusLength()
get modulus length, n Note: This may exceed the keysize in bytes by one byte. This is because big integer arithmetic will prepend a (byte)0x00 if the sign bit is set. Similarly for p, and q.
Specified by:
getModulusLength in interface jxta.security.publickey.RSAPublicKey

getPrimePLength

public int getPrimePLength()
Prime p
Specified by:
getPrimePLength in interface jxta.security.publickey.RSAPrivateKey

getPrimeQLength

public int getPrimeQLength()
Prime q
Specified by:
getPrimeQLength in interface jxta.security.publickey.RSAPrivateKey

getPrimeExponentPLength

public int getPrimeExponentPLength()
prime exponent, d mod (p-1)
Specified by:
getPrimeExponentPLength in interface jxta.security.publickey.RSAPrivateKey

getPrimeExponentQLength

public int getPrimeExponentQLength()
prime exponent, d mod (q-1)
Specified by:
getPrimeExponentQLength in interface jxta.security.publickey.RSAPrivateKey

getCrtCoefficientLength

public int getCrtCoefficientLength()
Chinese remainder theorem coefficient 1/q mod p
Specified by:
getCrtCoefficientLength in interface jxta.security.publickey.RSAPrivateKey

setPublicExponent

public void setPublicExponent(byte[] exp,
                              int offset,
                              int len)
                       throws jxta.security.exceptions.CryptoException
Store the exponent as restricted by our size.
Specified by:
setPublicExponent in interface jxta.security.publickey.RSAPublicKey

setPrivateExponent

public void setPrivateExponent(byte[] exp,
                               int offset,
                               int len)
                        throws jxta.security.exceptions.CryptoException
Specified by:
setPrivateExponent in interface jxta.security.publickey.RSAPrivateKey

setModulus

public void setModulus(byte[] mod,
                       int offset,
                       int len)
                throws jxta.security.exceptions.CryptoException
Store the modulus as restricted by our size.
Specified by:
setModulus in interface jxta.security.publickey.RSAPublicKey

setPrimeP

public void setPrimeP(byte[] prP,
                      int offset,
                      int length)
               throws jxta.security.exceptions.CryptoException
Specified by:
setPrimeP in interface jxta.security.publickey.RSAPrivateKey

setPrimeQ

public void setPrimeQ(byte[] prQ,
                      int offset,
                      int length)
               throws jxta.security.exceptions.CryptoException
Specified by:
setPrimeQ in interface jxta.security.publickey.RSAPrivateKey

setPrimeExponentP

public void setPrimeExponentP(byte[] pExpP,
                              int offset,
                              int length)
                       throws jxta.security.exceptions.CryptoException
d mod(p - 1)
Specified by:
setPrimeExponentP in interface jxta.security.publickey.RSAPrivateKey

setPrimeExponentQ

public void setPrimeExponentQ(byte[] pExpQ,
                              int offset,
                              int length)
                       throws jxta.security.exceptions.CryptoException
d mod(q - 1)
Specified by:
setPrimeExponentQ in interface jxta.security.publickey.RSAPrivateKey

setCrtCoefficient

public void setCrtCoefficient(byte[] crtCo,
                              int offset,
                              int length)
                       throws jxta.security.exceptions.CryptoException
1/q mod p
Specified by:
setCrtCoefficient in interface jxta.security.publickey.RSAPrivateKey

getPublicExponent

public int getPublicExponent(byte[] exp,
                             int offset)
copy the exponent into the byte array and return the exponent length in bytes.
Specified by:
getPublicExponent in interface jxta.security.publickey.RSAPublicKey

getPrivateExponent

public int getPrivateExponent(byte[] exp,
                              int offset)
Specified by:
getPrivateExponent in interface jxta.security.publickey.RSAPrivateKey

getModulus

public int getModulus(byte[] mod,
                      int offset)
Specified by:
getModulus in interface jxta.security.publickey.RSAPublicKey

getPrimeP

public int getPrimeP(byte[] prP,
                     int offset)
Specified by:
getPrimeP in interface jxta.security.publickey.RSAPrivateKey

getPrimeQ

public int getPrimeQ(byte[] prQ,
                     int offset)
Specified by:
getPrimeQ in interface jxta.security.publickey.RSAPrivateKey

getPrimeExponentP

public int getPrimeExponentP(byte[] pExpP,
                             int offset)
Specified by:
getPrimeExponentP in interface jxta.security.publickey.RSAPrivateKey

getPrimeExponentQ

public int getPrimeExponentQ(byte[] pExpQ,
                             int offset)
Specified by:
getPrimeExponentQ in interface jxta.security.publickey.RSAPrivateKey

getCrtCoefficient

public int getCrtCoefficient(byte[] crtCo,
                             int offset)
Specified by:
getCrtCoefficient in interface jxta.security.publickey.RSAPrivateKey

JXTA