Package net.schmizz.sshj.signature
Class AbstractSignature
- java.lang.Object
-
- net.schmizz.sshj.signature.AbstractSignature
-
- All Implemented Interfaces:
Signature
- Direct Known Subclasses:
AbstractSignatureDSA
,SignatureEdDSA
,SignatureRSA
public abstract class AbstractSignature extends java.lang.Object implements Signature
An abstract class forSignature
that implements common functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.security.Signature
signature
private java.lang.String
signatureName
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSignature(java.lang.String algorithm, java.lang.String signatureName)
protected
AbstractSignature(java.security.Signature signatureEngine, java.lang.String signatureName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
extractSig(byte[] sig, java.lang.String expectedKeyAlgorithm)
Check whether the signature is generated using the expected algorithm, and if so, return the signature blobjava.lang.String
getSignatureName()
void
initSign(java.security.PrivateKey privateKey)
Initialize this signature with the given private key for signing.void
initVerify(java.security.PublicKey publicKey)
Initialize this signature with the given public key for signature verification.byte[]
sign()
Compute the signature.void
update(byte[] foo)
Convenience method, same as callingSignature.update(byte[], int, int)
with offset as0
andH.length
.void
update(byte[] foo, int off, int len)
Update the computed signature with the given data.
-
-
-
Method Detail
-
getSignatureName
public java.lang.String getSignatureName()
- Specified by:
getSignatureName
in interfaceSignature
-
initVerify
public void initVerify(java.security.PublicKey publicKey)
Description copied from interface:Signature
Initialize this signature with the given public key for signature verification. Note that subsequent calls to eitherSignature.initVerify(PublicKey)
orSignature.initSign(PrivateKey)
will overwrite prior initialization.- Specified by:
initVerify
in interfaceSignature
- Parameters:
publicKey
- the public key to use for signature verification
-
initSign
public void initSign(java.security.PrivateKey privateKey)
Description copied from interface:Signature
Initialize this signature with the given private key for signing. Note that subsequent calls to eitherSignature.initVerify(PublicKey)
orSignature.initSign(PrivateKey)
will overwrite prior initialization.
-
update
public void update(byte[] foo)
Description copied from interface:Signature
Convenience method, same as callingSignature.update(byte[], int, int)
with offset as0
andH.length
.
-
update
public void update(byte[] foo, int off, int len)
Description copied from interface:Signature
Update the computed signature with the given data.
-
sign
public byte[] sign()
Description copied from interface:Signature
Compute the signature.
-
extractSig
protected byte[] extractSig(byte[] sig, java.lang.String expectedKeyAlgorithm)
Check whether the signature is generated using the expected algorithm, and if so, return the signature blob- Parameters:
sig
- The full signatureexpectedKeyAlgorithm
- The expected key algorithm- Returns:
- The blob part of the signature
-
-