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
-
e_
- The public exponent as a cryptix.math.BigInteger.
-
n_
- The public modulus as a cryptix.math.BigInteger.
-
PublicKey()
- A constructor that does nothing, for use by subclasses.
-
PublicKey(BigInteger, BigInteger)
- Creates a public key from a modulus and exponent.
-
PublicKey(PublicKey)
- Creates a new public key from an existing key.
-
bitLength()
- Gets the key's bit length.
-
copy(Object)
- Copies a key if it is an instance of cryptix.security.rsa.PublicKey.
-
e()
- Returns a new cryptix.math.BigInteger equal to the public exponent.
-
encrypt(BigInteger)
- Encrypts a number using this key.
-
equals(Object)
- Tests whether another object is equal to this one.
-
fingerPrint()
- Gets the key's fingerprint.
-
id()
- Gets the key's ID.
-
n()
- Returns a new cryptix.math.BigInteger equal to the public modulus.
-
toString()
- Returns a string representation of this key in hex.
n_
protected BigInteger n_
- The public modulus as a cryptix.math.BigInteger.
e_
protected BigInteger e_
- The public exponent as a cryptix.math.BigInteger.
PublicKey
protected PublicKey()
- A constructor that does nothing, for use by subclasses.
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
PublicKey
public PublicKey(PublicKey from)
- Creates a new public key from an existing key.
- Parameters:
- from - the key to copy.
n
public final BigInteger n()
- Returns a new cryptix.math.BigInteger equal to the public modulus.
e
public final BigInteger e()
- Returns a new cryptix.math.BigInteger equal to the public exponent.
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)
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
id
public final byte[] id()
- Gets the key's ID.
- Returns:
- s the lower 8 bytes of n, the public modulus.
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.
bitLength
public final int bitLength()
- Gets the key's bit length.
- Returns:
- the length in bits of n, the public modulus.
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.
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