org.logi.crypto.keys
Class KeyPair

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.keys.KeyPair

public class KeyPair
extends Crypto

This class is a simple holder for a pair of public/private keys. Some encryption algorithms only use a single key, in which case the public and private fields of a KeyPair may reference the same object. Either the public or private fields may be null if the corresponding key is unknown.

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
Key, KeyRing

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
KeyPair(Key pub, Key pri)
          Create a new KeyPair holder.
 
Method Summary
 Key getPrivate()
          Return the private key from the pair.
 Key getPublic()
          Return the public key from the pair.
static KeyPair parseCDS(java.lang.String[] param)
          Used by Crypto.fromString when parsing a CDS.
 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.
 java.lang.String toString()
          Return a CDS for this key-pair.
 
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyPair

public KeyPair(Key pub,
               Key pri)
Create a new KeyPair holder.
Method Detail

getPublic

public Key getPublic()
Return the public key from the pair.

getPrivate

public Key getPrivate()
Return the private key from the pair.

parseCDS

public static KeyPair parseCDS(java.lang.String[] param)
                        throws InvalidCDSException
Used by Crypto.fromString when parsing a CDS.

A valid CDS can be created by calling the toString() method.

Throws:
InvalidCDSException - if the CDS is malformed.
See Also:
Crypto.fromString(String)

toString

public java.lang.String toString()
Return a CDS for this key-pair.
Overrides:
toString in class java.lang.Object
See Also:
Crypto.fromString(String)

prettyPrint

public void prettyPrint(java.io.PrintWriter out,
                        int ind,
                        int rec)
                 throws java.io.IOException
Print this object to out, indented with ind tabs, going down at most rec levels of recursion.
Overrides:
prettyPrint in class Crypto


Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL