|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--org.logi.crypto.Crypto
|
+--org.logi.crypto.keys.K
|
+--org.logi.crypto.keys.RSAPrivateKey
An instance of this class handles a single RSA private key.
| Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
| Fields inherited from interface java.security.Key |
serialVersionUID |
| Fields inherited from interface java.security.PrivateKey |
serialVersionUID |
| Constructor Summary | |
RSAPrivateKey(java.math.BigInteger d,
java.math.BigInteger n)
Create a new RSA key (r,n). |
|
RSAPrivateKey(java.math.BigInteger d,
java.math.BigInteger p,
java.math.BigInteger q)
Create a new RSA key (r,n). |
|
| Method Summary | |
int |
cipherBlockSize()
Returns the size of the blocks that can be decrypted in one call to decrypt(). |
static KeyPair |
createKeys(java.math.BigInteger e,
java.math.BigInteger d,
java.math.BigInteger n)
Create a KeyPair object holding objects for the public RSA key (e,n) and the private RSA key (d,n). |
static KeyPair |
createKeys(int bitLength)
Create a pair of public/private keys. |
static KeyPair |
createKeys(java.lang.String username,
java.lang.String password,
java.lang.String hashFunction,
int bitLength)
Create a pair of public/private keys from a username/password pair. |
void |
decrypt(byte[] source,
int i,
byte[] dest,
int j)
Decrypt one block of data. |
boolean |
equals(java.lang.Object o)
Return true iff the two keys are equivalent. |
java.lang.String |
getAlgorithm()
The name of the algorithm is "RSA". |
byte[] |
getEncoded()
Return encoded version. |
Fingerprint |
getFingerprint()
Return the key's fingerprint using the default hash function. |
Fingerprint |
getFingerprint(java.lang.String algorithm)
Return the key's fingerprint using the specified hash function. |
java.lang.String |
getFormat()
Returns the name of the key-encoding format. |
java.math.BigInteger |
getModulus()
Return public modulus. |
java.math.BigInteger |
getPrivateExponent()
Return private exponent. |
int |
getSize()
Return the size of the key modulo in bits. |
int |
hashCode()
Return a hash-code based on the keys SHA1 fingerprint. |
boolean |
matches(Key key)
Check if a key mathces this. |
Fingerprint |
matchFingerprint()
Returns the default fingerprint of the matching key in the key-pair. |
Fingerprint |
matchFingerprint(java.lang.String algorithm)
Returns the default fingerprint of the matching key in the key-pair. |
static RSAPrivateKey |
parseCDS(java.lang.String[] param)
Used by Crypto.fromString when parsing a CDS. |
int |
plainBlockSize()
Returns the size of the blocks that can be encrypted in one call to encrypt(). |
void |
prettyPrint(java.io.PrintWriter out,
int ind,
int rec)
Print this object to out, indented with ind tabs, going down at most rec levels of recursion. |
BlindSignature |
sign(BlindFingerprint fp)
Create a signature for a blinded fingerprint with a private key. |
Signature |
sign(Fingerprint fp)
Create a signature for a Fingerprint with a private key. |
int |
signatureSize()
Returns the length of the signature in bytes. |
int |
signBlockSize()
Returns the maximum size in bytes of the fingerprint that can be signed. |
java.lang.String |
toString()
Return a CDS for this key. |
| Methods inherited from class org.logi.crypto.Crypto |
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.logi.crypto.keys.Key |
getFingerprint, getFingerprint, hashCode, matchFingerprint, matchFingerprint |
| Methods inherited from interface org.logi.crypto.io.PrettyPrintable |
prettyPrint |
| Methods inherited from interface java.security.Key |
getEncoded, getFormat |
| Constructor Detail |
public RSAPrivateKey(java.math.BigInteger d,
java.math.BigInteger n)
(r,n).
public RSAPrivateKey(java.math.BigInteger d,
java.math.BigInteger p,
java.math.BigInteger q)
(r,n).
It is a private key if pri is true.| Method Detail |
public static RSAPrivateKey parseCDS(java.lang.String[] param)
throws InvalidCDSException
A valid CDS can be created by calling the toString() method.
InvalidCDSException - if the CDS is malformed.Crypto.fromString(String)public static KeyPair createKeys(int bitLength)
bitLength or bitLength-1 bits.
public static KeyPair createKeys(java.lang.String username,
java.lang.String password,
java.lang.String hashFunction,
int bitLength)
throws InvalidCDSException
bitLength or bitLength-1 bits.
The keys are created by hashing the password, appending with
0's until it is bitLength bits long and
searching for a prime pby counting down from there.
Another prime q is found in the same way, but the
username is prepended to the password before hashing. Key-generation
proceeds as normally from there.
The hashFunction parameters directs which hash function to use. It must be the name of a supported hash function, such as MD5 or SHA1.
The username does not need to be secret and can in
fact be a fixed string. It plays a similar role as SALT in unix
password systems in protecting against dictionary attacks.
InvalidCDSException - if the specified hash function is not available.
public static KeyPair createKeys(java.math.BigInteger e,
java.math.BigInteger d,
java.math.BigInteger n)
throws KeyException
(e,n) and the private RSA key (d,n).KeyException - if (e,n) and (d,n) does not describe a valid
pair of RSA keys.public int getSize()
getSize in interface Keypublic java.lang.String getAlgorithm()
getAlgorithm in interface Keypublic java.math.BigInteger getModulus()
getModulus in interface java.security.interfaces.RSAKeypublic java.math.BigInteger getPrivateExponent()
getPrivateExponent in interface java.security.interfaces.RSAPrivateKeypublic java.lang.String toString()
toString in class java.lang.ObjectCrypto.fromString(java.io.Reader)
public void prettyPrint(java.io.PrintWriter out,
int ind,
int rec)
throws java.io.IOException
prettyPrint in interface PrettyPrintableprettyPrint in class Cryptopublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic final boolean matches(Key key)
matches in interface Keypublic int plainBlockSize()
plainBlockSize in interface DecryptionKeypublic int cipherBlockSize()
cipherBlockSize in interface DecryptionKey
public void decrypt(byte[] source,
int i,
byte[] dest,
int j)
source starting at offset i and
plaintext is written to dest, starting at
offset j.
The amount of data read and written will match the values returned
by cipherBlockSize() and plainBlockSize().
decrypt in interface DecryptionKeypublic int signBlockSize()
signBlockSize in interface SigningKeypublic int signatureSize()
signatureSize in interface SigningKey
public Signature sign(Fingerprint fp)
throws CryptoException
sign in interface SigningKeyKeyException - if the key modulus is shorter than the signature.KeyException - if this is not a private key
public BlindSignature sign(BlindFingerprint fp)
throws CryptoException
sign in interface BlindSigningKeyKeyException - if there are problems, depending on the implementing class.public final Fingerprint getFingerprint()
getFingerprint in interface Key
public final Fingerprint getFingerprint(java.lang.String algorithm)
throws InvalidCDSException
getFingerprint in interface KeyInvalidCDSException - if the specified hash function is not
available.public Fingerprint matchFingerprint()
matchFingerprint in interface Key
public Fingerprint matchFingerprint(java.lang.String algorithm)
throws InvalidCDSException
matchFingerprint in interface KeyInvalidCDSException - if the specified hash function is not
available.public final int hashCode()
hashCode in interface KeyhashCode in class java.lang.Objectpublic byte[] getEncoded()
getEncoded in interface java.security.Keypublic java.lang.String getFormat()
getFormat in interface java.security.Key
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL