All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.security.rsa.PublicKey

java.lang.Object
   |
   +----cryptix.security.rsa.PublicKey

public class PublicKey
extends Object
Note: PublicKey is deprecated. This class may be removed in a future version of Cryptix.

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 $

Author:
unattributed
See Also:
BaseRSAPublicKey

Variable Index

 o e_
The public exponent as a cryptix.math.BigInteger.
 o n_
The public modulus as a cryptix.math.BigInteger.

Constructor Index

 o PublicKey()
A constructor that does nothing, for use by subclasses.
 o PublicKey(BigInteger, BigInteger)
Creates a public key from a modulus and exponent.
 o PublicKey(PublicKey)
Creates a new public key from an existing key.

Method Index

 o bitLength()
Gets the key's bit length.
 o copy(Object)
Copies a key if it is an instance of cryptix.security.rsa.PublicKey.
 o e()
Returns a new cryptix.math.BigInteger equal to the public exponent.
 o encrypt(BigInteger)
Encrypts a number using this key.
 o equals(Object)
Tests whether another object is equal to this one.
 o fingerPrint()
Gets the key's fingerprint.
 o id()
Gets the key's ID.
 o n()
Returns a new cryptix.math.BigInteger equal to the public modulus.
 o toString()
Returns a string representation of this key in hex.

Variables

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

 o e_
 protected BigInteger e_
The public exponent as a cryptix.math.BigInteger.

Constructors

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

 o PublicKey
 public PublicKey(BigInteger n,
                  BigInteger e)
Creates a public key from a modulus and exponent.

Parameters:
n - the public modulus
e - the public exponent
 o PublicKey
 public PublicKey(PublicKey from)
Creates a new public key from an existing key.

Parameters:
from - the key to copy.

Methods

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

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

 o copy
 public void copy(Object src)
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)
 o equals
 public boolean equals(Object obj)
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.

Parameters:
obj - object to test
Returns:
true if the object is equal, otherwise false.
Overrides:
equals in class Object
 o id
 public final byte[] id()
Gets the key's ID.

Returns:
s the lower 8 bytes of n, the public modulus.
 o fingerPrint
 public final byte[] fingerPrint()
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.
 o bitLength
 public final int bitLength()
Gets the key's bit length.

Returns:
the length in bits of n, the public modulus.
 o encrypt
 public BigInteger encrypt(BigInteger plain)
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.
 o toString
 public String toString()
Returns a string representation of this key in hex.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index