cryptix.provider.rsa

Class BaseRSAPrivateKey

Implemented Interfaces:
CryptixRSAPrivateKey, PrivateKey, RSAFactors, RSAKey
Known Direct 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 $

Authors:
Raif S. Naffah
David Hopwood
Since:
Cryptix 2.2.2

Constructor Summary

BaseRSAPrivateKey()
Constructs an RSA private key, without setting the parameters.

Method Summary

String
getAlgorithm()
Returns the name of the algorithm, for this class always "RSA".
BigInteger
getExponent()
Return the private exponent d.
BigInteger
getInverseOfQModP()
Returns the multiplicative inverse of q modulo p.
BigInteger
getModulus()
Return the public modulus n: the product of both p and q.
BigInteger
getP()
Returns p, the first factor of the public modulus.
BigInteger
getQ()
Return q, the second factor of the public modulus.
protected void
setRsaParams(BigInteger n, BigInteger d)
Sets the RSA parameters n and d.
protected void
setRsaParams(BigInteger d, BigInteger p, BigInteger q, 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.
String
toString()
Returns a string representation of this key.

Constructor Details

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 Details

getAlgorithm

public String getAlgorithm()
Returns the name of the algorithm, for this class always "RSA".
Returns:
the name of the algorithm, "RSA".

getExponent

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

getInverseOfQModP

public 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.

getModulus

public 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.

getP

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

getQ

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

setRsaParams

protected void setRsaParams(BigInteger n,
                            BigInteger d)
Sets the RSA parameters n and d.

setRsaParams

protected void setRsaParams(BigInteger d,
                            BigInteger p,
                            BigInteger q,
                            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.

toString

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