com.mindbright.ssh2
public abstract class SSH2Signature extends java.lang.Object implements SSH2PKISigner
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
algorithm |
protected byte[] |
pubKeyBlob |
protected java.security.PublicKey |
publicKey |
protected java.security.Signature |
signature |
Modifier | Constructor and Description |
---|---|
protected |
SSH2Signature()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearSensitiveData()
Try to remove any sensitive data from memory.
|
protected abstract java.security.PublicKey |
decodePublicKey(byte[] pubKeyBlob)
Decode a public key blob.
|
protected abstract byte[] |
decodeSignature(byte[] sigBlob)
Decode the given signature blob from the ssh standard form to
the internal form.
|
protected abstract byte[] |
encodePublicKey(java.security.PublicKey publicKey)
Encode the given public key into a public key blob.
|
protected abstract byte[] |
encodeSignature(byte[] sigRaw)
Encode the given, internal form, signature into the ssh standard form.
|
java.lang.String |
getAlgorithmName()
Get the algorithm this instance handles.
|
static SSH2Signature |
getEncodingInstance(java.lang.String algorithm)
Get a
SSH2Signature instance suitable for encoding
with the given algorithm. |
static SSH2Signature |
getInstance(java.lang.String algorithm)
Get a
SSH2Signature instance suitable for encoding
with the given algorithm. |
java.security.PublicKey |
getPublicKey()
Get the public key associated with this
SSH2Signature object. |
byte[] |
getPublicKeyBlob()
Get the public key associated with this
SSH2Signature object. |
protected abstract java.lang.String |
getSignatureAlgorithm()
Get the signature algorithm.
|
void |
initSign(java.security.PrivateKey privateKey)
Prepare for signing with the given private key.
|
void |
initVerify(byte[] pubKeyBlob)
Prepare to verify a signature with the given public key.
|
void |
initVerify(java.security.PublicKey publicKey)
Prepare to verify a signature with the given public key.
|
void |
setIncompatibility(SSH2Transport transport)
Set eventual incompatibility modes depending on the remote end.
|
void |
setPublicKey(java.security.PublicKey publicKey)
Associate a public key with this object.
|
byte[] |
sign(byte[] data)
Sign the given data.
|
boolean |
verify(byte[] sigBlob,
byte[] data)
Verify that the given signature matches the given data and the
public key.
|
protected java.lang.String algorithm
protected java.security.Signature signature
protected java.security.PublicKey publicKey
protected byte[] pubKeyBlob
public static SSH2Signature getInstance(java.lang.String algorithm) throws SSH2Exception
SSH2Signature
instance suitable for encoding
with the given algorithm.algorithm
- The algorithm. Currently the valid values are
"ssh-dss" and "ssh-rsa".SSH2Exception
public static SSH2Signature getEncodingInstance(java.lang.String algorithm) throws SSH2Exception
SSH2Signature
instance suitable for encoding
with the given algorithm.algorithm
- The algorithm. Currently the valid values are
"ssh-dss" and "ssh-rsa".SSH2Exception
public final java.lang.String getAlgorithmName()
getAlgorithmName
in interface SSH2PKISigner
public final byte[] getPublicKeyBlob() throws SSH2SignatureException
SSH2Signature
object.getPublicKeyBlob
in interface SSH2PKISigner
SSH2SignatureException
public final java.security.PublicKey getPublicKey() throws SSH2SignatureException
SSH2Signature
object.SSH2SignatureException
public final void setPublicKey(java.security.PublicKey publicKey)
publicKey
- The key to associate.public void setIncompatibility(SSH2Transport transport)
SSH2PKISigner
setIncompatibility
in interface SSH2PKISigner
transport
- An SSH2Transport
object which identifies the
other end.public final void initSign(java.security.PrivateKey privateKey) throws SSH2Exception
privateKey
- Key to use for signing.SSH2Exception
public final void initVerify(java.security.PublicKey publicKey) throws SSH2Exception
publicKey
- Key to use when verifying.SSH2Exception
public final void initVerify(byte[] pubKeyBlob) throws SSH2Exception
pubKeyBlob
- key to use when verifying, encoded as a public
key blob.SSH2Exception
public byte[] sign(byte[] data) throws SSH2SignatureException
sign
in interface SSH2PKISigner
data
- Data to sign.SSH2SignatureException
public boolean verify(byte[] sigBlob, byte[] data) throws SSH2SignatureException
sigBlob
- Signature blob encoded in the ssh format.data
- Signed data.SSH2SignatureException
protected abstract java.lang.String getSignatureAlgorithm()
protected abstract byte[] encodePublicKey(java.security.PublicKey publicKey) throws SSH2Exception
publicKey
- The public key to encode. Must be an instance of
DSAPublicKey
.SSH2Exception
protected abstract java.security.PublicKey decodePublicKey(byte[] pubKeyBlob) throws SSH2Exception
pubKeyBlob
- A byte array containing a public key blob.Publickey
instance.SSH2Exception
protected abstract byte[] encodeSignature(byte[] sigRaw)
sigRaw
- The raw signature.protected abstract byte[] decodeSignature(byte[] sigBlob) throws SSH2SignatureException
sigBlob
- The encoded signature.SSH2SignatureException
public void clearSensitiveData()
SSH2PKISigner
clearSensitiveData
in interface SSH2PKISigner