com.mindbright.ssh2
Class SSH2SimpleSignature

java.lang.Object
  extended bycom.mindbright.ssh2.SSH2Signature
      extended bycom.mindbright.ssh2.SSH2SimpleSignature
All Implemented Interfaces:
SSH2PKISigner
Direct Known Subclasses:
SSH2DSS, SSH2RSA

public abstract class SSH2SimpleSignature
extends SSH2Signature

Handle signatures for the ssh draft standard algorithms.


Field Summary
protected  boolean draftIncompatibleSignature
           
protected  java.lang.String signatureAlgorithm
           
protected  java.lang.String ssh2KeyFormat
           
 
Fields inherited from class com.mindbright.ssh2.SSH2Signature
algorithm, privateKey, pubKeyBlob, publicKey, signature
 
Constructor Summary
protected SSH2SimpleSignature(java.lang.String signatureAlgorithm, java.lang.String ssh2KeyFormat)
          Constructor.
 
Method Summary
 byte[] decodeSignature(byte[] sigBlob)
          Decode a signature encoded according to the ssh standard.
 byte[] encodeSignature(byte[] sigRaw)
          Encode the given signature into the form specified by the ssh standard.
static java.lang.String getKeyFormat(byte[] pubKeyBlob)
          Get the key format of the given public key.
 java.lang.String getSignatureAlgorithm()
          Get the signature algorithm name.
static SSH2Signature getVerifyInstance(byte[] pubKeyBlob)
          Get an instance of SSH2Signature which is prepared to do a verify operation which the given public key.
 void setIncompatibility(SSH2Transport transport)
          Set the appropriate incompatibility mode which depends on the peer version.
 
Methods inherited from class com.mindbright.ssh2.SSH2Signature
clearSensitiveData, decodePublicKey, encodePublicKey, getAlgorithmName, getEncodingInstance, getInstance, getPublicKey, getPublicKeyBlob, initSign, initVerify, initVerify, setPublicKey, sign, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

signatureAlgorithm

protected java.lang.String signatureAlgorithm

ssh2KeyFormat

protected java.lang.String ssh2KeyFormat

draftIncompatibleSignature

protected boolean draftIncompatibleSignature
Constructor Detail

SSH2SimpleSignature

protected SSH2SimpleSignature(java.lang.String signatureAlgorithm,
                              java.lang.String ssh2KeyFormat)
Constructor.

Parameters:
signatureAlgorithm - The algorithm name to use when looking in the crypto provider for the implementation.
ssh2KeyFormat - The ssh2 name for this algorithm.
Method Detail

getVerifyInstance

public static SSH2Signature getVerifyInstance(byte[] pubKeyBlob)
                                       throws SSH2Exception
Get an instance of SSH2Signature which is prepared to do a verify operation which the given public key.

Parameters:
pubKeyBlob - Blob containing the public key to use.
Throws:
SSH2Exception

getSignatureAlgorithm

public final java.lang.String getSignatureAlgorithm()
Get the signature algorithm name. Used internally to find the right implementation of the algorithm.

Specified by:
getSignatureAlgorithm in class SSH2Signature
Returns:
The name of the algorithm.

encodeSignature

public byte[] encodeSignature(byte[] sigRaw)
Encode the given signature into the form specified by the ssh standard.

Specified by:
encodeSignature in class SSH2Signature
Parameters:
sigRaw - The signature as a raw byte array.
Returns:
The encoded signature as a byte array.

decodeSignature

public byte[] decodeSignature(byte[] sigBlob)
                       throws SSH2SignatureException
Decode a signature encoded according to the ssh standard.

Specified by:
decodeSignature in class SSH2Signature
Parameters:
sigBlob - a signature blob encodeded according to the ssh standard.
Returns:
The raw signature
Throws:
SSH2SignatureException

getKeyFormat

public static java.lang.String getKeyFormat(byte[] pubKeyBlob)
Get the key format of the given public key.

Parameters:
pubKeyBlob - the public key blob (encoded accoring to the ssh standard).
Returns:
The ssh name of the key format.

setIncompatibility

public void setIncompatibility(SSH2Transport transport)
Set the appropriate incompatibility mode which depends on the peer version.

Specified by:
setIncompatibility in interface SSH2PKISigner
Overrides:
setIncompatibility in class SSH2Signature
Parameters:
transport - SSH2Transport object which identifies the peer.