cryptix.provider.rsa

Class BaseRSAPrivateKey

public abstract class BaseRSAPrivateKey extends 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

Constructor Summary
protected BaseRSAPrivateKey()
Constructs an RSA private key, without setting the parameters.
Method Summary
StringgetAlgorithm()
Returns the name of the algorithm, for this class always "RSA".
BigIntegergetExponent()
Return the private exponent d.
BigIntegergetInverseOfQModP()
Returns the multiplicative inverse of q modulo p.
BigIntegergetModulus()
Return the public modulus n: the product of both p and q.
BigIntegergetP()
Returns p, the first factor of the public modulus.
BigIntegergetQ()
Return q, the second factor of the public modulus.
protected voidsetRsaParams(BigInteger n, BigInteger d)
Sets the RSA parameters n and d.
protected voidsetRsaParams(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.
StringtoString()
Returns a string representation of this key.

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

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.

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.

Returns: the multiplicative inverse of q modulo p.

getModulus

public BigInteger getModulus()
Return the public modulus n: the product of both p and q.

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.

Returns: the first factor p

getQ

public BigInteger getQ()
Return q, the second factor of the public modulus.

Returns: the second factor q

setRsaParams

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

Throws: NullPointerException if n == null || d == null

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.

Throws: NullPointerException if d == null || p == null || q == null InvalidParameterException if u must be calculated, and gcd(q, p) != 1

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.