wtanaka.praya.gale
Class GalePrivateKey
java.lang.Object
|
+--wtanaka.praya.gale.GalePrivateKey
- All Implemented Interfaces:
- java.security.Key, java.security.PrivateKey, java.io.Serializable
- public class GalePrivateKey
- extends java.lang.Object
- implements java.security.PrivateKey
Private Key used by the Gale Protocol.
How does RSA work?
We show a high-level though working description of RSA. Then, we give
an example with easy to work with numbers.
Description
To initialise RSA, follow the steps
1. Pick two large primes, p and q.
2. Find N = p * q. N is the RSA modulus.
3. Let e be a number relatively prime to (p-1)*(q-1).
4. Find d, so that d*e = 1 mod (p-1)*(q-1) .
5. The set (e, N) is the public key. Make it known to every one.
The set (d, N) is the private key. Keep it private and safe.
To encrypt a message m,
1. Make sure m < N, otherwise chop m in suitably small pieces and
perform RSA on each individual piece.
2. Compute c = m ^ e mod N
3. c is the encrypted message
To decrypt a ciphertext c,
1. Compute m = c ^ d mod N
2. m is the original message
To sign message m,
1. Compute s = m ^ d mod N
2. s is the digital signature. Send along with message m.
To verify signed message s,
1. Compute m = s ^ e mod N
2. Check if m from above calculation is the same with message sent.
Return to
or the Praya Homepage
- Version:
- $Name: $ $Date: 2001/10/17 09:19:13 $
- Author:
- $Author: wtanaka $
- See Also:
- Serialized Form
| Fields inherited from interface java.security.PrivateKey |
serialVersionUID |
|
Constructor Summary |
GalePrivateKey(java.io.File f)
|
GalePrivateKey(GaleInputStream in)
|
GalePrivateKey(java.lang.String id,
int bits,
java.math.BigInteger rsaModulus,
java.math.BigInteger rsaExponent,
java.math.BigInteger rsaPrivateExponent,
java.math.BigInteger rsaPrivatePrime1,
java.math.BigInteger rsaPrivatePrime2,
java.math.BigInteger rsaPrivatePrimeExponent1,
java.math.BigInteger rsaPrivatePrimeExponent2,
java.math.BigInteger rsaPrivateCoefficient)
Constructor for a newly generated key. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
MIN_RSA_MODULUS_BITS
public static final int MIN_RSA_MODULUS_BITS
MAX_RSA_MODULUS_BITS
public static final int MAX_RSA_MODULUS_BITS
MAX_RSA_MODULUS_LEN
public static final int MAX_RSA_MODULUS_LEN
MAX_RSA_PRIME_BITS
public static final int MAX_RSA_PRIME_BITS
MAX_RSA_PRIME_LEN
public static final int MAX_RSA_PRIME_LEN
DIGEST_INFO_A
public static final byte[] DIGEST_INFO_A
DIGEST_INFO_B
public static final byte[] DIGEST_INFO_B
DIGEST_INFO_LEN
public static final int DIGEST_INFO_LEN
GALE_RSA_MODULUS_BITS
public static final int GALE_RSA_MODULUS_BITS
GALE_RSA_MODULUS_LEN
public static final int GALE_RSA_MODULUS_LEN
GALE_RSA_PRIME_BITS
public static final int GALE_RSA_PRIME_BITS
GALE_RSA_PRIME_LEN
public static final int GALE_RSA_PRIME_LEN
GALE_ENCRYPTED_KEY_LEN
public static final int GALE_ENCRYPTED_KEY_LEN
GALE_SIGNATURE_LEN
public static final int GALE_SIGNATURE_LEN
m_id
java.lang.String m_id
m_owner
java.lang.String m_owner
m_bits
int m_bits
m_rsaModulus
java.math.BigInteger m_rsaModulus
- N
m_rsaExponent
java.math.BigInteger m_rsaExponent
m_rsaPrivateExponent
java.math.BigInteger m_rsaPrivateExponent
m_rsaPrivatePrime1
java.math.BigInteger m_rsaPrivatePrime1
- p
m_rsaPrivatePrime2
java.math.BigInteger m_rsaPrivatePrime2
- q
m_rsaPrivatePrimeExponent1
java.math.BigInteger m_rsaPrivatePrimeExponent1
m_rsaPrivatePrimeExponent2
java.math.BigInteger m_rsaPrivatePrimeExponent2
m_rsaPrivateCoefficient
java.math.BigInteger m_rsaPrivateCoefficient
m_fragments
FragmentList m_fragments
m_originalStreamVersion
int m_originalStreamVersion
GalePrivateKey
public GalePrivateKey(java.io.File f)
throws java.io.IOException
GalePrivateKey
public GalePrivateKey(GaleInputStream in)
throws java.io.IOException
GalePrivateKey
public GalePrivateKey(java.lang.String id,
int bits,
java.math.BigInteger rsaModulus,
java.math.BigInteger rsaExponent,
java.math.BigInteger rsaPrivateExponent,
java.math.BigInteger rsaPrivatePrime1,
java.math.BigInteger rsaPrivatePrime2,
java.math.BigInteger rsaPrivatePrimeExponent1,
java.math.BigInteger rsaPrivatePrimeExponent2,
java.math.BigInteger rsaPrivateCoefficient)
- Constructor for a newly generated key.
toPublicStub
public GalePublicKey toPublicStub()
- Gets the EXPORT_STUB public key corresponding to this ID. Used
for signing.
getID
public java.lang.String getID()
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithm in interface java.security.Key
getFormat
public java.lang.String getFormat()
- Specified by:
getFormat in interface java.security.Key
getEncoded
public byte[] getEncoded()
- Specified by:
getEncoded in interface java.security.Key
getModulus
public java.math.BigInteger getModulus()
getPrivateExponent
public java.math.BigInteger getPrivateExponent()
getPrivatePrime1
public java.math.BigInteger getPrivatePrime1()
getPrivatePrime2
public java.math.BigInteger getPrivatePrime2()
sign
public byte[] sign(byte[] message)
- See Also:
GalePublicKey.verify(byte[], byte[])
privateEncrypt
public java.math.BigInteger privateEncrypt(byte[] input)
privateDecrypt
public byte[] privateDecrypt(byte[] input)
- RSA private-key decryption, according to PKCS #1.
write
public void write(GaleOutputStream gout)
throws java.io.IOException,
NotEnoughInfoException
- Convenience method which writes this private key to the given
stream using the stream version this was originally constructed
with.
- Parameters:
gout - the output stream to write to- Throws:
NotEnoughInfoException - if this is a stub key. Use
exportStub instead.java.io.IOException - if any write to the stream throws
IOException
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object