cryptix.security.rsa
Class PublicKey

java.lang.Object
  |
  +--cryptix.security.rsa.PublicKey
Direct Known Subclasses:
SecretKey

Deprecated. This class may be removed in a future version of Cryptix.

public class PublicKey
extends java.lang.Object

This class represents an RSA public key. It can only verify signatures or encrypt.

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

$Revision: 1.2 $

Since:
Cryptix 2.2 or earlier
Author:
unattributed
See Also:
cryptix.provider.rsa.BaseRSAPublicKey

Field Summary
protected  BigInteger e_
          Deprecated. The public exponent as a cryptix.math.BigInteger.
protected  BigInteger n_
          Deprecated. The public modulus as a cryptix.math.BigInteger.
 
Constructor Summary
protected PublicKey()
          Deprecated. A constructor that does nothing, for use by subclasses.
  PublicKey(BigInteger n, BigInteger e)
          Deprecated. Creates a public key from a modulus and exponent.
  PublicKey(PublicKey from)
          Deprecated. Creates a new public key from an existing key.
 
Method Summary
 int bitLength()
          Deprecated. Gets the key's bit length.
 void copy(java.lang.Object src)
          Deprecated. Copies a key if it is an instance of cryptix.security.rsa.PublicKey.
 BigInteger e()
          Deprecated. Returns a new cryptix.math.BigInteger equal to the public exponent.
 BigInteger encrypt(BigInteger plain)
          Deprecated. Encrypts a number using this key.
 boolean equals(java.lang.Object obj)
          Deprecated. Tests whether another object is equal to this one.
 byte[] fingerPrint()
          Deprecated. Gets the key's fingerprint.
 byte[] id()
          Deprecated. Gets the key's ID.
 BigInteger n()
          Deprecated. Returns a new cryptix.math.BigInteger equal to the public modulus.
 java.lang.String toString()
          Deprecated. Returns a string representation of this key in hex.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

n_

protected BigInteger n_
Deprecated. 
The public modulus as a cryptix.math.BigInteger.

e_

protected BigInteger e_
Deprecated. 
The public exponent as a cryptix.math.BigInteger.
Constructor Detail

PublicKey

protected PublicKey()
Deprecated. 
A constructor that does nothing, for use by subclasses.

PublicKey

public PublicKey(BigInteger n,
                 BigInteger e)
Deprecated. 
Creates a public key from a modulus and exponent.
Parameters:
n - the public modulus
e - the public exponent

PublicKey

public PublicKey(PublicKey from)
Deprecated. 
Creates a new public key from an existing key.
Parameters:
from - the key to copy.
Method Detail

n

public final BigInteger n()
Deprecated. 
Returns a new cryptix.math.BigInteger equal to the public modulus.

e

public final BigInteger e()
Deprecated. 
Returns a new cryptix.math.BigInteger equal to the public exponent.

copy

public void copy(java.lang.Object src)
Deprecated. 
Copies a key if it is an instance of cryptix.security.rsa.PublicKey.
Parameters:
src - the object to copy from
Throws:
ClassCastException - if !(src instanceof cryptix.security.rsa.PublicKey)

equals

public boolean equals(java.lang.Object obj)
Deprecated. 
Tests whether another object is equal to this one.

Note: since PublicKey objects are mutable (because of the copy method), it was a mistake to override equals. Also, equals and hashCode should always be overridden together.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to test
Returns:
true if the object is equal, otherwise false.

id

public final byte[] id()
Deprecated. 
Gets the key's ID.

fingerPrint

public final byte[] fingerPrint()
Deprecated. 
Gets the key's fingerprint.

WARNING: because the lengths of n and e are not encoded, it is feasible to create distinct keys with the same fingerprint. See http://www.hotlava.com/doc/fag-pgp/.

Returns:
an MD5 hash of n and e.

bitLength

public final int bitLength()
Deprecated. 
Gets the key's bit length.
Returns:
the length in bits of n, the public modulus.

encrypt

public BigInteger encrypt(BigInteger plain)
Deprecated. 
Encrypts a number using this key. This can also be used to verify RSA signatures.

Note: using RSA directly without random padding can be insecure.

Parameters:
plain - the number to encrypt.
Returns:
the result of the encryption.

toString

public java.lang.String toString()
Deprecated. 
Returns a string representation of this key in hex.
Overrides:
toString in class java.lang.Object