cryptix.provider.rsa
Class BaseRSAPrivateKey

java.lang.Object
  |
  +--cryptix.provider.rsa.BaseRSAPrivateKey
All Implemented Interfaces:
CryptixRSAPrivateKey, java.security.Key, java.security.PrivateKey, RSAFactors, RSAKey, java.io.Serializable
Direct Known Subclasses:
RawRSAPrivateKey

public abstract class BaseRSAPrivateKey
extends java.lang.Object
implements CryptixRSAPrivateKey, RSAFactors

An abstract class representing an RSA private key.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.7 $

Since:
Cryptix 2.2.2
Author:
Raif S. Naffah, David Hopwood
See Also:
Serialized Form

Fields inherited from interface java.security.PrivateKey
serialVersionUID
 
Constructor Summary
protected BaseRSAPrivateKey()
          Constructs an RSA private key, without setting the parameters.
 
Method Summary
 java.lang.String getAlgorithm()
          Returns the name of the algorithm, for this class always "RSA".
 java.math.BigInteger getExponent()
          Return the private exponent d.
 java.math.BigInteger getInverseOfQModP()
          Returns the multiplicative inverse of q modulo p.
 java.math.BigInteger getModulus()
          Return the public modulus n: the product of both p and q.
 java.math.BigInteger getP()
          Returns p, the first factor of the public modulus.
 java.math.BigInteger getQ()
          Return q, the second factor of the public modulus.
protected  void setRsaParams(java.math.BigInteger n, java.math.BigInteger d)
          Sets the RSA parameters n and d.
protected  void setRsaParams(java.math.BigInteger d, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger u)
          Sets the RSA parameters d, p, q, and u, to allow fast execution of mathematical operations performed later on during the life of this key.
 java.lang.String toString()
          Returns a string representation of this key.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Key
getEncoded, getFormat
 

Constructor Detail

BaseRSAPrivateKey

protected BaseRSAPrivateKey()
Constructs an RSA private key, without setting the parameters. Subclasses should call one of the setRsaParams methods in each of their constructors.
Method Detail

getModulus

public java.math.BigInteger getModulus()
Return the public modulus n: the product of both p and q.
Specified by:
getModulus in interface RSAKey
Returns:
the public modulus n: the product of both p and q.

getExponent

public java.math.BigInteger getExponent()
Return the private exponent d.
Specified by:
getExponent in interface RSAKey
Returns:
the private exponent d.

getP

public java.math.BigInteger getP()
Returns p, the first factor of the public modulus.
Specified by:
getP in interface RSAFactors
Returns:
the first factor p

getQ

public java.math.BigInteger getQ()
Return q, the second factor of the public modulus.
Specified by:
getQ in interface RSAFactors
Returns:
the second factor q

getInverseOfQModP

public java.math.BigInteger getInverseOfQModP()
Returns the multiplicative inverse of q modulo p. The values p and q are those returned by the getP() and getQ() methods respectively.
Specified by:
getInverseOfQModP in interface RSAFactors
Returns:
the multiplicative inverse of q modulo p.

getAlgorithm

public java.lang.String getAlgorithm()
Returns the name of the algorithm, for this class always "RSA".
Specified by:
getAlgorithm in interface java.security.Key
Returns:
the name of the algorithm, "RSA".

setRsaParams

protected void setRsaParams(java.math.BigInteger n,
                            java.math.BigInteger d)
Sets the RSA parameters n and d.
Throws:
NullPointerException - if n == null || d == null

setRsaParams

protected void setRsaParams(java.math.BigInteger d,
                            java.math.BigInteger p,
                            java.math.BigInteger q,
                            java.math.BigInteger u)
Sets the RSA parameters d, p, q, and u, to allow fast execution of mathematical operations performed later on during the life of this key. u may be null, in which case it is calculated automatically.
Throws:
NullPointerException - if d == null || p == null || q == null
java.security.InvalidParameterException - if u must be calculated, and gcd(q, p) != 1

toString

public java.lang.String toString()
Returns a string representation of this key. This may reveal private information when debugging is enabled, and should be used with care.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this key.